mori 0.1.0 → 0.1.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.
@@ -38,20 +38,20 @@ describe 'Inviting Users', :type => :feature do
38
38
  visit '/invites/asd234fdsasd234'
39
39
  page.current_path.should eq root_path
40
40
  end
41
- it 'should redirect to the invites path if validation fails' do
42
- visit "/invites/#{@user.invitation_token}"
43
- User.should_receive(:accept_invitation).exactly(1).times.and_call_original
44
- within(:css, '.edit_user') do
45
- fill_in 'Password', :with => 'passwoasdfasdfasdasdf'
46
- fill_in 'Password confirmation', :with => 'password123'
41
+ it 'should reject old tokens' do
42
+ Timecop.freeze(Date.today + 3.weeks) do
43
+ visit "/invites/#{@user.invitation_token}"
44
+ within(:css, '.edit_user') do
45
+ fill_in 'Password', :with => 'password123'
46
+ fill_in 'Password confirmation', :with => 'password123'
47
+ end
48
+ click_button 'Accept'
49
+ page.current_path.should eq "/invites/#{@user.invitation_token}"
50
+ page.has_content?(I18n.t('flashes.invalid_invitation_token'))
47
51
  end
48
- click_button 'Accept'
49
- page.current_path.should eq "/invites/#{@user.invitation_token}"
50
- page.has_content?(I18n.t('flashes.passwords_dont_match')).should eq true
51
52
  end
52
53
  it 'should accept the invite and log the new user in' do
53
54
  visit "/invites/#{@user.invitation_token}"
54
- User.should_receive(:accept_invitation).exactly(1).times.and_call_original
55
55
  within(:css, '.edit_user') do
56
56
  fill_in 'Password', :with => 'password123'
57
57
  fill_in 'Password confirmation', :with => 'password123'
@@ -59,6 +59,8 @@ describe 'Inviting Users', :type => :feature do
59
59
  click_button 'Accept'
60
60
  page.current_path.should eq Mori.configuration.dashboard_path
61
61
  page.has_content?(I18n.t('flashes.logged_in')).should be true
62
+ ::BCrypt::Password.new(@user.reload.password).should eq 'password123'
63
+ @user.confirmed.should eq true
62
64
  end
63
65
  end
64
66
  end
@@ -24,7 +24,7 @@ describe 'Password Management', :type => :feature do
24
24
  page.has_content?('Reset My Password').should be true
25
25
  end
26
26
  it 'should change a users password when they go to the link from the email' do
27
- Mori.configuration.user_model.forgot_password(@user.email)
27
+ @user.forgot_password
28
28
  user = Mori.configuration.user_model.find_by_email(@user.email)
29
29
  visit "/passwords/reset?token=#{user.password_reset_token}"
30
30
  within '.edit_user' do
@@ -36,7 +36,7 @@ describe 'Password Management', :type => :feature do
36
36
  end
37
37
  it 'should render the reset form again if the change failed' do
38
38
  Timecop.freeze(Date.today - 3.weeks) do
39
- Mori.configuration.user_model.forgot_password(@user.email)
39
+ @user.forgot_password
40
40
  end
41
41
  user = Mori.configuration.user_model.find_by_email(@user.email)
42
42
  visit "/passwords/reset?token=#{user.password_reset_token}"
@@ -45,7 +45,11 @@ describe 'Password Management', :type => :feature do
45
45
  fill_in 'user_password_confirmation', :with => 'password123'
46
46
  end
47
47
  click_button 'Update Password'
48
- page.has_content?('Expired Reset Token').should be true
48
+ page.has_content?(I18n.t('flashes.invalid_password_reset_token')).should be true
49
+ end
50
+ it 'should redirect if no token' do
51
+ visit '/passwords/reset'
52
+ page.current_path.should eq root_path
49
53
  end
50
54
  it 'should redirect if no user is found' do
51
55
  visit '/passwords/reset?token=123asdf123'
@@ -95,7 +99,7 @@ describe 'Password Management', :type => :feature do
95
99
  fill_in 'new_password_confirmation', :with => 'potatwo'
96
100
  end
97
101
  click_button 'Change Password'
98
- page.has_content?(I18n.t('flashes.passwords_did_not_match')).should be true
102
+ page.has_content?(I18n.t('flashes.password_change_failed')).should be true
99
103
  end
100
104
  end
101
105
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  describe MoriHelper do
3
3
  it 'should return the logout link' do
4
- logout_link.should eq link_to('Log Out', '/logout', :method => :delete)
4
+ mori_logout_link.should eq link_to('Log Out', '/logout', :method => :delete)
5
5
  end
6
6
  end
@@ -81,19 +81,9 @@ describe User do
81
81
  @user = User.find_by_email(email)
82
82
  end
83
83
  it 'should set their password' do
84
- User.accept_invitation(@user.invitation_token, password, password)
84
+ @user.accept_invitation(password)
85
85
  @user.reload.password.should_not eq password
86
86
  end
87
- it 'should not be able to use a stale token' do
88
- Timecop.freeze(Date.today + 3.weeks) do
89
- valid, message = User.accept_invitation(
90
- @user.invitation_token,
91
- password,
92
- password)
93
- valid.should eq false
94
- message.should eq 'Expired Invitation Token'
95
- end
96
- end
97
87
  end
