citygate 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/README.rdoc +11 -0
  2. data/app/assets/javascripts/citygate/admin_users.coffee +1 -1
  3. data/app/assets/javascripts/citygate/jquery.pjax.js +4 -2
  4. data/app/assets/javascripts/citygate.js +16 -0
  5. data/app/assets/stylesheets/citygate/{application.css.scss → application.css} +0 -0
  6. data/app/assets/stylesheets/citygate/main.sass +0 -9
  7. data/app/controllers/citygate/admin/application_controller.rb +3 -1
  8. data/app/controllers/citygate/admin/users_controller.rb +4 -4
  9. data/app/controllers/citygate/application_controller.rb +4 -2
  10. data/app/controllers/citygate/users/omniauth_callbacks_controller.rb +13 -12
  11. data/app/models/citygate/permission.rb +7 -0
  12. data/app/models/citygate/role.rb +2 -1
  13. data/app/models/citygate/user.rb +24 -4
  14. data/app/views/citygate/admin/users/index.html.erb +3 -3
  15. data/app/views/citygate/admin/users/show.html.erb +12 -3
  16. data/app/views/citygate/home/index.html.erb +4 -5
  17. data/app/views/citygate/shared/_navigation.html.erb +18 -18
  18. data/app/views/citygate/users/show.html.erb +6 -4
  19. data/app/views/devise/confirmations/new.html.erb +12 -0
  20. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  21. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  22. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  23. data/app/views/devise/passwords/edit.html.erb +16 -0
  24. data/app/views/devise/passwords/new.html.erb +12 -0
  25. data/app/views/devise/registrations/edit.html.erb +33 -30
  26. data/app/views/devise/registrations/new.html.erb +10 -10
  27. data/app/views/devise/sessions/new.html.erb +18 -0
  28. data/app/views/devise/{_links.erb → shared/_links.erb} +7 -7
  29. data/app/views/devise/unlocks/new.html.erb +12 -0
  30. data/app/views/layouts/admin/application.html.erb +2 -2
  31. data/config/accounts.yml +1 -3
  32. data/config/initializers/devise.rb +1 -1
  33. data/config/locales/defaults/en.yml +2 -0
  34. data/config/locales/models/user/en.yml +4 -0
  35. data/config/locales/navigation/en.yml +12 -0
  36. data/config/locales/shared/cancan/en.yml +3 -0
  37. data/config/locales/{devise.en.yml → shared/devise/devise.en.yml} +0 -0
  38. data/config/locales/{devise_invitable.en.yml → shared/devise/devise_invitable.en.yml} +0 -0
  39. data/config/locales/views/admin/users/en.yml +32 -0
  40. data/db/migrate/20120303195103_add_name_to_users.rb +2 -1
  41. data/db/migrate/20120727143920_create_permissions_table.rb +12 -0
  42. data/db/seeds.rb +14 -0
  43. data/lib/ability.rb +53 -0
  44. data/lib/citygate/engine.rb +10 -0
  45. data/lib/citygate/version.rb +1 -1
  46. data/spec/dummy/README.rdoc +261 -0
  47. data/spec/dummy/Rakefile +30 -0
  48. data/{app/assets/javascripts/citygate → spec/dummy/app/assets/javascripts}/application.js +2 -3
  49. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  50. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  51. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  53. data/spec/dummy/config/application.rb +61 -0
  54. data/spec/dummy/config/boot.rb +10 -0
  55. data/spec/dummy/config/database.yml +25 -0
  56. data/spec/dummy/config/environment.rb +5 -0
  57. data/spec/dummy/config/environments/development.rb +39 -0
  58. data/spec/dummy/config/environments/production.rb +67 -0
  59. data/spec/dummy/config/environments/test.rb +39 -0
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/spec/dummy/config/initializers/inflections.rb +15 -0
  62. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  63. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  64. data/spec/dummy/config/initializers/session_store.rb +8 -0
  65. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/{config → spec/dummy/config}/locales/en.yml +0 -0
  67. data/spec/dummy/config/routes.rb +3 -0
  68. data/spec/dummy/config.ru +4 -0
  69. data/spec/dummy/db/development.sqlite3 +0 -0
  70. data/spec/dummy/db/migrate/20120706095546_devise_create_users.citygate.rb +50 -0
  71. data/spec/dummy/db/migrate/20120706095547_add_name_to_users.citygate.rb +7 -0
  72. data/spec/dummy/db/migrate/20120706095548_add_confirmable_to_users.citygate.rb +12 -0
  73. data/spec/dummy/db/migrate/20120706095549_devise_invitable_add_to_users.citygate.rb +24 -0
  74. data/spec/dummy/db/migrate/20120706095550_add_omniauth_to_devise.citygate.rb +20 -0
  75. data/spec/dummy/db/migrate/20120706095551_create_roles.citygate.rb +11 -0
  76. data/spec/dummy/db/migrate/20120727145840_create_permissions_table.citygate.rb +13 -0
  77. data/spec/dummy/db/production.sqlite3 +0 -0
  78. data/spec/dummy/db/schema.rb +79 -0
  79. data/spec/dummy/db/seeds.rb +1 -0
  80. data/spec/dummy/db/test.sqlite3 +0 -0
  81. data/spec/dummy/features/step_definitions/email_steps.rb +206 -0
  82. data/spec/dummy/features/step_definitions/user_steps.rb +249 -0
  83. data/spec/dummy/features/support/email_spec.rb +1 -0
  84. data/spec/dummy/features/support/env.rb +107 -0
  85. data/spec/dummy/features/support/hooks.rb +0 -0
  86. data/spec/dummy/features/support/paths.rb +46 -0
  87. data/spec/dummy/features/users/login_omniauth.feature +19 -0
  88. data/spec/dummy/features/users/sign_in.feature +40 -0
  89. data/spec/dummy/features/users/sign_out.feature +11 -0
  90. data/spec/dummy/features/users/sign_up.feature +27 -0
  91. data/spec/dummy/features/users/user_edit.feature +9 -0
  92. data/spec/dummy/features/users/users_admin.feature +44 -0
  93. data/spec/dummy/log/development.log +18417 -0
  94. data/spec/dummy/log/test.log +59087 -0
  95. data/spec/dummy/public/404.html +26 -0
  96. data/spec/dummy/public/422.html +26 -0
  97. data/spec/dummy/public/500.html +25 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/dummy/script/rails +6 -0
  100. data/spec/dummy/spec/controllers/admin/admin_controller_spec.rb +10 -0
  101. data/spec/dummy/spec/controllers/admin/users_spec.rb +15 -0
  102. data/spec/dummy/spec/controllers/home_controller_spec.rb +12 -0
  103. data/spec/dummy/spec/controllers/omniauth_spec.rb +73 -0
  104. data/spec/dummy/spec/factories.rb +33 -0
  105. data/spec/dummy/spec/javascripts/UserSpec.js +14 -0
  106. data/spec/dummy/spec/javascripts/fixtures/user_listing.html +20 -0
  107. data/spec/dummy/spec/javascripts/helpers/SpecHelper.js +9 -0
  108. data/spec/dummy/spec/javascripts/helpers/jasmine-jquery.js +306 -0
  109. data/spec/dummy/spec/javascripts/helpers/jquery.min.js +4 -0
  110. data/spec/dummy/spec/javascripts/support/jasmine.yml +19 -0
  111. data/spec/dummy/spec/models/user_spec.rb +100 -0
  112. data/spec/dummy/spec/routing/routing_spec.rb +22 -0
  113. data/spec/dummy/spec/spec_helper.rb +79 -0
  114. data/spec/dummy/spec/support/devise.rb +3 -0
  115. data/spec/dummy/tmp/cache/assets/C63/E40/sprockets%2F36a675f52eb281488964b58be8971051 +0 -0
  116. data/spec/dummy/tmp/cache/assets/C79/FC0/sprockets%2F76c2f8ffd1175afd6274640057134300 +0 -0
  117. data/spec/dummy/tmp/cache/assets/C7A/CE0/sprockets%2F9124c83a02e7332a90b2883b69f81d04 +0 -0
  118. data/spec/dummy/tmp/cache/assets/C89/540/sprockets%2F606a455261f8f047c994c4b9a582f126 +0 -0
  119. data/spec/dummy/tmp/cache/assets/CC5/020/sprockets%2Ffa39f3f719158fea829829617391b42c +0 -0
  120. data/spec/dummy/tmp/cache/assets/CD6/2B0/sprockets%2F08e01b4122e606428c6de7234d87bee1 +0 -0
  121. data/spec/dummy/tmp/cache/assets/CD8/070/sprockets%2F3afc9406d6d06c238a33603363af8a66 +0 -0
  122. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  123. data/spec/dummy/tmp/cache/assets/CE2/7D0/sprockets%2Fe69b8c4ca0800c940d1d9785f1a92327 +0 -0
  124. data/spec/dummy/tmp/cache/assets/CE8/510/sprockets%2F0d85ab6e3972f70636a990e91fec8301 +0 -0
  125. data/spec/dummy/tmp/cache/assets/CF6/500/sprockets%2Fe48376f3339fc2f84ac25d713936ea99 +0 -0
  126. data/spec/dummy/tmp/cache/assets/D0D/DE0/sprockets%2Fa35442f02b0b2479f22d83d639d8c4fd +0 -0
  127. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  128. data/spec/dummy/tmp/cache/assets/D3E/710/sprockets%2F93251497334cafddb54ecc36a332f5b9 +0 -0
  129. data/spec/dummy/tmp/cache/assets/D48/410/sprockets%2Fa18aa9c28f587c76e162489eb19f2a2a +0 -0
  130. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  131. data/spec/dummy/tmp/cache/assets/D53/840/sprockets%2Ff753499d8cefbb5a8450ca97540ff275 +0 -0
  132. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  133. data/spec/dummy/tmp/cache/assets/D72/580/sprockets%2F02aed4ae7c633d6d577280de93c4c7c6 +0 -0
  134. data/spec/dummy/tmp/cache/assets/D73/010/sprockets%2F834fa37dfa7f28148e125baf3f9d91b0 +0 -0
  135. data/spec/dummy/tmp/cache/assets/D75/530/sprockets%2F6a480d7952fbe8ce5c2eaad0369f7271 +0 -0
  136. data/spec/dummy/tmp/cache/assets/D78/BD0/sprockets%2Fd0c9ac69560ea197444b7f759ecd06da +0 -0
  137. data/spec/dummy/tmp/cache/assets/D9B/0B0/sprockets%2F609a6d0b06eb3752679f6e1f0adcb4fc +0 -0
  138. data/spec/dummy/tmp/cache/assets/D9E/F10/sprockets%2F9ab223df888d724dcad09eb1163cc5f4 +0 -0
  139. data/spec/dummy/tmp/cache/assets/D9E/F70/sprockets%2Fc5d4a6e7d907804c52cbf910339dafdb +0 -0
  140. data/spec/dummy/tmp/cache/assets/DB9/2A0/sprockets%2F0a7332e4e1420de7165bd13ecffca4cc +0 -0
  141. data/spec/dummy/tmp/cache/assets/DC2/210/sprockets%2Ff0049a44fff3a6ea3a55283aceb06fb4 +0 -0
  142. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  143. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  144. data/spec/dummy/tmp/cache/assets/E0B/AF0/sprockets%2Ff71f3afdedf8ab892f147a5facc07488 +0 -0
  145. data/spec/dummy/tmp/cache/assets/E2B/670/sprockets%2Feac21904ecb266ce92aecadb8681b7fe +0 -0
  146. data/spec/spec_helper.rb +33 -0
  147. metadata +267 -41
  148. data/app/models/citygate/ability.rb +0 -31
