Skip to content

Commit

Permalink
Added tests for issues and translate controllers just to test permission
Browse files Browse the repository at this point in the history
level
  • Loading branch information
Doug Youch committed Jun 22, 2010
1 parent be444c6 commit f951a92
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
47 changes: 47 additions & 0 deletions spec/controllers/manage/issues_controller_spec.rb
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
49 changes: 49 additions & 0 deletions spec/controllers/manage/translate_controller_spec.rb
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

0 comments on commit f951a92

Please sign in to comment.