98
88
  end
99
89
 
@@ -103,26 +93,16 @@ describe User do
103
93
  describe 'Resetting their password' do
104
94
  before(:each) do
105
95
  @user = create(:mori_minimal_user)
106
- User.forgot_password(@user.email)
107
- @user = User.find_by_email('email@example.com')
96
+ @user.forgot_password
97
+ @user = User.find_by_email(@user.email)
108
98
  end
109
99
  it 'should be able to reset password' do
110
100
  @user.password_reset_token.should_not be nil
111
101
  @user.password_reset_sent.should eq Date.today
112
102
  end
113
- it 'should require a valid reset token' do
114
- expect { User.reset_password('token123', password) }.to raise_error
115
- token = @user.password_reset_token
116
- User.reset_password(token, password, password)
117
- ::BCrypt::Password.new(@user.reload.password).should eq password
118
- end
119
- it 'should not be able to use an old token' do
120
- token = @user.password_reset_token
121
- ::Timecop.freeze(Date.today + 3.weeks) do
122
- valid, message = User.reset_password(token, password, password)
123
- valid.should eq false
124
- message.should eq 'Expired Reset Token'
125
- end
103
+ it 'should change their password' do
104
+ @user.reset_password("password123")
105
+ ::BCrypt::Password.new(@user.reload.password).should eq "password123"
126
106
  end
127
107
  end
128
108
 
@@ -135,19 +115,9 @@ describe User do
135
115
  @user = create(:mori_minimal_user)
136
116
  end
137
117
  it 'should be able to change their password' do
138
- @user.change_password('123456789sdf', password2, password2)
118
+ @user.change_password(password2)
139
119
  ::BCrypt::Password.new(@user.reload.password).should eq password2
140
120
  end
141
- it 'should return false if both new passwords don\'t match' do
142
- valid, message = @user.change_password('123456789sdf', password2, 'potato')
143
- valid.should eq false
144
- message.should eq I18n.t('flashes.passwords_did_not_match')
145
- end
146
- it 'should raise an error if the incorrect password is provided' do
147
- valid, message = @user.change_password(password2, password, password)
148
- valid.should eq false
149
- message.should eq I18n.t('flashes.password_change_failed')
150
- end
151
121
  end
152
122
 
153
123
  #########################################
@@ -158,23 +128,9 @@ describe User do
158
128
  before :each do
159
129
  @user = create(:mori_minimal_user)
160
130
  end
161
- it 'should require a valid token' do
162
- valid, message = User.confirm_email('tokentoken123')
163
- valid.should eq false
164
- message.should eq 'Invalid Confirmation Token'
165
- end
166
- it 'should require the token to be recent' do
167
- token = @user.confirmation_token
168
- ::Timecop.freeze(Date.today + 3.weeks) do
169
- valid, message = User.confirm_email(token)
170
- valid.should eq false
171
- message.should eq 'Expired Confirmation Token'
172
- end
173
- end
174
131
  it 'should set confirmed to true' do
175
- valid, message = User.confirm_email(@user.confirmation_token)
176
- valid.should eq true
177
- message.should eq 'Email Confirmed'
132
+ @user.confirm_email
133
+ @user.reload.confirmed.should eq true
178
134
  end
179
135
  end
180
136
 
@@ -189,7 +145,7 @@ describe User do
189
145
  it 'resetting their password' do
190
146
  user = create(:mori_minimal_user)
191
147
  MoriMailer.should_receive(:forgot_password).and_call_original
192
- User.forgot_password(user.email)
148
+ user.forgot_password
193
149
  end
194
150
  it 'confirming their email' do
195
151
  MoriMailer.should_receive(:confirm_email).and_call_original
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mori
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Miler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-10 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt-ruby
@@ -114,6 +114,7 @@ files:
114
114
  - lib/generators/mori/install/templates/db/migrate/add_mori_to_users.rb
115
115
  - lib/generators/mori/install/templates/db/migrate/create_users.rb
116
116
  - lib/generators/mori/install/templates/mori.rb
117
+ - lib/generators/mori/install/templates/README
117
118
  - lib/generators/mori/install/templates/user.rb
118
119
  - lib/generators/mori/views/USAGE
119
120
  - lib/generators/mori/views/views_generator.rb
@@ -129,8 +130,6 @@ files:
129
130
  - MIT-LICENSE
130
131
  - Rakefile
131
132
  - README.md
132
- - spec/dummy/app/assets/javascripts/application.js
133
- - spec/dummy/app/assets/stylesheets/application.css
134
133
  - spec/dummy/app/controllers/application_controller.rb
135
134
  - spec/dummy/app/helpers/application_helper.rb
136
135
  - spec/dummy/app/models/user.rb
@@ -252,8 +251,6 @@ signing_key:
252
251
  specification_version: 4
253
252
  summary: Mori is a user authentication platform
254
253
  test_files:
255
- - spec/dummy/app/assets/javascripts/application.js
256
- - spec/dummy/app/assets/stylesheets/application.css
257
254
  - spec/dummy/app/controllers/application_controller.rb
258
255
  - spec/dummy/app/helpers/application_helper.rb
259
256
  - spec/dummy/app/models/user.rb
@@ -1,15 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require_tree .
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */