solidus_auth_devise 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_auth_devise might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3af627c22bba6eef8baec7a7c4295ebfa965f53
4
- data.tar.gz: 08c4f939fe23134adf2b5fae23c8f925351259dc
3
+ metadata.gz: 601953fd74741f135c859fa0a62ff28186f3bf7e
4
+ data.tar.gz: 769599d2154ca0ed69cd3241e9b29e610c6d7b14
5
5
  SHA512:
6
- metadata.gz: 59324791f413c3eb9875cb673f6ff9dd64c836844fcf2bc4c58fb3340a3ce70b37d32755fbecc0f691907d75f8939264246d5c1d98af262a469c51ca3cf14bbe
7
- data.tar.gz: 563da308b471cfa8c22252f30618571fd382d89caaf5cefaa23dd4205b5c80dff211fd791193b5af3b37d15185ced1b90d27a672bfac83fd0896c64c8d2caf10
6
+ metadata.gz: ed4af47908d361784886f3587cb6fcc97c082c71f4ca055ae7aa13cc1b1a04f0adb53caf104563eddf4596f80fc218a0b52657a3fb07c235b0f5d1006b8606ec
7
+ data.tar.gz: 7c84c3019011bdebef14e2d8cebe422f0b5a0e324ccf678b178afc8177aac1a14541a688e65bb1ef2c40df0f3526570d1bb5a558883e86a9a562c5b55e9fc8de
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  spec/dummy
2
+ spec/examples.txt
2
3
  .sass-cache
3
4
  coverage
4
5
  Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Master (unreleased)
2
2
 
3
+ ## Solidus Auth Devise v1.6.2 (2016-11-18)
4
+
5
+ * Fix an issue where invalid addresses could be persisted after starting a
6
+ checkout as a guest and then returning to the cart page.
7
+
3
8
  ## Solidus Auth Devise v1.6.1 (2016-08-24)
4
9
 
5
10
  * Replace usages of `before_filter` with `before_action` (#73)
data/README.md CHANGED
@@ -17,7 +17,7 @@ Then, run `bundle install`.
17
17
  After that's done, you can install and run the necessary migrations, then seed the database:
18
18
 
19
19
  ```shell
20
- bundle exec rake solidus_auth:install:migration
20
+ bundle exec rake solidus_auth:install:migrations
21
21
  bundle exec rake db:migrate
22
22
  bundle exec rake db:seed
23
23
  ```
@@ -4,12 +4,16 @@ Spree::CheckoutController.class_eval do
4
4
  except: [:registration, :update_registration]
5
5
  prepend_before_action :check_authorization
6
6
 
7
+ # This action builds some associations on the order, ex. addresses, which we
8
+ # don't to build or save here.
9
+ skip_before_action :setup_for_current_state, only: [:registration, :update_registration]
10
+
7
11
  def registration
8
12
  @user = Spree::User.new
9
13
  end
10
14
 
11
15
  def update_registration
12
- if params[:order][:email] =~ Devise.email_regexp && current_order.update_attribute(:email, params[:order][:email])
16
+ if params[:order][:email] =~ Devise.email_regexp && current_order.update_attributes(email: params[:order][:email])
13
17
  redirect_to spree.checkout_path
14
18
  else
15
19
  flash[:registration_error] = t(:email_is_invalid, scope: [:errors, :messages])
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = "solidus_auth_devise"
6
- s.version = "1.6.1"
6
+ s.version = "1.6.2"
7
7
  s.summary = "Provides authentication and authorization services for use with Solidus by using Devise and CanCan."
8
8
  s.description = s.summary
9
9
 
@@ -1,21 +1,18 @@
1
1
  RSpec.describe Spree::CheckoutController, type: :controller do
2
2
 
3
- let(:order) { create(:order_with_line_items, email: nil, user: nil) }
3
+ let(:order) { create(:order_with_line_items, email: nil, user: nil, guest_token: token) }
4
4
  let(:user) { build(:user, spree_api_key: 'fake') }
5
5
  let(:token) { 'some_token' }
6
+ let(:cookie_token) { token }
6
7
 
7
8
  before do
9
+ request.cookie_jar.signed[:guest_token] = cookie_token
8
10
  allow(controller).to receive(:current_order) { order }
9
11
  allow(order).to receive(:confirmation_required?) { true }
10
12
  end
11
13
 
12
14
  context '#edit' do
13
15
  context 'when registration step enabled' do
14
- before do
15
- allow(controller).to receive(:check_authorization)
16
- Spree::Auth::Config.set(registration_step: true)
17
- end
18
-
19
16
  context 'when authenticated as registered user' do
20
17
  before { allow(controller).to receive(:spree_current_user) { user } }
21
18
 
@@ -60,7 +57,6 @@ RSpec.describe Spree::CheckoutController, type: :controller do
60
57
  context 'when registration step disabled' do
61
58
  before do
62
59
  Spree::Auth::Config.set(registration_step: false)
63
- allow(controller).to receive(:check_authorization)
64
60
  end
65
61
 
66
62
  context 'when authenticated as registered' do
@@ -119,7 +115,6 @@ RSpec.describe Spree::CheckoutController, type: :controller do
119
115
 
120
116
  context '#registration' do
121
117
  it 'does not check registration' do
122
- allow(controller).to receive(:check_authorization)
123
118
  expect(controller).not_to receive(:check_registration)
124
119
  get :registration
125
120
  end
@@ -132,34 +127,70 @@ RSpec.describe Spree::CheckoutController, type: :controller do
132
127
  end
133
128
 
134
129
  context '#update_registration' do
135
- let(:user) { build(:user) }
130
+ subject { put :update_registration, { order: { email: email } } }
131
+ let(:email) { 'foo@example.com' }
136
132
 
137
133
  it 'does not check registration' do
138
- controller.stub :check_authorization
139
- order.stub update_attributes: true
140
- controller.should_not_receive :check_registration
141
- put :update_registration, { order: { email: 'foo@example.com' } }
142
- end
143
-
144
- it 'renders the registration view if unable to save' do
145
- allow(controller).to receive(:check_authorization)
146
- put :update_registration, { order: { email: 'invalid' } }
147
- expect(flash[:registration_error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages])
148
- expect(response).to render_template :registration
134
+ expect(controller).not_to receive(:check_registration)
135
+ subject
149
136
  end
150
137
 
151
138
  it 'redirects to the checkout_path after saving' do
152
- allow(order).to receive(:update_attributes) { true }
153
- allow(controller).to receive(:check_authorization)
154
- put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
139
+ subject
155
140
  expect(response).to redirect_to spree.checkout_path
156
141
  end
157
142
 
158
- it 'checks if the user is authorized for :edit' do
159
- request.cookie_jar.signed[:guest_token] = token
160
- allow(order).to receive(:update_attributes) { true }
161
- expect(controller).to receive(:authorize!).with(:edit, order, token)
162
- put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
143
+ # Regression test for https://github.com/solidusio/solidus/issues/1588
144
+ context 'order in address state' do
145
+ let(:order) do
146
+ create(
147
+ :order_with_line_items,
148
+ email: nil,
149
+ user: nil,
150
+ guest_token: token,
151
+ bill_address: nil,
152
+ ship_address: nil,
153
+ state: 'address'
154
+ )
155
+ end
156
+
157
+ # This may seem out of left field, but previously there was an issue
158
+ # where address would be built in a before filter and then would be saved
159
+ # when trying to update the email.
160
+ it "doesn't create addresses" do
161
+ expect {
162
+ subject
163
+ }.not_to change { Spree::Address.count }
164
+ expect(response).to redirect_to spree.checkout_path
165
+ end
166
+ end
167
+
168
+ context 'invalid email' do
169
+ let(:email) { 'invalid' }
170
+
171
+ it 'renders the registration view' do
172
+ subject
173
+ expect(flash[:registration_error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages])
174
+ expect(response).to render_template :registration
175
+ end
176
+ end
177
+
178
+ context 'with wrong order token' do
179
+ let(:cookie_token) { 'lol_no_access' }
180
+
181
+ it 'redirects to login' do
182
+ put :update_registration, { order: { email: 'foo@example.com' } }
183
+ expect(response).to redirect_to(login_path)
184
+ end
185
+ end
186
+
187
+ context 'without order token' do
188
+ let(:cookie_token) { nil }
189
+
190
+ it 'redirects to login' do
191
+ put :update_registration, { order: { email: 'foo@example.com' } }
192
+ expect(response).to redirect_to(login_path)
193
+ end
163
194
  end
164
195
  end
165
196
  end
@@ -1,6 +1,8 @@
1
1
  RSpec.feature 'Change email', type: :feature do
2
2
 
3
3
  background do
4
+ Spree::Auth::Config.set(signout_after_password_change: false)
5
+
4
6
  user = create(:user)
5
7
  visit spree.root_path
6
8
  click_link 'Login'
@@ -23,9 +23,28 @@ RSpec.feature 'Checkout', :js, type: :feature do
23
23
  visit spree.root_path
24
24
  end
25
25
 
26
+ # Regression test for https://github.com/solidusio/solidus/issues/1588
27
+ scenario 'leaving and returning to address step' do
28
+ Spree::Auth::Config.set(registration_step: true)
29
+ click_link 'RoR Mug'
30
+ click_button 'Add To Cart'
31
+ within('h1') { expect(page).to have_text 'Shopping Cart' }
32
+ click_button 'Checkout'
33
+
34
+ within '#guest_checkout' do
35
+ fill_in 'Email', with: 'test@example.com'
36
+ end
37
+ click_on 'Continue'
38
+
39
+ click_on 'Cart'
40
+
41
+ click_on 'Checkout'
42
+
43
+ expect(page).to have_content "Billing Address"
44
+ end
45
+
26
46
  context 'without payment being required' do
27
47
  scenario 'allow a visitor to checkout as guest, without registration' do
28
- Spree::Auth::Config.set(registration_step: true)
29
48
  click_link 'RoR Mug'
30
49
  click_button 'Add To Cart'
31
50
  within('h1') { expect(page).to have_text 'Shopping Cart' }
@@ -63,6 +63,8 @@ RSpec.describe Spree::User, type: :model do
63
63
  end
64
64
 
65
65
  describe "confirmable" do
66
+ before { skip "this introduces a run order dependency" }
67
+
66
68
  it "is confirmable if the confirmable option is enabled" do
67
69
  set_confirmable_option(true)
68
70
  Spree::UserMailer.stub(:confirmation_instructions).and_return(double(deliver: true))
data/spec/spec_helper.rb CHANGED
@@ -18,6 +18,9 @@ RSpec.configure do |config|
18
18
  config.filter_run focus: true
19
19
  config.run_all_when_everything_filtered = true
20
20
  config.use_transactional_fixtures = false
21
+ config.order = :random
22
+
23
+ config.example_status_persistence_file_path = "./spec/examples.txt"
21
24
 
22
25
  config.mock_with :rspec do |mock|
23
26
  mock.syntax = [:should, :expect]
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before do
3
+ Spree::Auth::Config.preference_store = Spree::Auth::Config.default_preferences
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-24 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -414,6 +414,7 @@ files:
414
414
  - spec/support/database_cleaner.rb
415
415
  - spec/support/email.rb
416
416
  - spec/support/factory_girl.rb
417
+ - spec/support/preferences.rb
417
418
  - spec/support/spree.rb
418
419
  homepage:
419
420
  licenses:
@@ -475,4 +476,5 @@ test_files:
475
476
  - spec/support/database_cleaner.rb
476
477
  - spec/support/email.rb
477
478
  - spec/support/factory_girl.rb
479
+ - spec/support/preferences.rb
478
480
  - spec/support/spree.rb