aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-05-11 16:38:36 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-05-20 17:05:05 +0200
commitc6ab87f6b1ad319eb44b603096b552b83c1c2754 (patch)
tree1f2d0dc26c32d36741de9cbffe7b94efc669d221
parentUse hobo_devise to manage users login (diff)
downloadcouncil-webapp-c6ab87f6b1ad319eb44b603096b552b83c1c2754.tar.gz
council-webapp-c6ab87f6b1ad319eb44b603096b552b83c1c2754.tar.bz2
council-webapp-c6ab87f6b1ad319eb44b603096b552b83c1c2754.zip
Add council_member role to User model
-rw-r--r--site/app/models/user.rb9
-rw-r--r--site/db/schema.rb7
-rw-r--r--site/spec/models/user_spec.rb10
3 files changed, 19 insertions, 7 deletions
diff --git a/site/app/models/user.rb b/site/app/models/user.rb
index bf9769b..e49fa77 100644
--- a/site/app/models/user.rb
+++ b/site/app/models/user.rb
@@ -3,10 +3,11 @@ class User < ActiveRecord::Base
hobo_devise_user_model :auth_methods => [:database_authenticable]
fields do
- name :string, :required, :unique
- irc_nick :string, :required, :unique
- email :email_address, :login => true
- administrator :boolean, :default => false
+ name :string, :required, :unique
+ irc_nick :string, :required, :unique
+ email :email_address, :login => true
+ administrator :boolean, :default => false
+ council_member :boolean, :default => false, :null => false
timestamps
end
diff --git a/site/db/schema.rb b/site/db/schema.rb
index bd46dfd..433a0c7 100644
--- a/site/db/schema.rb
+++ b/site/db/schema.rb
@@ -10,21 +10,22 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110510180303) do
+ActiveRecord::Schema.define(:version => 20110520150447) do
create_table "users", :force => true do |t|
- t.string "crypted_password", :limit => 40
t.string "salt", :limit => 40
t.string "remember_token"
t.datetime "remember_token_expires_at"
t.string "name"
+ t.string "crypted_password", :limit => 60
+ t.string "irc_nick"
t.string "email"
t.boolean "administrator", :default => false
+ t.boolean "council_member", :default => false, :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "state", :default => "active"
t.datetime "key_timestamp"
- t.string "irc_nick"
end
add_index "users", ["state"], :name => "index_users_on_state"
diff --git a/site/spec/models/user_spec.rb b/site/spec/models/user_spec.rb
index 05254c8..bdffa30 100644
--- a/site/spec/models/user_spec.rb
+++ b/site/spec/models/user_spec.rb
@@ -4,4 +4,14 @@ describe User do
it "should run spec test with shoulda and models from application" do
Guest.new.should_not be_administrator
end
+
+ it "should set correct roles for new user" do
+ u = User.new :name => 'Example', :email => 'example@example.com',
+ :password => 'Example', :irc_nick => 'example'
+ u.save!
+ u.should_not be_administrator
+ u.should_not be_council_member
+ u.should_not be_guest
+ u.should be_signed_up
+ end
end