public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/council-webapp:master commit in: site/db/, site/features/support/, site/features/, site/app/models/, ...
@ 2011-05-24  9:41 Petteri Räty
  0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-05-24  9:41 UTC (permalink / raw
  To: gentoo-commits

commit:     971d1d4a91fdb569f1f0c70bc85f8b613df58521
Author:     Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Mon May  9 11:42:46 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri May 20 15:03:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=971d1d4a

Add irc_nick field to User model

---
 site/app/models/user.rb                          |    3 +-
 site/db/schema.rb                                |    3 +-
 site/features/irc_nick.feature                   |   20 ++++++++++++++++
 site/features/step_definitions/irc_nick_steps.rb |   26 ++++++++++++++++++++++
 site/features/step_definitions/login_steps.rb    |    2 +-
 site/features/step_definitions/within_steps.rb   |   10 ++++++++
 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:
     #



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-24  9:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-24  9:41 [gentoo-commits] proj/council-webapp:master commit in: site/db/, site/features/support/, site/features/, site/app/models/, Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox