-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for issues and translate controllers just to test permission
level
- Loading branch information
Doug Youch
committed
Jun 22, 2010
1 parent
be444c6
commit f951a92
Showing
2 changed files
with
96 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,47 @@ | ||
require File.dirname(__FILE__) + "/../../spec_helper" | ||
|
||
describe Manage::IssuesController do | ||
|
||
reset_system_tables :client_users, :clients, :domains, :domain_databases | ||
reset_domain_tables :end_users | ||
|
||
before(:each) do | ||
@domain = Domain.find CMS_DEFAULTS['testing_domain'] | ||
@client = @domain.client | ||
end | ||
|
||
it "should permit system administrators" do | ||
@user = @client.client_users.create :username => 'my_system_admin', :client_admin => 1, :system_admin => 1 | ||
@myself = @user.end_user | ||
controller.should_receive('myself').at_least(:once).and_return(@myself) | ||
get 'index' | ||
response.should render_template('index') | ||
end | ||
|
||
it "should not permit client administrators" do | ||
@user = @client.client_users.create :username => 'my_system_admin', :client_admin => 1, :system_admin => 0 | ||
@myself = @user.end_user | ||
controller.should_receive('myself').at_least(:once).and_return(@myself) | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
|
||
it "should redirect if not a system admin" do | ||
@user = @client.client_users.create :username => 'my_system_admin', :client_admin => 0, :system_admin => 0 | ||
@myself = @user.end_user | ||
controller.should_receive('myself').at_least(:once).and_return(@myself) | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
|
||
it "should redirect if not a system admin" do | ||
mock_user | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
|
||
it "should redirect if not a system admin" do | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
end |
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,49 @@ | ||
require File.dirname(__FILE__) + "/../../spec_helper" | ||
|
||
describe Manage::TranslateController do | ||
|
||
reset_system_tables :client_users, :clients, :domains, :domain_databases | ||
reset_domain_tables :end_users | ||
|
||
before(:each) do | ||
@domain = Domain.find CMS_DEFAULTS['testing_domain'] | ||
@client = @domain.client | ||
end | ||
|
||
it "should permit system administrators" do | ||
@user = @client.client_users.create :username => 'my_system_admin', :client_admin => 1, :system_admin => 1 | ||
@myself = @user.end_user | ||
@language = mock :id => 1 | ||
Locale.should_receive(:language).at_least(:once).and_return(@language) | ||
controller.should_receive('myself').at_least(:once).and_return(@myself) | ||
get 'index' | ||
response.should render_template('index') | ||
end | ||
|
||
it "should not permit client administrators" do | ||
@user = @client.client_users.create :username => 'my_system_admin', :client_admin => 1, :system_admin => 0 | ||
@myself = @user.end_user | ||
controller.should_receive('myself').at_least(:once).and_return(@myself) | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
|
||
it "should redirect if not a system admin" do | ||
@user = @client.client_users.create :username => 'my_system_admin', :client_admin => 0, :system_admin => 0 | ||
@myself = @user.end_user | ||
controller.should_receive('myself').at_least(:once).and_return(@myself) | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
|
||
it "should redirect if not a system admin" do | ||
mock_user | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
|
||
it "should redirect if not a system admin" do | ||
get 'index' | ||
response.should redirect_to(:controller => '/manage/access', :action => 'denied') | ||
end | ||
end |