blue_light_special 0.2.0

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 (104) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +67 -0
  3. data/Rakefile +95 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/blue_light_special/impersonations_controller.rb +44 -0
  6. data/app/controllers/blue_light_special/passwords_controller.rb +84 -0
  7. data/app/controllers/blue_light_special/sessions_controller.rb +70 -0
  8. data/app/controllers/blue_light_special/users_controller.rb +48 -0
  9. data/app/models/blue_light_special_mailer.rb +22 -0
  10. data/app/models/deliver_change_password_job.rb +19 -0
  11. data/app/models/deliver_welcome_job.rb +17 -0
  12. data/app/models/impersonation.rb +26 -0
  13. data/app/views/blue_light_special_mailer/change_password.html.erb +9 -0
  14. data/app/views/impersonations/index.html.erb +5 -0
  15. data/app/views/passwords/edit.html.erb +23 -0
  16. data/app/views/passwords/new.html.erb +15 -0
  17. data/app/views/sessions/new.html.erb +48 -0
  18. data/app/views/users/_form.html.erb +21 -0
  19. data/app/views/users/edit.html.erb +6 -0
  20. data/app/views/users/new.html.erb +6 -0
  21. data/app/views/users/show.html.erb +8 -0
  22. data/generators/blue_light_special/USAGE +1 -0
  23. data/generators/blue_light_special/blue_light_special_generator.rb +78 -0
  24. data/generators/blue_light_special/lib/insert_commands.rb +33 -0
  25. data/generators/blue_light_special/lib/rake_commands.rb +22 -0
  26. data/generators/blue_light_special/templates/README +20 -0
  27. data/generators/blue_light_special/templates/application.html.erb +50 -0
  28. data/generators/blue_light_special/templates/blue_light_special.rb +21 -0
  29. data/generators/blue_light_special/templates/blue_light_special.yml +42 -0
  30. data/generators/blue_light_special/templates/factories.rb +23 -0
  31. data/generators/blue_light_special/templates/migrations/create_users.rb +24 -0
  32. data/generators/blue_light_special/templates/migrations/update_users.rb +44 -0
  33. data/generators/blue_light_special/templates/style.css +31 -0
  34. data/generators/blue_light_special/templates/user.rb +3 -0
  35. data/generators/blue_light_special/templates/xd_receiver.html +10 -0
  36. data/generators/blue_light_special/templates/xd_receiver_ssl.html +10 -0
  37. data/generators/blue_light_special_admin/USAGE +1 -0
  38. data/generators/blue_light_special_admin/blue_light_special_admin_generator.rb +30 -0
  39. data/generators/blue_light_special_admin/lib/insert_commands.rb +33 -0
  40. data/generators/blue_light_special_admin/templates/README +16 -0
  41. data/generators/blue_light_special_admin/templates/app/controllers/admin/admin_controller.rb +14 -0
  42. data/generators/blue_light_special_admin/templates/app/controllers/admin/users_controller.rb +52 -0
  43. data/generators/blue_light_special_admin/templates/app/views/admin/users/_form.html.erb +25 -0
  44. data/generators/blue_light_special_admin/templates/app/views/admin/users/edit.html.erb +6 -0
  45. data/generators/blue_light_special_admin/templates/app/views/admin/users/index.html.erb +7 -0
  46. data/generators/blue_light_special_admin/templates/app/views/admin/users/new.html.erb +6 -0
  47. data/generators/blue_light_special_admin/templates/app/views/admin/users/show.html.erb +10 -0
  48. data/generators/blue_light_special_admin/templates/test/integration/admin/users_test.rb +201 -0
  49. data/generators/blue_light_special_tests/USAGE +1 -0
  50. data/generators/blue_light_special_tests/blue_light_special_tests_generator.rb +21 -0
  51. data/generators/blue_light_special_tests/templates/README +58 -0
  52. data/generators/blue_light_special_tests/templates/test/integration/edit_profile_test.rb +35 -0
  53. data/generators/blue_light_special_tests/templates/test/integration/facebook_test.rb +61 -0
  54. data/generators/blue_light_special_tests/templates/test/integration/impersonation_test.rb +39 -0
  55. data/generators/blue_light_special_tests/templates/test/integration/password_reset_test.rb +128 -0
  56. data/generators/blue_light_special_tests/templates/test/integration/sign_in_test.rb +66 -0
  57. data/generators/blue_light_special_tests/templates/test/integration/sign_out_test.rb +28 -0
  58. data/generators/blue_light_special_tests/templates/test/integration/sign_up_test.rb +47 -0
  59. data/lib/blue_light_special.rb +7 -0
  60. data/lib/blue_light_special/authentication.rb +138 -0
  61. data/lib/blue_light_special/configuration.rb +32 -0
  62. data/lib/blue_light_special/extensions/errors.rb +6 -0
  63. data/lib/blue_light_special/extensions/rescue.rb +5 -0
  64. data/lib/blue_light_special/routes.rb +55 -0
  65. data/lib/blue_light_special/user.rb +241 -0
  66. data/rails/init.rb +4 -0
  67. data/shoulda_macros/blue_light_special.rb +244 -0
  68. data/test/controllers/passwords_controller_test.rb +184 -0
  69. data/test/controllers/sessions_controller_test.rb +129 -0
  70. data/test/controllers/users_controller_test.rb +57 -0
  71. data/test/models/blue_light_special_mailer_test.rb +52 -0
  72. data/test/models/impersonation_test.rb +25 -0
  73. data/test/models/user_test.rb +213 -0
  74. data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
  75. data/test/rails_root/app/controllers/application_controller.rb +6 -0
  76. data/test/rails_root/app/helpers/application_helper.rb +5 -0
  77. data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
  78. data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
  79. data/test/rails_root/app/models/user.rb +3 -0
  80. data/test/rails_root/config/boot.rb +110 -0
  81. data/test/rails_root/config/environment.rb +22 -0
  82. data/test/rails_root/config/environments/development.rb +19 -0
  83. data/test/rails_root/config/environments/production.rb +1 -0
  84. data/test/rails_root/config/environments/test.rb +37 -0
  85. data/test/rails_root/config/initializers/blue_light_special.rb +4 -0
  86. data/test/rails_root/config/initializers/inflections.rb +10 -0
  87. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  88. data/test/rails_root/config/initializers/requires.rb +13 -0
  89. data/test/rails_root/config/initializers/time_formats.rb +4 -0
  90. data/test/rails_root/config/routes.rb +9 -0
  91. data/test/rails_root/db/migrate/20100305173127_blue_light_special_create_users.rb +21 -0
  92. data/test/rails_root/db/migrate/20100305173129_create_delayed_jobs.rb +20 -0
  93. data/test/rails_root/public/dispatch.rb +10 -0
  94. data/test/rails_root/script/create_project.rb +52 -0
  95. data/test/rails_root/test/factories/user.rb +13 -0
  96. data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
  97. data/test/rails_root/test/integration/facebook_test.rb +49 -0
  98. data/test/rails_root/test/integration/impersonation_test.rb +38 -0
  99. data/test/rails_root/test/integration/password_reset_test.rb +127 -0
  100. data/test/rails_root/test/integration/sign_in_test.rb +72 -0
  101. data/test/rails_root/test/integration/sign_out_test.rb +28 -0
  102. data/test/rails_root/test/integration/sign_up_test.rb +84 -0
  103. data/test/test_helper.rb +21 -0
  104. metadata +219 -0
