-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#51 Tests for admin only secrets controller
- Loading branch information
1 parent
f694bc4
commit e0306dc
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'spec_helper' | ||
|
||
describe Admin::SecretsController do | ||
setup :activate_authlogic | ||
|
||
describe "GET index as an admin" do | ||
before do | ||
@account = Account.create! :username => "testaccount", :password => "123456", :password_confirmation => "123456" | ||
@account.update_attribute(:is_admin, true) | ||
@account_session = AccountSession.create! @account | ||
@secret = Secret.create! :secret_text => "pssssst" | ||
get :index | ||
end | ||
subject { response } | ||
|
||
it "should load secrets" do | ||
assigns(:secrets).should eq([@secret]) | ||
end | ||
it { should be_success } | ||
it { should render_template( "index" ) } | ||
end | ||
|
||
describe "GET index as an regular user" do | ||
before do | ||
@account = Account.create! :username => "testaccount", :password => "123456", :password_confirmation => "123456" | ||
@account_session = AccountSession.create! @account | ||
get :index | ||
end | ||
subject { response } | ||
|
||
it { should be_redirect } | ||
end | ||
|
||
describe "GET index when not logged in" do | ||
before do | ||
@account_session = nil | ||
get :index | ||
end | ||
subject { response } | ||
|
||
it { should be_redirect } | ||
end | ||
|
||
end |