aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorlouise <louise>2009-04-06 09:30:26 +0000
committerlouise <louise>2009-04-06 09:30:26 +0000
commitea8b613191aa95cbb2a8c51b71981e3801af4712 (patch)
treefb55adc9ca2c17826ae51c562ae7677c45c850ee /spec/models/user_spec.rb
parented6861f787408e603c238a5e1c8e7c8297a58206 (diff)
Add a convenience method User.requires_admin_power? for determining whether a user has the power to edit "requires_admin" requests
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index be56faf39..5b7b08a7d 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -103,4 +103,24 @@ describe User, "when checking abilities" do
end
-
+describe User, 'when asked if a user has the ability to edit "requires admin" requests' do
+
+ before do
+ @mock_user = mock_model(User)
+ end
+
+ it 'should return false if no user is passed' do
+ User.requires_admin_power?(nil).should be_false
+ end
+
+ it 'should return true if the user has "requires admin" power' do
+ @mock_user.stub!(:requires_admin_power?).and_return true
+ User.requires_admin_power?(@mock_user).should be_true
+ end
+
+ it 'should return false if the user does not have "requires admin" power' do
+ @mock_user.stub!(:requires_admin_power?).and_return false
+ User.requires_admin_power?(@mock_user).should be_false
+ end
+
+end