rules_engine_users 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +47 -0
  6. data/VERSION +1 -0
  7. data/init.rb +1 -0
  8. data/lib/rules_engine/controller_user_mail.rb +29 -0
  9. data/lib/rules_engine/controller_users.rb +170 -0
  10. data/lib/rules_engine_users.rb +4 -0
  11. data/rails_generators/USAGE +97 -0
  12. data/rails_generators/manifests/rules_engine_users.rb +79 -0
  13. data/rails_generators/manifests/rules_engine_users.yml +32 -0
  14. data/rails_generators/rules_engine_users_generator.rb +21 -0
  15. data/rails_generators/templates/app/controllers/admin/users_controller.rb +64 -0
  16. data/rails_generators/templates/app/controllers/users_controller.rb +215 -0
  17. data/rails_generators/templates/app/models/user.rb +113 -0
  18. data/rails_generators/templates/app/models/user_mailer.rb +26 -0
  19. data/rails_generators/templates/app/models/user_observer.rb +19 -0
  20. data/rails_generators/templates/app/views/admin/users/_form.html.erb +6 -0
  21. data/rails_generators/templates/app/views/admin/users/edit.html.erb +18 -0
  22. data/rails_generators/templates/app/views/admin/users/index.html.erb +52 -0
  23. data/rails_generators/templates/app/views/admin/users/new.html.erb +17 -0
  24. data/rails_generators/templates/app/views/admin/users/show.html.erb +15 -0
  25. data/rails_generators/templates/app/views/user_mailer/forgot_password.html.erb +11 -0
  26. data/rails_generators/templates/app/views/user_mailer/welcome_message.html.erb +11 -0
  27. data/rails_generators/templates/app/views/users/change_form.html.erb +22 -0
  28. data/rails_generators/templates/app/views/users/details.html.erb +11 -0
  29. data/rails_generators/templates/app/views/users/login_form.html.erb +35 -0
  30. data/rails_generators/templates/app/views/users/pswd_change_form.html.erb +20 -0
  31. data/rails_generators/templates/app/views/users/pswd_forgot_form.html.erb +18 -0
  32. data/rails_generators/templates/app/views/users/pswd_reset_form.html.erb +22 -0
  33. data/rails_generators/templates/app/views/users/welcome_form.html.erb +21 -0
  34. data/rails_generators/templates/db/migrate/20100104014507_create_users.rb +41 -0
  35. data/rails_generators/templates/doc/README.rules_engine_users +122 -0
  36. data/rails_generators/templates/doc/README.rules_engine_users_paths +12 -0
  37. data/rails_generators/templates/features/admin/user/edit.feature +46 -0
  38. data/rails_generators/templates/features/admin/user/index.feature +78 -0
  39. data/rails_generators/templates/features/admin/user/new.feature +26 -0
  40. data/rails_generators/templates/features/admin/user/show.feature +22 -0
  41. data/rails_generators/templates/features/admin/user/step_definitions/edit_steps.rb +3 -0
  42. data/rails_generators/templates/features/admin/user/step_definitions/index_steps.rb +13 -0
  43. data/rails_generators/templates/features/admin/user/step_definitions/show_steps.rb +3 -0
  44. data/rails_generators/templates/features/support/blueprint_users.rb +14 -0
  45. data/rails_generators/templates/features/user/change.feature +37 -0
  46. data/rails_generators/templates/features/user/details.feature +15 -0
  47. data/rails_generators/templates/features/user/login.feature +65 -0
  48. data/rails_generators/templates/features/user/pswd_change.feature +46 -0
  49. data/rails_generators/templates/features/user/pswd_forgot.feature +32 -0
  50. data/rails_generators/templates/features/user/pswd_reset.feature +52 -0
  51. data/rails_generators/templates/features/user/step_definitions/login_steps.rb +46 -0
  52. data/rails_generators/templates/features/user/step_definitions/pswd_reset_steps.rb +15 -0
  53. data/rails_generators/templates/features/user/step_definitions/welcome_steps.rb +15 -0
  54. data/rails_generators/templates/features/user/welcome.feature +52 -0
  55. data/rails_generators/templates/spec/controllers/admin/users_controller_spec.rb +191 -0
  56. data/rails_generators/templates/spec/controllers/users_controller_spec.rb +579 -0
  57. data/rails_generators/templates/spec/models/user_mailer_spec.rb +39 -0
  58. data/rails_generators/templates/spec/models/user_observer_spec.rb +56 -0
  59. data/rails_generators/templates/spec/models/user_spec.rb +253 -0
  60. data/rails_generators/templates/spec/support/rules_engine_macros.rb +16 -0
  61. data/rules_engine_users.gemspec +141 -0
  62. data/spec/railsenv/app/controllers/application_controller.rb +10 -0
  63. data/spec/railsenv/config/boot.rb +110 -0
  64. data/spec/railsenv/config/database.yml +22 -0
  65. data/spec/railsenv/config/environment.rb +41 -0
  66. data/spec/railsenv/config/environments/development.rb +17 -0
  67. data/spec/railsenv/config/environments/production.rb +28 -0
  68. data/spec/railsenv/config/environments/test.rb +28 -0
  69. data/spec/railsenv/config/initializers/backtrace_silencers.rb +7 -0
  70. data/spec/railsenv/config/initializers/inflections.rb +10 -0
  71. data/spec/railsenv/config/initializers/mime_types.rb +5 -0
  72. data/spec/railsenv/config/initializers/new_rails_defaults.rb +19 -0
  73. data/spec/railsenv/config/initializers/session_store.rb +15 -0
  74. data/spec/railsenv/config/locales/en.yml +5 -0
  75. data/spec/railsenv/config/routes.rb +43 -0
  76. data/spec/railsenv/db/test.sqlite3 +1 -0
  77. data/spec/railsenv/log/debug.log +1 -0
  78. data/spec/railsenv/log/test.log +1 -0
  79. data/spec/rcov.opts +3 -0
  80. data/spec/rules_engine/controller_user_mail_spec.rb +43 -0
  81. data/spec/rules_engine/controller_users_spec.rb +337 -0
  82. data/spec/spec.opts +4 -0
  83. data/spec/spec_helper.rb +30 -0
  84. data/tasks/rspec.rake +18 -0
  85. metadata +180 -0