@@ -0,0 +1,249 @@
1
+ ### UTILITY METHODS ###
2
+
3
+ def current_path
4
+ URI.parse(current_url).path
5
+ end
6
+
7
+ def create_visitor
8
+ @visitor ||= { :first_name => "User", :email => "example@example.com",
9
+ :password => "bigpasswordisbig", :password_confirmation => "bigpasswordisbig" }
10
+ end
11
+
12
+ def find_user
13
+ @user ||= Citygate::User.first conditions: {:email => @visitor[:email]}
14
+ end
15
+
16
+ def create_unconfirmed_user
17
+ create_visitor
18
+ delete_user
19
+ sign_up
20
+ end
21
+
22
+ def create_or_get_user
23
+ @user ||= lambda do
24
+ create_visitor
25
+ delete_user
26
+ Factory.create(:user, email: @visitor[:email])
27
+ end.call
28
+ @user.confirmation_sent_at = Time.now
29
+ @user.save
30
+ return @user
31
+ end
32
+
33
+ def delete_user
34
+ @user ||= Citygate::User.first conditions: {:email => @visitor[:email]}
35
+ @user.destroy unless @user.nil?
36
+ end
37
+
38
+ def sign_up
39
+ delete_user
40
+ visit '/users/sign_up'
41
+ fill_in "user_email", :with => @visitor[:email]
42
+ fill_in "user_password", :with => @visitor[:password]
43
+ fill_in "user_password_confirmation", :with => @visitor[:password_confirmation]
44
+ click_button "Sign up"
45
+ find_user
46
+ end
47
+
48
+ def sign_in
49
+ visit '/users/sign_in'
50
+ fill_in "Email", :with => @visitor[:email]
51
+ fill_in "Password", :with => @visitor[:password]
52
+ click_button "Sign in"
53
+ end
54
+
55
+ ### GIVEN ###
56
+ Given /^I am not logged in$/ do
57
+ page.should_not have_link('Log out')
58
+ end
59
+
60
+ Given /^I am logged in$/ do
61
+ create_or_get_user
62
+ sign_in
63
+ end
64
+
65
+ Given /^I am an admin$/ do
66
+ create_or_get_user
67
+ @user.role_id = 2
68
+ @user.save
69
+ end
70
+
71
+ Given /^I exist as a user$/ do
72
+ create_or_get_user
73
+ end
74
+
75
+ Given /^I do not exist as a user$/ do
76
+ create_visitor
77
+ delete_user
78
+ end
79
+
80
+ Given /^I exist as an unconfirmed user$/ do
81
+ create_unconfirmed_user
82
+ end
83
+
84
+ Given /^I am on (.*)$/ do |path|
85
+ visit path_to(path)
86
+ end
87
+
88
+ Given /^I do not have an? (.*)$/ do |attribute|
89
+ create_or_get_user
90
+ @user[attribute] = nil
91
+ end
92
+
93
+ ### WHEN ###
94
+ When /^I sign in with valid credentials$/ do
95
+ create_visitor
96
+ sign_in
97
+ end
98
+
99
+ When /^I sign out$/ do
100
+ click_link 'Log out'
101
+ end
102
+
103
+ When /^I sign up with valid user data$/ do
104
+ create_visitor
105
+ sign_up
106
+ end
107
+
108
+ When /^I sign up with an invalid email$/ do
109
+ create_visitor
110
+ @visitor = @visitor.merge(:email => "notanemail")
111
+ sign_up
112
+ end
113
+
114
+ When /^I sign up without a password confirmation$/ do
115
+ create_visitor
116
+ @visitor = @visitor.merge(:password_confirmation => "")
117
+ sign_up
118
+ end
119
+
120
+ When /^I sign up without a password$/ do
121
+ create_visitor
122
+ @visitor = @visitor.merge(:password => "")
123
+ sign_up
124
+ end
125
+
126
+ When /^I sign up with a mismatched password confirmation$/ do
127
+ create_visitor
128
+ @visitor = @visitor.merge(:password_confirmation => "please123")
129
+ sign_up
130
+ end
131
+
132
+ When /^I return to the site$/ do
133
+ visit '/'
134
+ end
135
+
136
+ When /^I sign in with a wrong email$/ do
137
+ @visitor = @visitor.merge(:email => "wrong@example.com")
138
+ sign_in
139
+ end
140
+
141
+ When /^I sign in with a wrong password$/ do
142
+ @visitor = @visitor.merge(:password => "wrongpass")
143
+ sign_in
144
+ end
145
+
146
+ When /^I edit my account details$/ do
147
+ click_link "Edit account"
148
+ fill_in "user_current_password", :with => @visitor[:password]
149
+ click_button "Update"
150
+ end
151
+
152
+ When /^I look at the list of users$/ do
153
+ visit '/admin/users'
154
+ end
155
+
156
+ When /^I click (.*)$/ do |link|
157
+ click_link link
158
+ end
159
+
160
+ When /^I go back in history$/ do
161
+ sleep 2
162
+ page.execute_script("history.back()")
163
+ end
164
+
165
+ ### THEN ###
166
+ Then /^I should be signed in$/ do
167
+ page.should have_content "Log out"
168
+ page.should_not have_content "Sign up"
169
+ page.should_not have_content "Log in"
170
+ end
171
+
172
+ Then /^I should be signed in with (.*)$/ do |provider|
173
+ page.should have_content "Successfully authorized from #{provider} account"
174
+ end
175
+
176
+ Then /^I should be signed out$/ do
177
+ page.should have_content "Sign up"
178
+ page.should_not have_content "Log out"
179
+ end
180
+
181
+ Then /^I see an unconfirmed account message$/ do
182
+ page.should have_content "You have to confirm your account before continuing."
183
+ end
184
+
185
+ Then /^I see a successful sign in message$/ do
186
+ page.should have_content "Signed in successfully."
187
+ end
188
+
189
+ Then /^I should see a successful sign up message$/ do
190
+ page.should have_content "A message with a confirmation link has been sent to your email address."
191
+ end
192
+
193
+ Then /^I should see an invalid email message$/ do
194
+ page.should have_content "Email is invalid"
195
+ end
196
+
197
+ Then /^I should see a missing password message$/ do
198
+ page.should have_content "Password can't be blank"
199
+ end
200
+
201
+ Then /^I should see a missing password confirmation message$/ do
202
+ page.should have_content "Password doesn't match confirmation"
203
+ end
204
+
205
+ Then /^I should see a mismatched password message$/ do
206
+ page.should have_content "Password doesn't match confirmation"
207
+ end
208
+
209
+ Then /^I should see a signed out message$/ do
210
+ page.should have_content "Signed out successfully."
211
+ end
212
+
213
+ Then /^I see an invalid login message$/ do
214
+ page.should have_content "Invalid email or password."
215
+ end
216
+
217
+ Then /^I should see an account edited message$/ do
218
+ page.should have_content "You updated your account successfully."
219
+ end
220
+
221
+ Then /^I should (not )?see my (.*)$/ do |nonexistent, attribute|
222
+ create_or_get_user
223
+ if nonexistent
224
+ page.should_not have_content @user[attribute]
225
+ else
226
+ page.should have_content @user[attribute]
227
+ end
228
+ end
229
+
230
+ Then /^I should see the (.*) of user number (.*)$/ do |attribute,id|
231
+ page.should have_content Citygate::User.find(id)[attribute]
232
+ end
233
+
234
+ Then /^the element with (class |id )(.*) should (not )?exist$/ do |type, name, nonexistent|
235
+ selector = %Q{#{(type.strip == 'class') ? '.' : '#'}#{name}}
236
+ if nonexistent
237
+ page.should_not have_css selector
238
+ else
239
+ page.should have_css selector
240
+ end
241
+ end
242
+
243
+ Then /^I can see (.*)$/ do |text|
244
+ has_link?(text).should be_true
245
+ end
246
+
247
+ Then /^I should be redirected to (.*)$/ do |path|
248
+ current_path.should == path_to(path)
249
+ end
@@ -0,0 +1 @@
1
+ require 'email_spec/cucumber'
@@ -0,0 +1,107 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV['RAILS_ENV'] ||= 'test'
8
+
9
+ require 'email_spec'
10
+ require 'email_spec/cucumber'
11
+ require 'cucumber/rails'
12
+ require 'cucumber/rails/rspec'
13
+ require 'cucumber/rails/world'
14
+ require 'capybara-webkit'
15
+
16
+ require 'factory_girl'
17
+ FactoryGirl.find_definitions
18
+
19
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
20
+ # order to ease the transition to Capybara we set the default here. If you'd
21
+ # prefer to use XPath just remove this line and adjust any selectors in your
22
+ # steps to use the XPath syntax.
23
+ Capybara.default_selector = :css
24
+ Capybara.javascript_driver = :webkit
25
+
26
+ if Capybara.current_driver == :webkit
27
+ require 'headless'
28
+
29
+ headless = Headless.new
30
+ headless.start
31
+ end
32
+
33
+ # By default, any exception happening in your Rails application will bubble up
34
+ # to Cucumber so that your scenario will fail. This is a different from how
35
+ # your application behaves in the production environment, where an error page will
36
+ # be rendered instead.
37
+ #
38
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
39
+ # exceptions and display an error page (just like when the app is running in production).
40
+ # Typical scenarios where you want to do this is when you test your error pages.
41
+ # There are two ways to allow Rails to rescue exceptions:
42
+ #
43
+ # 1) Tag your scenario (or feature) with @allow-rescue
44
+ #
45
+ # 2) Set the value below to true. Beware that doing this globally is not
46
+ # recommended as it will mask a lot of errors for you!
47
+ #
48
+ ActionController::Base.allow_rescue = false
49
+
50
+ # Remove/comment out the lines below if your app doesn't have a database.
51
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
52
+ begin
53
+ DatabaseCleaner.strategy = :transaction
54
+ rescue NameError
55
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
56
+ end
57
+
58
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
59
+ # See the DatabaseCleaner documentation for details. Example:
60
+ #
61
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
62
+ # # { :except => [:widgets] } may not do what you expect here
63
+ # # as tCucumber::Rails::Database.javascript_strategy overrides
64
+ # # this setting.
65
+ # DatabaseCleaner.strategy = :truncation
66
+ # end
67
+ #
68
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
69
+ # DatabaseCleaner.strategy = :transaction
70
+ # end
71
+ #
72
+
73
+ # Possible values are :truncation and :transaction
74
+ # The :transaction strategy is faster, but might give you threading problems.
75
+ # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
76
+ Cucumber::Rails::Database.javascript_strategy = :transaction
77
+
78
+ OmniAuth.config.test_mode = true
79
+ OmniAuth.config.mock_auth[:facebook] = {
80
+ "uid" => "10",
81
+ "credentials" => {
82
+ "token" => "1234567890"
83
+ },
84
+ "extra" => {
85
+ "raw_info" => {
86
+ "email" => "zamith@groupbuddies.com",
87
+ "name" => "zamith",
88
+ "link" => "zamith.github.com"
89
+ }
90
+ },
91
+ "info" => {
92
+ "image" => "/path/to/image"
93
+ }
94
+ }
95
+
96
+ OmniAuth.config.mock_auth[:google] = {
97
+ "uid" => "10",
98
+ "credentials" => {
99
+ "token" => "1234567890"
100
+ },
101
+ "info" => {
102
+ "email" => "zamith@groupbuddies.com",
103
+ "name" => "zamith"
104
+ }
105
+ }
106
+
107
+ load "#{Rails.root}/db/seeds.rb"
File without changes
@@ -0,0 +1,46 @@
1
+ module NavigationHelpers
2
+ include Citygate::Engine.routes.url_helpers
3
+ # Maps a name to a path. Used by the
4
+ #
5
+ # When /^I go to (.+)$/ do |page_name|
6
+ #
7
+ # step definition in web_steps.rb
8
+ #
9
+ def path_to(page_name)
10
+ case page_name
11
+
12
+ when /the home\s?page/
13
+ root_path
14
+
15
+ when /the sign up page/
16
+ '/users/sign_up'
17
+
18
+ when /the sign in page/
19
+ '/users/sign_in'
20
+
21
+ when /the users admin page/
22
+ admin_users_path
23
+
24
+ when /the login page/
25
+ root_path
26
+
27
+ # Add more mappings here.
28
+ # Here is an example that pulls values out of the Regexp:
29
+ #
30
+ # when /^(.*)'s profile page$/i
31
+ # user_profile_path(User.find_by_login($1))
32
+
33
+ else
34
+ begin
35
+ page_name =~ /the (.*) page/
36
+ path_components = $1.split(/\s+/)
37
+ self.send(path_components.push('path').join('_').to_sym)
38
+ rescue Object => e
39
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
40
+ "Now, go and add a mapping in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ World(NavigationHelpers)
@@ -0,0 +1,19 @@
1
+ @omniauth
2
+ Feature: Login
3
+ In order to login easily
4
+ As a user of other websites
5
+ I want to be able to login with those credentials
6
+
7
+ @facebook
8
+ Scenario: Login with Facebook
9
+ Given I am on the login page
10
+ Then I can see Sign in with Facebook
11
+ When I click Sign in with Facebook
12
+ Then I should be signed in with Facebook
13
+
14
+ @google
15
+ Scenario: Login with Google
16
+ Given I am on the login page
17
+ Then I can see Sign in with Google
18
+ When I click Sign in with Google
19
+ Then I should be signed in with Google
@@ -0,0 +1,40 @@
1
+ Feature: Sign in
2
+ In order to get access to protected sections of the site
3
+ A user
4
+ Should be able to sign in
5
+
6
+ Scenario: User is not signed up
7
+ Given I do not exist as a user
8
+ When I sign in with valid credentials
9
+ Then I see an invalid login message
10
+ And I should be signed out
11
+
12
+ Scenario: User has not confirmed account
13
+ Given I exist as an unconfirmed user
14
+ And I am not logged in
15
+ When I sign in with valid credentials
16
+ Then I see an unconfirmed account message
17
+ And I should be signed out
18
+ Scenario: User signs in successfully
19
+ Given I exist as a user
20
+ And I am not logged in
21
+ When I sign in with valid credentials
22
+ Then I see a successful sign in message
23
+ When I return to the site
24
+ Then I should be signed in
25
+
26
+ Scenario: User enters wrong email
27
+ Given I exist as a user
28
+ And I am not logged in
29
+ When I sign in with a wrong email
30
+ Then I see an invalid login message
31
+ And I should be signed out
32
+
33
+ Scenario: User enters wrong password
34
+ Given I exist as a user
35
+ And I am not logged in
36
+ When I sign in with a wrong password
37
+ Then I see an invalid login message
38
+ And I should be signed out
39
+
40
+
@@ -0,0 +1,11 @@
1
+ Feature: Sign out
2
+ To protect my account from unauthorized access
3
+ A signed in user
4
+ Should be able to sign out
5
+
6
+ Scenario: User signs out
7
+ Given I am logged in
8
+ When I sign out
9
+ Then I should see a signed out message
10
+ When I return to the site
11
+ Then I should be signed out
@@ -0,0 +1,27 @@
1
+ Feature: Sign up
2
+ In order to get access to protected sections of the site
3
+ As a user
4
+ I want to be able to sign up
5
+
6
+ Background:
7
+ Given I am not logged in
8
+
9
+ Scenario: User signs up with valid data
10
+ When I sign up with valid user data
11
+ Then I should see a successful sign up message
12
+
13
+ Scenario: User signs up with invalid email
14
+ When I sign up with an invalid email
15
+ Then I should see an invalid email message
16
+
17
+ Scenario: User signs up without password
18
+ When I sign up without a password
19
+ Then I should see a missing password message
20
+
21
+ Scenario: User signs up without password confirmation
22
+ When I sign up without a password confirmation
23
+ Then I should see a missing password confirmation message
24
+
25
+ Scenario: User signs up with mismatched password and confirmation
26
+ When I sign up with a mismatched password confirmation
27
+ Then I should see a mismatched password message
@@ -0,0 +1,9 @@
1
+ Feature: Edit User
2
+ As a registered user of the website
3
+ I want to edit my user profile
4
+ so I can change my username
5
+
6
+ Scenario: I sign in and edit my account
7
+ Given I am logged in
8
+ When I edit my account details
9
+ Then I should see an account edited message
@@ -0,0 +1,44 @@
1
+ Feature: Admin Users
2
+ As an administrator on the website
3
+ I want to see registered users listed on the backend so I can manage them
4
+
5
+ Scenario: Going to the administration page
6
+ Given I exist as a user
7
+ And I am logged in
8
+ And I am an admin
9
+ And I am on the home page
10
+ Then I can see Admin
11
+
12
+ Scenario: Viewing users
13
+ Given I exist as a user
14
+ And I am logged in
15
+ And I am an admin
16
+ When I look at the list of users
17
+ Then I should see my name
18
+ And I should see my email
19
+
20
+ Scenario: Viewing users without name
21
+ Given I exist as a user
22
+ And I am logged in
23
+ And I am an admin
24
+ And I do not have a name
25
+ When I look at the list of users
26
+ Then the element with class name should not exist
27
+ And I should see my email
28
+
29
+ Scenario: Viewing users without privileges
30
+ Given I exist as a user
31
+ And I am not logged in
32
+ When I look at the list of users
33
+ Then I should be redirected to the home page
34
+
35
+ @javascript
36
+ Scenario: Click the show user and then click the browser back button should work as expected
37
+ Given I exist as a user
38
+ And I am logged in
39
+ And I am an admin
40
+ When I look at the list of users
41
+ And I click Show
42
+ And I go back in history
43
+ Then I should be redirected to the users admin page
44
+ And I should see the name of user number 1