@@ -0,0 +1,72 @@
1
+ require 'test_helper'
2
+
3
+ class SignInTest < ActionController::IntegrationTest
4
+
5
+ context 'Signing in as a User' do
6
+
7
+ context 'who is not in the system' do
8
+
9
+ should 'see a failure message' do
10
+ sign_in_as('someone@somewhere.com', 'password')
11
+ assert_match(/Bad email or password/, response.body)
12
+ end
13
+
14
+ should 'not be signed in' do
15
+ sign_in_as "someone@somewhere.com", 'password'
16
+ assert !controller.signed_in?
17
+ end
18
+
19
+ end
20
+
21
+ context 'when confirmed' do
22
+
23
+ setup do
24
+ @user = Factory(:user, :email => "bob@bob.bob", :password => "password")
25
+ end
26
+
27
+ should 'be signed in' do
28
+ sign_in_as 'bob@bob.bob', 'password'
29
+ assert controller.signed_in?
30
+ end
31
+
32
+ should 'see "Signed In"' do
33
+ sign_in_as 'bob@bob.bob', 'password'
34
+ assert_match %r{Signed in}, @response.body
35
+ end
36
+
37
+ should 'be signed in on subsequent requests' do
38
+ sign_in_as 'bob@bob.bob', 'password'
39
+ reset_session
40
+ visit root_url
41
+ assert controller.signed_in?
42
+ end
43
+
44
+ should 'redirect back to tender' do
45
+ sign_in_as 'bob@bob.bob', 'password', sign_in_url(:to => 'http://help.twongo.com')
46
+ assert_response :redirect
47
+ assert_match(%r{\Ahttp://help.twongo.com/\?sso=}, response['Location'])
48
+ end
49
+
50
+ end
51
+
52
+ context 'when confirmed but with bad credentials' do
53
+
54
+ setup do
55
+ @user = Factory(:user, :email => 'bob@bob.bob', :password => 'password')
56
+ end
57
+
58
+ should 'not be signed in' do
59
+ sign_in_as 'bob@bob.bob', 'badpassword'
60
+ assert !controller.signed_in?
61
+ end
62
+
63
+ should 'see "Bad email or password"' do
64
+ sign_in_as 'bob@bob.bob', 'badpassword'
65
+ assert_match /Bad email or password/, response.body
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class SignOutTest < ActionController::IntegrationTest
4
+
5
+ context 'Signing out as a user' do
6
+
7
+ should 'see "Signed out"' do
8
+ sign_up(:email => 'bob@bob.bob')
9
+ sign_out
10
+ assert_match(/Signed out/, response.body)
11
+ end
12
+
13
+ should 'be signed out' do
14
+ sign_up(:email => 'bob@bob.bob')
15
+ sign_out
16
+ assert !controller.signed_in?
17
+ end
18
+
19
+ should 'be signed out when I return' do
20
+ sign_up(:email => 'bob@bob.bob')
21
+ sign_out
22
+ visit root_url
23
+ assert !controller.signed_in?
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,84 @@
1
+ require 'test_helper'
2
+
3
+ class SignUpTest < ActionController::IntegrationTest
4
+
5
+ context 'Signing up as a new user' do
6
+
7
+ setup do
8
+ ActionMailer::Base.deliveries.clear
9
+ end
10
+
11
+ teardown do
12
+ ActionMailer::Base.deliveries.clear
13
+ end
14
+
15
+ context 'with invalid data' do
16
+
17
+ should 'show error messages' do
18
+ sign_up(:email => 'invalidemail', :password_confirmation => '')
19
+ assert_match /Email is invalid/, response.body
20
+ assert_match /Password doesn't match confirmation/, response.body
21
+ end
22
+
23
+ end
24
+
25
+ context 'with valid data' do
26
+
27
+ should 'sign in the user' do
28
+ sign_up(:email => 'bob@bob.bob', :password => 'password', :password_confirmation => 'password')
29
+ assert controller.signed_in?
30
+ end
31
+
32
+ should 'see "Thanks for signing up with Twongo!"' do
33
+ sign_up(:email => 'bob@bob.bob', :password => 'password', :password_confirmation => 'password')
34
+ assert_match /Thanks for signing up with Twongo!/, response.body
35
+ end
36
+
37
+ should 'send a welcome email' do
38
+ sign_up(:email => 'bob@bob.bob', :password => 'password', :password_confirmation => 'password')
39
+ user = User.find_by_email('bob@bob.bob')
40
+ Delayed::Job.work_off
41
+ sent = ActionMailer::Base.deliveries.last
42
+ assert_equal user.email, sent.recipients
43
+ assert_match /welcome/i, sent.subject
44
+ end
45
+
46
+ end
47
+
48
+ context 'with an email for an existing deleted user' do
49
+
50
+ setup do
51
+ @user = Factory(:user, :email => 'deleted@example.com')
52
+ @user.destroy
53
+ end
54
+
55
+ should 'undelete the existing user' do
56
+ sign_up(:email => 'deleted@example.com')
57
+ @user.reload
58
+ assert !@user.destroyed?
59
+ end
60
+
61
+ should 'sign in the user' do
62
+ sign_up(:email => 'deleted@example.com', :password => 'password', :password_confirmation => 'password')
63
+ assert controller.signed_in?
64
+ end
65
+
66
+ should 'see "Thanks for signing up with Twongo!"' do
67
+ sign_up(:email => 'deleted@example.com', :password => 'password', :password_confirmation => 'password')
68
+ assert_match /Thanks for signing up with Twongo!/, response.body
69
+ end
70
+
71
+ should 'send a welcome email' do
72
+ sign_up(:email => 'deleted@example.com', :password => 'password', :password_confirmation => 'password')
73
+ user = User.find_by_email('deleted@example.com')
74
+ Delayed::Job.work_off
75
+ sent = ActionMailer::Base.deliveries.last
76
+ assert_equal user.email, sent.recipients
77
+ assert_match /welcome/i, sent.subject
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
84
+ end
@@ -0,0 +1,21 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) +
3
+ "/rails_root/config/environment")
4
+ require 'test_help'
5
+
6
+ $: << File.expand_path(File.dirname(__FILE__) + '/..')
7
+ require 'blue_light_special'
8
+
9
+ begin
10
+ require 'redgreen'
11
+ rescue LoadError
12
+ end
13
+
14
+ require File.join(File.dirname(__FILE__), '..', 'shoulda_macros', 'blue_light_special')
15
+
16
+ class ActiveSupport::TestCase
17
+ self.use_transactional_fixtures = true
18
+ self.use_instantiated_fixtures = false
19
+ end
20
+
21
+ FakeWeb.allow_net_connect = false
metadata ADDED
@@ -0,0 +1,219 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blue_light_special
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Nathaniel Bibler
13
+ - Mark Kendall
14
+ - Caike Souza
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-03-19 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: mini_fb
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ - 2
32
+ - 2
33
+ version: 0.2.2
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: delayed_job
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 8
46
+ - 4
47
+ version: 1.8.4
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: mad_mimi_mailer
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ - 0
60
+ - 7
61
+ version: 0.0.7
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: shoulda
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
76
+ description: Rails authentication by email and password with integrated dependencies to MadMimi. Also provides administrative user impersonation.
77
+ email: nate@envylabs.com
78
+ executables: []
79
+
80
+ extensions: []
81
+
82
+ extra_rdoc_files:
83
+ - LICENSE
84
+ - README.rdoc
85
+ files:
86
+ - LICENSE
87
+ - README.rdoc
88
+ - Rakefile
89
+ - VERSION
90
+ - app/controllers/blue_light_special/impersonations_controller.rb
91
+ - app/controllers/blue_light_special/passwords_controller.rb
92
+ - app/controllers/blue_light_special/sessions_controller.rb
93
+ - app/controllers/blue_light_special/users_controller.rb
94
+ - app/models/blue_light_special_mailer.rb
95
+ - app/models/deliver_change_password_job.rb
96
+ - app/models/deliver_welcome_job.rb
97
+ - app/models/impersonation.rb
98
+ - app/views/blue_light_special_mailer/change_password.html.erb
99
+ - app/views/impersonations/index.html.erb
100
+ - app/views/passwords/edit.html.erb
101
+ - app/views/passwords/new.html.erb
102
+ - app/views/sessions/new.html.erb
103
+ - app/views/users/_form.html.erb
104
+ - app/views/users/edit.html.erb
105
+ - app/views/users/new.html.erb
106
+ - app/views/users/show.html.erb
107
+ - generators/blue_light_special/USAGE
108
+ - generators/blue_light_special/blue_light_special_generator.rb
109
+ - generators/blue_light_special/lib/insert_commands.rb
110
+ - generators/blue_light_special/lib/rake_commands.rb
111
+ - generators/blue_light_special/templates/README
112
+ - generators/blue_light_special/templates/application.html.erb
113
+ - generators/blue_light_special/templates/blue_light_special.rb
114
+ - generators/blue_light_special/templates/blue_light_special.yml
115
+ - generators/blue_light_special/templates/factories.rb
116
+ - generators/blue_light_special/templates/migrations/create_users.rb
117
+ - generators/blue_light_special/templates/migrations/update_users.rb
118
+ - generators/blue_light_special/templates/style.css
119
+ - generators/blue_light_special/templates/user.rb
120
+ - generators/blue_light_special/templates/xd_receiver.html
121
+ - generators/blue_light_special/templates/xd_receiver_ssl.html
122
+ - generators/blue_light_special_admin/USAGE
123
+ - generators/blue_light_special_admin/blue_light_special_admin_generator.rb
124
+ - generators/blue_light_special_admin/lib/insert_commands.rb
125
+ - generators/blue_light_special_admin/templates/README
126
+ - generators/blue_light_special_admin/templates/app/controllers/admin/admin_controller.rb
127
+ - generators/blue_light_special_admin/templates/app/controllers/admin/users_controller.rb
128
+ - generators/blue_light_special_admin/templates/app/views/admin/users/_form.html.erb
129
+ - generators/blue_light_special_admin/templates/app/views/admin/users/edit.html.erb
130
+ - generators/blue_light_special_admin/templates/app/views/admin/users/index.html.erb
131
+ - generators/blue_light_special_admin/templates/app/views/admin/users/new.html.erb
132
+ - generators/blue_light_special_admin/templates/app/views/admin/users/show.html.erb
133
+ - generators/blue_light_special_admin/templates/test/integration/admin/users_test.rb
134
+ - generators/blue_light_special_tests/USAGE
135
+ - generators/blue_light_special_tests/blue_light_special_tests_generator.rb
136
+ - generators/blue_light_special_tests/templates/README
137
+ - generators/blue_light_special_tests/templates/test/integration/edit_profile_test.rb
138
+ - generators/blue_light_special_tests/templates/test/integration/facebook_test.rb
139
+ - generators/blue_light_special_tests/templates/test/integration/impersonation_test.rb
140
+ - generators/blue_light_special_tests/templates/test/integration/password_reset_test.rb
141
+ - generators/blue_light_special_tests/templates/test/integration/sign_in_test.rb
142
+ - generators/blue_light_special_tests/templates/test/integration/sign_out_test.rb
143
+ - generators/blue_light_special_tests/templates/test/integration/sign_up_test.rb
144
+ - lib/blue_light_special.rb
145
+ - lib/blue_light_special/authentication.rb
146
+ - lib/blue_light_special/configuration.rb
147
+ - lib/blue_light_special/extensions/errors.rb
148
+ - lib/blue_light_special/extensions/rescue.rb
149
+ - lib/blue_light_special/routes.rb
150
+ - lib/blue_light_special/user.rb
151
+ - rails/init.rb
152
+ - shoulda_macros/blue_light_special.rb
153
+ has_rdoc: true
154
+ homepage: http://github.com/envylabs/blue_light_special
155
+ licenses: []
156
+
157
+ post_install_message:
158
+ rdoc_options:
159
+ - --charset=UTF-8
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ segments:
174
+ - 0
175
+ version: "0"
176
+ requirements: []
177
+
178
+ rubyforge_project:
179
+ rubygems_version: 1.3.6
180
+ signing_key:
181
+ specification_version: 3
182
+ summary: Rails authentication by email and password
183
+ test_files:
184
+ - test/controllers/passwords_controller_test.rb
185
+ - test/controllers/sessions_controller_test.rb
186
+ - test/controllers/users_controller_test.rb
187
+ - test/models/blue_light_special_mailer_test.rb
188
+ - test/models/impersonation_test.rb
189
+ - test/models/user_test.rb
190
+ - test/rails_root/app/controllers/accounts_controller.rb
191
+ - test/rails_root/app/controllers/application_controller.rb
192
+ - test/rails_root/app/helpers/application_helper.rb
193
+ - test/rails_root/app/helpers/confirmations_helper.rb
194
+ - test/rails_root/app/helpers/passwords_helper.rb
195
+ - test/rails_root/app/models/user.rb
196
+ - test/rails_root/config/boot.rb
197
+ - test/rails_root/config/environment.rb
198
+ - test/rails_root/config/environments/development.rb
199
+ - test/rails_root/config/environments/production.rb
200
+ - test/rails_root/config/environments/test.rb
201
+ - test/rails_root/config/initializers/blue_light_special.rb
202
+ - test/rails_root/config/initializers/inflections.rb
203
+ - test/rails_root/config/initializers/mime_types.rb
204
+ - test/rails_root/config/initializers/requires.rb
205
+ - test/rails_root/config/initializers/time_formats.rb
206
+ - test/rails_root/config/routes.rb
207
+ - test/rails_root/db/migrate/20100305173127_blue_light_special_create_users.rb
208
+ - test/rails_root/db/migrate/20100305173129_create_delayed_jobs.rb
209
+ - test/rails_root/public/dispatch.rb
210
+ - test/rails_root/script/create_project.rb
211
+ - test/rails_root/test/factories/user.rb
212
+ - test/rails_root/test/functional/accounts_controller_test.rb
213
+ - test/rails_root/test/integration/facebook_test.rb
214
+ - test/rails_root/test/integration/impersonation_test.rb
215
+ - test/rails_root/test/integration/password_reset_test.rb
216
+ - test/rails_root/test/integration/sign_in_test.rb
217
+ - test/rails_root/test/integration/sign_out_test.rb
218
+ - test/rails_root/test/integration/sign_up_test.rb
219
+ - test/test_helper.rb