@@ -0,0 +1,21 @@
1
+ <div class="prepend-1 prepend-top span-16">
2
+ <h2>Set Your Password</h2>
3
+ <% re_form_for(:user, :url => user_welcome_path, :html => {:id => "user_welcome"}, :span => "5x11") do |f| %>
4
+ <% re_whitebox do %>
5
+ <%= hidden_field_tag :token, @token%>
6
+
7
+ <%= f.text_field :email, :label => 'Your Email', :size=>40, :required => true%>
8
+ <%= f.password_field :password, :label => 'New Password', :size=>25, :required => true%>
9
+ <%= f.password_field :password_confirmation, :label => 'Confirm New Password', :size=>25, :required => true%>
10
+
11
+ <div class="span-10">
12
+ <%= link_to("Login", user_login_path) %>
13
+ </div>
14
+ <div class="span-5">
15
+ <%= re_button_submit("Set Password", "green", :span => "4") %>
16
+ </div>
17
+ <div class="clear"></div>
18
+ <% end %>
19
+ <% end %>
20
+ </div>
21
+ <div class="clear"></div>
@@ -0,0 +1,41 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+
4
+ # USERS
5
+ create_table :users do |t|
6
+ t.column :full_name, :string
7
+ t.column :email, :string
8
+ t.column :login, :string
9
+ t.column :time_zone, :string
10
+ t.column :crypted_password, :string, :limit => 40
11
+ t.column :salt, :string, :limit => 40
12
+ t.column :created_at, :datetime
13
+ t.column :updated_at, :datetime
14
+ t.column :remember_token, :string
15
+ t.column :remember_token_expires_at, :datetime
16
+ t.column :reset_token, :string
17
+ t.column :reset_token_expires_at, :datetime
18
+ t.column :access_level, :int
19
+ end
20
+
21
+ add_index :users, :full_name
22
+ add_index :users, :email
23
+ add_index :users, :login
24
+
25
+ ######### THIS SHOULD BE IN THE seeds.rb file
26
+ ActionMailer::Base.perform_deliveries = false
27
+
28
+ User.create (:full_name => 'Admin User',
29
+ :email => 'admin@test.com',
30
+ :login => 'admin',
31
+ :time_zone => "Pacific Time (US & Canada)",
32
+ :password => 'nopassword',
33
+ :password_confirmation => 'nopassword',
34
+ :access_level => User::ACCESS_LEVEL_ADMIN )
35
+
36
+ end
37
+
38
+ def self.down
39
+ drop_table :users
40
+ end
41
+ end
@@ -0,0 +1,122 @@
1
+ ## Ruby and Rails Rules Engine Framework
2
+ # More detailed documentation at http://www.r3ef.com
3
+
4
+ ## Installation Guide
5
+ ######################################
6
+ # 1. Install the Gem
7
+ sudo gem install rules_engine
8
+ sudo gem install rules_engine_users
9
+ sudo gem install will_paginate
10
+
11
+ ######################################
12
+ # 2. Add to the existing Rails App
13
+ ./script/generate rules_engine_users
14
+
15
+ ######################################
16
+ # 3. Setup the Rails Environments
17
+ - ./config/environment.rb
18
+
19
+ Rails::Initializer.run do |config|
20
+ ...
21
+ config.gem 'rules_engine'
22
+ config.gem 'rules_engine_users'
23
+ config.gem 'will_paginate'
24
+ ...
25
+ config.active_record.observers = :user_observer
26
+ ...
27
+ end
28
+
29
+ ActionController::Base.define_access_level(:rules_engine_editor, 10)
30
+ ActionController::Base.define_access_level(:rules_engine_reader, 5)
31
+ # ActionController::Base.define_access_level(:more_access, 7)
32
+ # ActionController::Base.define_access_level(:less_access, 3)
33
+
34
+ - ./config/environments/production.rb
35
+ - ./config/environments/development.rb
36
+
37
+ config.action_mailer.delivery_method = :smtp
38
+ config.action_mailer.smtp_settings = {
39
+ :address => "XXX",
40
+ :port => 25,
41
+ :user_name => "XXX",
42
+ :password => "XXX",
43
+ :domain => "XXX",
44
+ :authentication => :login
45
+ }
46
+ RulesEngine::ControllerUserMail.host = 'domain.com'
47
+ RulesEngine::ControllerUserMail.from = 'domain.com'
48
+ RulesEngine::ControllerUserMail.prefix = 'My Cool App'
49
+
50
+ - ./config/environments/test.rb
51
+ - ./config/environments/cucumber.rb
52
+
53
+ config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.0'
54
+ config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0'
55
+ config.gem 'webrat', :lib => false, :version => '>=0.7.0'
56
+
57
+ config.gem "rspec", :version => '>=1.3.0', :lib => false
58
+ config.gem "rspec-rails", :version => '>=1.3.2', :lib => false
59
+ config.gem "faker", :version => '>=0.3.1', :lib => false
60
+
61
+ config.gem "machinist", :version => '>=1.0.6', :lib => false
62
+ config.gem 'rcov', :version => '>=0.9.8', :lib => false
63
+ config.gem 'remarkable_rails', :version => '>=3.1.13', :lib => false
64
+
65
+ require 'machinist/active_record'
66
+ require 'sham'
67
+ require 'faker'
68
+ require 'remarkable_rails'
69
+
70
+ ######################################
71
+ # 4. Add the Routes
72
+ - ./config/routes.rb
73
+
74
+ ActionController::Routing::Routes.draw do |map|
75
+ ...
76
+ # map.root :controller => 're_pipelines', :action => 'template'
77
+
78
+ map.with_options :controller => 'users', :path_prefix => '/user', :name_prefix => 'user_' do |user|
79
+ user.login '/', :action => 'login_form', :conditions => { :method => :get }
80
+ user.login '/', :action => 'login', :conditions => { :method => :post }
81
+ user.logout '/logout', :action => 'logout'
82
+ user.pswd_forgot '/pswd_forgot', :action => 'pswd_forgot_form', :conditions => { :method => :get }
83
+ user.pswd_forgot '/pswd_forgot', :action => 'pswd_forgot', :conditions => { :method => :post }
84
+ user.pswd_change '/pswd_change', :action => 'pswd_change_form', :conditions => { :method => :get }
85
+ user.pswd_change '/pswd_change', :action => 'pswd_change', :conditions => { :method => :post }
86
+ user.details '/details', :action => 'details', :conditions => { :method => :get }
87
+ user.change '/change', :action => 'change_form', :conditions => { :method => :get }
88
+ user.change '/change', :action => 'change', :conditions => { :method => :put }
89
+ user.pswd_reset '/pswd_reset', :action => 'pswd_reset_form', :conditions => { :method => :get }
90
+ user.pswd_reset '/pswd_reset', :action => 'pswd_reset', :conditions => { :method => :post }
91
+ user.welcome '/welcome', :action => 'welcome_form', :conditions => { :method => :get }
92
+ user.welcome '/welcome', :action => 'welcome', :conditions => { :method => :post }
93
+ end
94
+
95
+ map.namespace :admin do |admin|
96
+ admin.resources :users, :controller => 'users'
97
+ end
98
+ ...
99
+ end
100
+
101
+
102
+ ######################################
103
+ # 5. Install the Required Gems
104
+ rake gems:install
105
+ rake gems:install RAILS_ENV=test
106
+
107
+ ######################################
108
+ # 6. Migrate the Database
109
+ rake db:migrate
110
+ rake db:migrate RAILS_ENV=test
111
+
112
+ ######################################
113
+ # 7. Run the Tests
114
+ rake spec
115
+ rake spec:rcov
116
+ rake cucumber
117
+ open coverage/index.html
118
+
119
+ ######################################
120
+ # 8. Start the Server
121
+ ./script/server
122
+ open http://localhost:3000/re_pipelines
@@ -0,0 +1,12 @@
1
+ <h1>User Pages</h1>
2
+ <ul>
3
+ <li><a href='/user/'> Login </a></li>
4
+ <li><a href='/user/logout'> Logout </a></li>
5
+ <li><a href='/user/user_details'> Your Details </a></li>
6
+ <li><a href='/user/pswd_forgot'> Password Forgot </a></li>
7
+ <li><a href='/user/pswd_change'> Password Change </a></li>
8
+ <li><a href='/user/pswd_reset'> Password Reset (Check logs for reset token) </a></li>
9
+ <li><a href='/user/welcome'> User Welcome (Check logs for reset token) </a></li>
10
+
11
+ <li><a href='/admin/users'> Admin Users </a></li>
12
+ </ul>
@@ -0,0 +1,46 @@
1
+ Feature: change the user's details
2
+ As an logged in administrator
3
+ I want to change any user's details
4
+
5
+ Background:
6
+ Given I am logged in as an administrator
7
+ Given there is a "user"
8
+ Given I visit the edit admin user page
9
+
10
+ Scenario: Visit the edit user page
11
+ Then I should see the view "admin/users/edit"
12
+ Then the "Full Name" field should be required
13
+ Then the "Full Name" field should be "user" "full_name"
14
+ Then the "Login Name" field should be required
15
+ Then the "Login Name" field should be "user" "login"
16
+ Then the "Email" field should be required
17
+ Then the "Email" field should be "user" "email"
18
+ Then the "Time Zone" field should be required
19
+ Then the "Time Zone" field should be "user" "time_zone"
20
+ Then the "Access Level" field should be required
21
+ # Then the "Access Level" field should be "Account Disabled"
22
+ Then the "Access Level" field should be "0"
23
+ Then I should see the "Cancel" link to the admin user page
24
+ Then I should see the "Delete" link to the admin user page
25
+ Then I should see the "Update" button
26
+
27
+ Scenario: I enter invalid details
28
+ Given I fill in "Full Name" with ""
29
+ When I press "Update"
30
+ Then I should see the view "admin/users/edit"
31
+ Then the form error message should be "Unable to Update User"
32
+ Then the "Full Name" field should be an error
33
+
34
+ Scenario: I enter valid details
35
+ Given I fill in "Full Name" with "New Name"
36
+ When I press "Update"
37
+ Then I should see the view "admin/users/show"
38
+ Then the success message should be "User Updated"
39
+ Then I should see "New Name"
40
+
41
+ And I visit the edit admin user page
42
+
43
+ Scenario: I delete the user
44
+ When I follow "Delete"
45
+ Then I should see the view "admin/users/index"
46
+ Then the success message should be "User Deleted"
@@ -0,0 +1,78 @@
1
+ Feature: see all of the user
2
+ As an logged in administrator
3
+ I want see or find all of the users
4
+
5
+ Background:
6
+ Given I am logged in as an administrator
7
+ Given I have the following users
8
+ | full_name | login | email |
9
+ | A One | a_one | a_one@test.com |
10
+ | B Two | b_two | b_two@test.com |
11
+ | C Three | c_three | c_three@test.com |
12
+
13
+ Scenario: List all of the users
14
+ When I am on the admin users page
15
+ Then I should see the view "admin/users/index"
16
+ Then I should see the breadcrumb "Home Page" link to the root page
17
+ Then I should see the breadcrumb "List Users" link to the admin users page
18
+ Then I should see the breadcrumb "+ Create New User" link to the new admin user page
19
+ Then I should see the "Search" button
20
+ Then should see "a_one@test.com" within "table.data"
21
+ Then should see "b_two@test.com" within "table.data"
22
+ Then should see "c_three@test.com" within "table.data"
23
+
24
+ Scenario: Search by Name
25
+ Given I am on the admin users page
26
+ Given I fill in "query" with "B"
27
+ Given I select "Search Name" from "query_type"
28
+ When I press "Search"
29
+ Then I should see the view "admin/users/index"
30
+ Then the "query" field should be "B"
31
+ Then the "query_type" select field should be "Search Name"
32
+ Then should not see "a_one@test.com" within "table.data"
33
+ Then should see "b_two@test.com" within "table.data"
34
+ Then should see "c_three@test.com" within "table.data"
35
+
36
+ Scenario: Search by Login
37
+ Given I am on the admin users page
38
+ Given I fill in "query" with "b"
39
+ Given I select "Search Login" from "query_type"
40
+ When I press "Search"
41
+ Then I should see the view "admin/users/index"
42
+ Then the "query" field should be "b"
43
+ Then the "query_type" select field should be "Search Login"
44
+ Then should not see "a_one@test.com" within "table.data"
45
+ Then should see "b_two@test.com" within "table.data"
46
+ Then should see "c_three@test.com" within "table.data"
47
+
48
+ Scenario: Search by Email
49
+ Given I am on the admin users page
50
+ Given I fill in "query" with "b"
51
+ Given I select "Search Email" from "query_type"
52
+ When I press "Search"
53
+ Then I should see the view "admin/users/index"
54
+ Then the "query" field should be "b"
55
+ Then the "query_type" select field should be "Search Email"
56
+ Then should not see "a_one@test.com" within "table.data"
57
+ Then should see "b_two@test.com" within "table.data"
58
+ Then should see "c_three@test.com" within "table.data"
59
+
60
+ Scenario: See the user details
61
+ Given there are no "users"
62
+ Given I am logged in as an administrator
63
+ Given there is a "user"
64
+ When I am on the admin users page
65
+ Then I should see the "user" "login" value
66
+ Then I should see the "user" "full_name" value
67
+ Then I should see the "user" "email" value
68
+ Then I should see the "user" "time_zone" value
69
+ # Then I should see the "user" "access_level" value
70
+ Then I should see "Account Disabled"
71
+
72
+ Scenario: Link to the user details
73
+ Given there is a "user"
74
+ When I am on the admin users page
75
+ Then I should see the user login name link to the user page
76
+ Then I should see the user full name link to the user page
77
+
78
+
@@ -0,0 +1,26 @@
1
+ Feature: see all of the user
2
+ As an logged in administrator
3
+ I want create a new user
4
+
5
+ Background:
6
+ Given I am logged in as an administrator
7
+
8
+ Scenario: View the new user form
9
+ When I am on the new admin user page
10
+ Then I should see the view "admin/users/new"
11
+ Then I should see the breadcrumb "Home Page" link to the root page
12
+ Then I should see the breadcrumb "List Users" link to the admin users page
13
+ Then I should see the breadcrumb title "New User"
14
+ Then the "Full Name" field should be required
15
+ Then the "Full Name" field should be blank
16
+ Then the "Login Name" field should be required
17
+ Then the "Login Name" field should be blank
18
+ Then the "Email" field should be required
19
+ Then the "Email" field should be blank
20
+ Then the "Time Zone" field should be required
21
+ Then the "Time Zone" select field should be "(GMT-05:00) Eastern Time (US & Canada)"
22
+ Then the "Access Level" field should be required
23
+ Then the "Access Level" select field should be "Account Disabled"
24
+ Then I should see the "Cancel" link to the admin users page
25
+ Then I should see the "Create" button
26
+
@@ -0,0 +1,22 @@
1
+ Feature: see the user details
2
+ As an logged in administrator
3
+ I want see the user
4
+
5
+ Background:
6
+ Given I am logged in as an administrator
7
+ Given there is a "user"
8
+
9
+ Scenario: View the user details
10
+ When I visit the admin user page
11
+ Then I should see the view "admin/users/show"
12
+ Then I should see the breadcrumb "Home Page" link to the root page
13
+ Then I should see the breadcrumb "List Users" link to the admin users page
14
+ Then I should see the breadcrumb title "User Details"
15
+ Then I should see the "user" "full_name" value
16
+ Then I should see the "user" "login" value
17
+ Then I should see the "user" "email" value
18
+ Then I should see the "user" "time_zone" value
19
+ # Then I should see the "user" "access_level" value
20
+ Then I should see "Account Disabled"
21
+ Then I should see the "Edit" link to the edit admin user page
22
+
@@ -0,0 +1,3 @@
1
+ When /^I visit the edit admin user page$/ do
2
+ visit edit_admin_user_path(@user)
3
+ end
@@ -0,0 +1,13 @@
1
+ Given /^I have the following users$/ do |table|
2
+ table.hashes.each do |item|
3
+ User.make(item)
4
+ end
5
+ end
6
+
7
+ Then /^I should see the user login name link to the user page$/ do
8
+ response.should have_tag("a[href=#{admin_user_path(@user)}]", :text => @user.login)
9
+ end
10
+
11
+ Then /^I should see the user full name link to the user page$/ do
12
+ response.should have_tag("a[href=#{admin_user_path(@user)}]", :text => @user.full_name)
13
+ end
@@ -0,0 +1,3 @@
1
+ When /^I visit the admin user page$/ do
2
+ visit admin_user_path(@user)
3
+ end
@@ -0,0 +1,14 @@
1
+ # USER
2
+ User.blueprint do
3
+ email { Faker::Internet.email }
4
+ login { Faker::Name.name.gsub(/[^a-z0-9]+/i, '_') }
5
+ full_name { Faker::Name.name }
6
+ password { 's3creT' }
7
+ password_confirmation { password }
8
+ access_level { User::ACCESS_LEVEL_DISABLED }
9
+ time_zone { "Eastern Time (US & Canada)" }
10
+ end
11
+
12
+ User.blueprint(:administrator) do
13
+ access_level { User::ACCESS_LEVEL_ADMIN }
14
+ end
@@ -0,0 +1,37 @@
1
+ Feature: change the current user's details
2
+ As an logged in user
3
+ I want to change my details
4
+
5
+ Background:
6
+ Given I am logged in as a user
7
+
8
+ Scenario: Visit change my details
9
+ When I am on the user change page
10
+ Then I should see the view "users/change_form"
11
+ Then the "Full Name" field should be required
12
+ Then the "Full Name" field should be "login" "full_name"
13
+ Then the "Login Name" field should be required
14
+ Then the "Login Name" field should be "login" "login"
15
+ Then the "Email" field should be required
16
+ Then the "Email" field should be "login" "email"
17
+ Then the "Time Zone" field should be required
18
+ Then the "Time Zone" field should be "login" "time_zone"
19
+ Then I should see the "Change Your Password" link to the user pswd change page
20
+ Then I should see the "Cancel" link to the user details page
21
+ Then I should see the "Update" button
22
+
23
+ Scenario: I enter invalid details
24
+ Given I am on the user change page
25
+ Given I fill in "Full Name" with ""
26
+ When I press "Update"
27
+ Then I should see the view "users/change_form"
28
+ Then the form error message should be "Unable to Change User Details"
29
+ Then the "Full Name" field should be an error
30
+
31
+ Scenario: I enter valid details
32
+ Given I am on the user change page
33
+ Given I fill in "Full Name" with "New Name"
34
+ When I press "Update"
35
+ Then I should see the view "users/details"
36
+ Then the success message should be "User Details Changed"
37
+ Then I should see "New Name"
@@ -0,0 +1,15 @@
1
+ Feature: see the current user's details
2
+ As an logged in user
3
+ I want to confirm my details
4
+
5
+ Background:
6
+ Given I am logged in as a user
7
+
8
+ Scenario: Visit user details page
9
+ When I am on the user details page
10
+ Then I should see the view "users/details"
11
+ Then I should see the "login" "full_name" value
12
+ Then I should see the "login" "login" value
13
+ Then I should see the "login" "email" value
14
+ Then I should see the "login" "time_zone" value
15
+ Then I should see the "Update Your Details" link to the user change page
@@ -0,0 +1,65 @@
1
+ Feature: login a user
2
+ As an unlogged in guest
3
+ I want to login to my account
4
+
5
+ Background:
6
+ Given I am not logged in
7
+
8
+ Scenario: Visit login
9
+ When I am on the user login page
10
+ Then I should see the view "users/login_form"
11
+ Then the "Email or Login Name" field should be required
12
+ Then the "Email or Login Name" field should be blank
13
+ Then the "Password" field should be required
14
+ Then the "Password" field should be blank
15
+ Then the "Remember Me" field should be blank
16
+ Then I should see the "Forgot Password?" link to the user pswd forgot page
17
+ Then I should see the "Login" button
18
+
19
+ Scenario: Login with the correct details
20
+ Given there is a user with email "bill@smith.com" and password "smitty"
21
+ Given I am on the user login page
22
+ Given I fill in "Email or Login Name" with "bill@smith.com"
23
+ Given I fill in "Password" with "smitty"
24
+ When I press "Login"
25
+ Then I should be on the root page
26
+ Then I should be logged in
27
+
28
+ Scenario: Login with the wrong details
29
+ Given there is a user with email "bill@smith.com" and password "smitty"
30
+ Given I am on the user login page
31
+ Given I fill in "Email or Login Name" with "bill@smith.com"
32
+ Given I fill in "Password" with "wrong"
33
+ When I press "Login"
34
+ Then I should be on the user login page
35
+ Then I should not be logged in
36
+
37
+ Scenario: Login as a disabled user
38
+ Given there is a disabled user with email "bill@smith.com" and password "smitty"
39
+ Given I am on the user login page
40
+ Given I fill in "Email or Login Name" with "bill@smith.com"
41
+ Given I fill in "Password" with "smitty"
42
+ When I press "Login"
43
+ Then I should be on the home page
44
+ Then the error message should not be blank
45
+ Then I should not be logged in
46
+
47
+ Scenario: Login with remember me set
48
+ Given there is a user with email "bill@smith.com" and password "smitty"
49
+ Given I am on the user login page
50
+ Given I fill in "Email or Login Name" with "bill@smith.com"
51
+ Given I fill in "Password" with "smitty"
52
+ Given I check "Remember Me"
53
+ When I press "Login"
54
+ Then I should be logged in
55
+ Then the remember me token should be set
56
+
57
+ Scenario: remember me previously set
58
+ Given there is a user with email "bill@smith.com" and password "smitty"
59
+ Given I am on the user login page
60
+ Given I fill in "Email or Login Name" with "bill@smith.com"
61
+ Given I fill in "Password" with "smitty"
62
+ Given I check "Remember Me"
63
+ Given I press "Login"
64
+ When I go to the user logout page
65
+ Then the remember me token should be set
@@ -0,0 +1,46 @@
1
+ Feature: change the current user's password
2
+ As an logged in user
3
+ I want to change my password
4
+
5
+ Background:
6
+ Given I am logged in as a user
7
+
8
+ Scenario: Visit change my password
9
+ When I am on the user pswd change page
10
+ Then I should see the view "users/pswd_change_form"
11
+ Then the "Old Password" field should be required
12
+ Then the "Old Password" field should be blank
13
+ Then the "New Password" field should be required
14
+ Then the "New Password" field should be blank
15
+ Then the "Confirm New Password" field should be required
16
+ Then the "Confirm New Password" field should be blank
17
+ Then I should see the "Change Your Details" link to the user change page
18
+ Then I should see the "Cancel" link to the user details page
19
+ Then I should see the "Update" button
20
+
21
+ Scenario: I enter invalid old password
22
+ Given I am on the user pswd change page
23
+ Given I fill in "Old Password" with "wrong"
24
+ Given I fill in "New Password" with "new_password"
25
+ Given I fill in "Confirm New Password" with "new_password"
26
+ When I press "Update"
27
+ Then I should see the view "users/pswd_change_form"
28
+ Then the error message should be "Invalid Old Password"
29
+
30
+ Scenario: I enter a wrong confirm new password
31
+ Given I am on the user pswd change page
32
+ Given I fill in "Old Password" with "mock_password"
33
+ Given I fill in "New Password" with "new_password"
34
+ Given I fill in "Confirm New Password" with "new_password_wrong"
35
+ When I press "Update"
36
+ Then I should see the view "users/pswd_change_form"
37
+ Then the error message should be "Could not change password"
38
+
39
+ Scenario: I enter a a new password
40
+ Given I am on the user pswd change page
41
+ Given I fill in "Old Password" with "mock_password"
42
+ Given I fill in "New Password" with "new_password"
43
+ Given I fill in "Confirm New Password" with "new_password"
44
+ When I press "Update"
45
+ Then I should see the view "users/details"
46
+ Then the success message should be "Password Changed"
@@ -0,0 +1,32 @@
1
+ Feature: reset my password
2
+ As an unlogged in user
3
+ I want to reset my password
4
+
5
+ Background:
6
+ Given I am not logged in
7
+
8
+ Scenario: Visit user pswd forgot
9
+ When I am on the user pswd forgot page
10
+ Then I should see the view "users/pswd_forgot_form"
11
+ Then the "Your Email" field should be required
12
+ Then the "Your Email" field should be blank
13
+ Then I should see the "Login" link to the user login page
14
+ Then I should see the "Reset Password" button
15
+
16
+ Scenario: Enter an invalid email
17
+ Given there are no "users" with "email" set to "bill@smith.com"
18
+ Given I am on the user pswd forgot page
19
+ Given I fill in "Your Email" with "bill@smith.com"
20
+ When I press "Reset Password"
21
+ Then I should be on the user pswd forgot page
22
+ Then the error message should be "Could not reset password"
23
+
24
+ Scenario: Enter a valid email
25
+ Given there is a "user" with "email" set to "bill@smith.com"
26
+ Given I am on the user pswd forgot page
27
+ Given I fill in "Your Email" with "bill@smith.com"
28
+ When I press "Reset Password"
29
+ Then I should be on the user login page
30
+ Then the success message should be "An email has been sent with the password reset details."
31
+ Then warning "Test the outbound email is correct"
32
+ # http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/