From c6ab87f6b1ad319eb44b603096b552b83c1c2754 Mon Sep 17 00:00:00 2001 From: Joachim Filip Ignacy Bartosik Date: Wed, 11 May 2011 16:38:36 +0200 Subject: Add council_member role to User model --- site/app/models/user.rb | 9 +++++---- site/db/schema.rb | 7 ++++--- site/spec/models/user_spec.rb | 10 ++++++++++ 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 -- cgit v1.2.3-65-gdbad