diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-05-09 13:42:46 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-05-20 17:03:03 +0200 |
commit | 971d1d4a91fdb569f1f0c70bc85f8b613df58521 (patch) | |
tree | eee330030281b7bf4560d2d61d6e6caeb675ab8b | |
parent | Cookie steps (diff) | |
download | council-webapp-971d1d4a91fdb569f1f0c70bc85f8b613df58521.tar.gz council-webapp-971d1d4a91fdb569f1f0c70bc85f8b613df58521.tar.bz2 council-webapp-971d1d4a91fdb569f1f0c70bc85f8b613df58521.zip |
Add irc_nick field to User model
-rw-r--r-- | site/app/models/user.rb | 3 | ||||
-rw-r--r-- | site/db/schema.rb | 3 | ||||
-rw-r--r-- | site/features/irc_nick.feature | 20 | ||||
-rw-r--r-- | site/features/step_definitions/irc_nick_steps.rb | 26 | ||||
-rw-r--r-- | site/features/step_definitions/login_steps.rb | 2 | ||||
-rw-r--r-- | site/features/step_definitions/within_steps.rb | 10 | ||||
-rw-r--r-- | site/features/support/paths.rb | 3 |
7 files changed, 64 insertions, 3 deletions
diff --git a/site/app/models/user.rb b/site/app/models/user.rb index fc9bc9f..20b2c4c 100644 --- a/site/app/models/user.rb +++ b/site/app/models/user.rb @@ -4,6 +4,7 @@ class User < ActiveRecord::Base fields do name :string, :required, :unique + irc_nick :string, :required, :unique email_address :email_address, :login => true administrator :boolean, :default => false timestamps @@ -16,7 +17,7 @@ class User < ActiveRecord::Base state :active, :default => true create :signup, :available_to => "Guest", - :params => [:name, :email_address, :password, :password_confirmation], + :params => [:name, :email_address, :irc_nick, :password, :password_confirmation], :become => :active transition :request_password_reset, { :active => :active }, :new_key => true do diff --git a/site/db/schema.rb b/site/db/schema.rb index e4c4626..d01de42 100644 --- a/site/db/schema.rb +++ b/site/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110510091749) do +ActiveRecord::Schema.define(:version => 20110510092019) do create_table "users", :force => true do |t| t.string "crypted_password", :limit => 40 @@ -24,6 +24,7 @@ ActiveRecord::Schema.define(:version => 20110510091749) do 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/features/irc_nick.feature b/site/features/irc_nick.feature new file mode 100644 index 0000000..cb1d73a --- /dev/null +++ b/site/features/irc_nick.feature @@ -0,0 +1,20 @@ +Feature: IRC nick + In order to make IRC bot integration possible + I want all users to provide their freenode IRC nicks + + Scenario: User registration with nick + When I am on the homepage + And I follow "Signup" + And I signup as example user with IRC nick + Then I should see "Thanks for signing up!" in the notices + + Scenario: Fail user registration without nick + When I am on the signup page + And I signup as example user without IRC nick + Then I should see "Irc nick can't be blank" in the errors + And I should be on the signup page + + Scenario: View your own IRC nick + Given I am logged in as example user + When I follow "Logged in as Example" + Then I should see "example" as the user nick diff --git a/site/features/step_definitions/irc_nick_steps.rb b/site/features/step_definitions/irc_nick_steps.rb new file mode 100644 index 0000000..acaa4f8 --- /dev/null +++ b/site/features/step_definitions/irc_nick_steps.rb @@ -0,0 +1,26 @@ +When /^I fill in example user registration data$/ do + When "I fill in the following:", table(%{ + |user_name|examle| + |user_email_address|example@example.com| + |user_irc_nick|example| + |user_password|Example| + |user_password_confirmation|Example| + }) +end + +When /^I signup as example user without IRC nick$/ do + When 'I fill in example user registration data' + When 'I fill in "user_irc_nick" with ""' + When 'I press "Signup"' +end + +When /^I signup as example user with IRC nick$/ do + When 'I fill in example user registration data' + When 'I press "Signup"' +end + +Given /^I am logged in as example user$/ do + Given 'example user' + When 'I am on the login page' + When 'I login as example user' +end diff --git a/site/features/step_definitions/login_steps.rb b/site/features/step_definitions/login_steps.rb index 52fbcd3..5eaa5cc 100644 --- a/site/features/step_definitions/login_steps.rb +++ b/site/features/step_definitions/login_steps.rb @@ -1,6 +1,6 @@ Given /^example user$/ do user = User.new :name => "Example", :email_address => "example@example.com", - :password => "Example" + :password => "Example", :irc_nick => "example" user.save! end diff --git a/site/features/step_definitions/within_steps.rb b/site/features/step_definitions/within_steps.rb new file mode 100644 index 0000000..76b0ad6 --- /dev/null +++ b/site/features/step_definitions/within_steps.rb @@ -0,0 +1,10 @@ +{ + 'in the notices' => '.flash.notice', + 'in the errors' => '.error-messages', + 'as the user nick' => '.user-irc-nick' +}. +each do |within, selector| + Then /^I should( not)? see "([^"]*)" #{within}$/ do |negation, text| + Then %Q{I should#{negation} see "#{text}" within "#{selector}"} + end +end diff --git a/site/features/support/paths.rb b/site/features/support/paths.rb index 6ea5ce1..90b611b 100644 --- a/site/features/support/paths.rb +++ b/site/features/support/paths.rb @@ -14,6 +14,9 @@ module NavigationHelpers when /the login page/ user_login_path + when /the signup page/ + user_signup_path + # Add more mappings here. # Here is an example that pulls values out of the Regexp: # |