aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei Xie <xieconnect@gmail.com>2010-07-25 00:42:49 +0800
committerHans de Graaff <hans@degraaff.org>2010-07-25 09:08:30 +0200
commitcc5c9dc39ccda80385970f03aa79370625ad17fa (patch)
treee23e27f49d815652821f8e1b605a0866b91764bd
parentignore db/schema.rb (diff)
downloadcouncil-webapp-cc5c9dc39ccda80385970f03aa79370625ad17fa.tar.gz
council-webapp-cc5c9dc39ccda80385970f03aa79370625ad17fa.tar.bz2
council-webapp-cc5c9dc39ccda80385970f03aa79370625ad17fa.zip
fix User spec indention
-rw-r--r--spec/models/user_spec.rb66
1 files changed, 36 insertions, 30 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 5e6e41a..cf88645 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,39 +1,45 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User do
- before(:each) do
- @admin = users(:admin)
- @other_user = users(:developer)
- end
+ before(:each) do
+ @admin = users(:admin)
+ @other_user = users(:developer)
+ end
it "should be administrator" do
- @admin.should be_administrator
+ @admin.should be_administrator
+ end
+
+ [:guest, :developer, :council_member].each do |role|
+ it "with role #{role} should not be administrator" do
+ users(role).should_not be_administrator
+ end
+ end
+
+ it "should be able to become administrator" do
+ # make sure user is not admin before the test
+ @other_user.should_not be_administrator
+ @other_user.role = :admin
+ @other_user.should be_valid
+ @other_user.should be_administrator
end
- it "should not be administrator" do
- @other_user.should_not be_administrator
- end
-
- it "should be able to become administrator" do
- @other_user.role = :admin
- @other_user.should be_valid
- @other_user.should be_administrator
- end
-
- it "should reject invalid role" do
- @other_user.role = :fake_role
- @other_user.should_not be_valid
- end
-
- it "role should be updatable by administrator" do
- @other_user.should be_updatable_by(@admin)
- end
-
- [:council_member, :guest].each do |role|
- it "should not be updatable by a user with role #{role}" do
- @other_user.role = role
- @other_user.should_not be_updatable_by(@other_user)
- end
- end
+ it "should reject invalid role" do
+ @other_user.role = :fake_role
+ @other_user.should_not be_valid
+ end
+
+ it "role should be updatable by administrator" do
+ # make sure old and new roles are different
+ @other_user.role.to_sym.should_not == :guest
+ @other_user.role = :guest
+ @other_user.should be_updatable_by(@admin)
+ end
+
+ [:council_member, :guest].each do |role|
+ it "should not be updatable by a user with role #{role}" do
+ @other_user.should_not be_updatable_by(users(role))
+ end
+ end
end