spree_auth_devise 4.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +29 -23
- data/Appraisals +1 -1
- data/Gemfile +1 -1
- data/Rakefile +9 -3
- data/app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb +20 -0
- data/app/controllers/spree/api/v2/storefront/passwords_controller.rb +35 -0
- data/app/controllers/spree/user_passwords_controller.rb +1 -1
- data/app/mailers/spree/user_mailer.rb +6 -2
- data/app/models/spree/user.rb +17 -0
- data/app/services/spree/account/create.rb +19 -0
- data/app/services/spree/account/update.rb +17 -0
- data/app/views/spree/user_mailer/confirmation_instructions.text.erb +3 -3
- data/app/views/spree/user_mailer/reset_password_instructions.text.erb +2 -7
- data/config/locales/de.yml +18 -0
- data/config/locales/en.yml +7 -2
- data/config/locales/zh-TW.yml +60 -0
- data/config/routes.rb +10 -0
- data/gemfiles/spree_4_1.gemfile +1 -1
- data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +41 -0
- data/lib/controllers/frontend/spree/users_controller.rb +1 -6
- data/lib/spree/auth/engine.rb +14 -1
- data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +63 -0
- data/spec/features/admin/sign_in_spec.rb +8 -2
- data/spec/features/checkout_spec.rb +1 -1
- data/spec/features/sign_in_spec.rb +13 -7
- data/spec/features/sign_out_spec.rb +1 -3
- data/spec/mailers/user_mailer_spec.rb +2 -2
- data/spec/models/user_spec.rb +4 -2
- data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +48 -0
- data/spec/requests/spree/api/v2/storefront/account_spec.rb +101 -0
- data/spec/spec_helper.rb +7 -38
- data/spree_auth_devise.gemspec +3 -25
- metadata +20 -344
- data/spec/requests/spree/frontend/user_update_spec.rb +0 -42
- data/spec/support/add_to_cart.rb +0 -22
- data/spec/support/authentication_helpers.rb +0 -14
- data/spec/support/cache_helpers.rb +0 -5
- data/spec/support/capybara.rb +0 -23
- data/spec/support/database_cleaner.rb +0 -17
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/spree.rb +0 -10
@@ -35,17 +35,23 @@ RSpec.feature 'Sign In', type: :feature do
|
|
35
35
|
fill_in 'Password', with: user.password
|
36
36
|
click_button 'Log in'
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
if Spree.version.to_f > 4.1
|
39
|
+
within '.navbar .dropdown-menu' do
|
40
|
+
expect(page).to have_text 'admin@person.com'
|
41
|
+
end
|
42
|
+
else
|
43
|
+
within '.user-menu' do
|
44
|
+
expect(page).to have_text 'admin@person.com'
|
45
|
+
end
|
40
46
|
end
|
41
47
|
expect(current_path).to eq '/admin/orders'
|
42
48
|
end
|
43
49
|
|
44
|
-
|
50
|
+
it 'should store the user previous location' do
|
45
51
|
visit spree.account_path
|
46
|
-
fill_in
|
47
|
-
fill_in
|
48
|
-
click_button
|
49
|
-
expect(current_path).to eq
|
52
|
+
fill_in 'Email', with: @user.email
|
53
|
+
fill_in 'Password', with: @user.password
|
54
|
+
click_button 'Log in'
|
55
|
+
expect(current_path).to eq '/account'
|
50
56
|
end
|
51
57
|
end
|
@@ -5,7 +5,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
5
5
|
describe '#reset_password_instructions' do
|
6
6
|
describe 'message contents' do
|
7
7
|
before do
|
8
|
-
@message = described_class.reset_password_instructions(user, 'token goes here')
|
8
|
+
@message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.current.id })
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'subject includes' do
|
@@ -30,7 +30,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
30
30
|
describe 'legacy support for User object' do
|
31
31
|
it 'sends an email' do
|
32
32
|
expect {
|
33
|
-
described_class.reset_password_instructions(user, 'token goes here').deliver_now
|
33
|
+
described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.current.id }).deliver_now
|
34
34
|
}.to change(ActionMailer::Base.deliveries, :size).by(1)
|
35
35
|
end
|
36
36
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
RSpec.describe Spree::User, type: :model do
|
2
2
|
before(:all) { Spree::Role.create name: 'admin' }
|
3
|
+
let!(:store) { create(:store) }
|
3
4
|
|
4
5
|
it '#admin?' do
|
5
6
|
expect(create(:admin_user).admin?).to be true
|
@@ -8,8 +9,9 @@ RSpec.describe Spree::User, type: :model do
|
|
8
9
|
|
9
10
|
it 'generates the reset password token' do
|
10
11
|
user = build(:user)
|
11
|
-
|
12
|
-
user.
|
12
|
+
current_store = Spree::Store.current
|
13
|
+
expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, { current_store_id: current_store.id }).and_return(double(deliver: true))
|
14
|
+
user.send_reset_password_instructions(current_store)
|
13
15
|
expect(user.reset_password_token).not_to be_nil
|
14
16
|
end
|
15
17
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Storefront API v2 Account Confirmation spec', type: :request do
|
4
|
+
describe 'account_confirmations#show' do
|
5
|
+
|
6
|
+
before do
|
7
|
+
Spree::User.stub(:confirm_by_token, confirmation_token: confirmation_token).and_return user
|
8
|
+
get "/api/v2/storefront/account_confirmations/#{confirmation_token}"
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'valid confirmation_token param' do
|
12
|
+
let(:user) { create(:user, confirmation_token: '12345') }
|
13
|
+
let(:confirmation_token) { user.confirmation_token }
|
14
|
+
|
15
|
+
it_behaves_like 'returns 200 HTTP status'
|
16
|
+
|
17
|
+
it 'returns user state' do
|
18
|
+
expect(JSON.parse(response.body)['data']['state']).to eq('')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'invalid confirmation_token param' do
|
23
|
+
let(:user) do
|
24
|
+
user = create(:user)
|
25
|
+
user.errors.add(:confirmation_token, :invalid)
|
26
|
+
return user
|
27
|
+
end
|
28
|
+
let(:confirmation_token) { 'dummy_token' }
|
29
|
+
|
30
|
+
it 'return 422 status' do
|
31
|
+
expect(response.code).to eq('422')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'return JSON API payload of error' do
|
35
|
+
expect(JSON.parse(response.body)['error']).to eq("Confirmation token is invalid")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'blank confirmation_token param' do
|
40
|
+
let(:user) { build(:user) }
|
41
|
+
let(:confirmation_token) { '' }
|
42
|
+
|
43
|
+
it 'return 301 status' do
|
44
|
+
expect(response.code).to eq('301')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Storefront API v2 Account spec', type: :request do
|
4
|
+
describe 'account#create' do
|
5
|
+
before { post '/api/v2/storefront/account', params: params }
|
6
|
+
|
7
|
+
context 'valid user params' do
|
8
|
+
let(:params) do
|
9
|
+
{
|
10
|
+
"user": {
|
11
|
+
"email": "hello@example.com",
|
12
|
+
"password": "password123",
|
13
|
+
"password_confirmation": "password123"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it_behaves_like 'returns 200 HTTP status'
|
19
|
+
|
20
|
+
it 'return JSON API payload of User' do
|
21
|
+
expect(JSON.parse(response.body)['data']['attributes']['email']).to eq('hello@example.com')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'invalid user params' do
|
26
|
+
let(:params) do
|
27
|
+
{
|
28
|
+
"user": {
|
29
|
+
"email": "hello@example.com",
|
30
|
+
"password": "password123",
|
31
|
+
"password_confirmation": ""
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'return JSON API payload of error' do
|
37
|
+
expect(JSON.parse(response.body)['error']).to eq("Password Confirmation doesn't match Password")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'account#update' do
|
44
|
+
include_context 'API v2 tokens'
|
45
|
+
|
46
|
+
let!(:user) { create(:user_with_addresses) }
|
47
|
+
let(:headers) { headers_bearer }
|
48
|
+
|
49
|
+
before { patch '/api/v2/storefront/account', params: params, headers: headers }
|
50
|
+
|
51
|
+
context 'valid user params' do
|
52
|
+
let(:params) do
|
53
|
+
{
|
54
|
+
"user": {
|
55
|
+
"email": "spree@example.com",
|
56
|
+
"password": "password123",
|
57
|
+
"password_confirmation": "password123"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
it_behaves_like 'returns 200 HTTP status'
|
63
|
+
|
64
|
+
it 'return JSON API payload of User' do
|
65
|
+
expect(JSON.parse(response.body)['data']['attributes']['email']).to eq('spree@example.com')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'valid user params without passwords' do
|
70
|
+
let(:params) do
|
71
|
+
{
|
72
|
+
"user": {
|
73
|
+
"email": "spree@example.com"
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
it_behaves_like 'returns 200 HTTP status'
|
79
|
+
|
80
|
+
it 'return JSON API payload of User' do
|
81
|
+
expect(JSON.parse(response.body)['data']['attributes']['email']).to eq('spree@example.com')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'invalid user params' do
|
86
|
+
let(:params) do
|
87
|
+
{
|
88
|
+
"user": {
|
89
|
+
"email": "spree@example.com",
|
90
|
+
"password": "password123",
|
91
|
+
"password_confirmation": ""
|
92
|
+
}
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'return JSON API payload of error' do
|
97
|
+
expect(JSON.parse(response.body)['error']).to eq("Password Confirmation doesn't match Password")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,49 +1,18 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
3
|
|
4
|
-
|
4
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
5
|
|
6
|
-
require
|
6
|
+
require 'spree_dev_tools/rspec/spec_helper'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require 'pry'
|
12
|
-
|
13
|
-
require 'spree/testing_support/auth_helpers'
|
14
|
-
require 'spree/testing_support/checkout_helpers'
|
15
|
-
|
16
|
-
require 'spree/testing_support/authorization_helpers'
|
17
|
-
require 'spree/testing_support/capybara_ext'
|
18
|
-
require 'spree/testing_support/controller_requests'
|
19
|
-
require 'spree/testing_support/factories'
|
20
|
-
require 'spree/testing_support/url_helpers'
|
8
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
|
+
# in spec/support/ and its subdirectories.
|
10
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
|
21
11
|
|
22
12
|
RSpec.configure do |config|
|
23
|
-
config.filter_run focus: true
|
24
|
-
config.infer_spec_type_from_file_location!
|
25
|
-
config.raise_errors_for_deprecations!
|
26
|
-
config.run_all_when_everything_filtered = true
|
27
|
-
config.use_transactional_fixtures = false
|
28
|
-
|
29
|
-
config.mock_with :rspec do |mock|
|
30
|
-
mock.syntax = [:should, :expect]
|
31
|
-
end
|
32
|
-
|
33
|
-
config.order = :random
|
34
|
-
Kernel.srand(config.seed)
|
35
|
-
|
36
13
|
config.before(:each) do
|
37
14
|
allow(RSpec::Rails::ViewRendering::EmptyTemplateHandler)
|
38
15
|
.to receive(:call)
|
39
16
|
.and_return(%("")) if Rails.gem_version >= Gem::Version.new('6.0.0.beta1')
|
40
|
-
|
41
|
-
create(:store)
|
42
17
|
end
|
43
|
-
|
44
|
-
config.include Spree::TestingSupport::AuthHelpers, type: :feature
|
45
|
-
config.include Spree::TestingSupport::CheckoutHelpers, type: :feature
|
46
|
-
config.include Spree::TestingSupport::UrlHelpers
|
47
18
|
end
|
48
|
-
|
49
|
-
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
data/spree_auth_devise.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.name = 'spree_auth_devise'
|
6
|
-
s.version = '4.
|
6
|
+
s.version = '4.2.0'
|
7
7
|
s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.'
|
8
8
|
s.description = s.summary
|
9
9
|
|
@@ -24,31 +24,9 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency 'devise', '~> 4.7'
|
25
25
|
s.add_dependency 'devise-encryptable', '0.2.0'
|
26
26
|
|
27
|
-
spree_version = '>= 4.1
|
27
|
+
spree_version = '>= 4.1', '< 5.0'
|
28
28
|
s.add_dependency 'spree_core', spree_version
|
29
29
|
s.add_dependency 'spree_extension'
|
30
30
|
|
31
|
-
s.add_development_dependency '
|
32
|
-
s.add_development_dependency 'capybara'
|
33
|
-
s.add_development_dependency 'capybara-screenshot'
|
34
|
-
s.add_development_dependency 'coffee-rails', '~> 4.2'
|
35
|
-
s.add_development_dependency 'database_cleaner', '~> 1.5'
|
36
|
-
s.add_development_dependency 'email_spec', '~> 2.1'
|
37
|
-
s.add_development_dependency 'factory_bot', '~> 4.7'
|
38
|
-
s.add_development_dependency 'ffaker'
|
39
|
-
s.add_development_dependency 'launchy'
|
40
|
-
s.add_development_dependency 'mysql2'
|
41
|
-
s.add_development_dependency 'pg'
|
42
|
-
s.add_development_dependency 'pry'
|
43
|
-
s.add_development_dependency 'puma'
|
44
|
-
s.add_development_dependency 'rails-controller-testing'
|
45
|
-
s.add_development_dependency 'rspec-rails', '~> 4.0.0.beta2'
|
46
|
-
s.add_development_dependency 'sass-rails'
|
47
|
-
s.add_development_dependency 'selenium-webdriver'
|
48
|
-
s.add_development_dependency 'shoulda-matchers', '~> 4.3'
|
49
|
-
s.add_development_dependency 'simplecov', '~> 0.12'
|
50
|
-
s.add_development_dependency 'spree_backend', spree_version
|
51
|
-
s.add_development_dependency 'spree_frontend', spree_version
|
52
|
-
s.add_development_dependency 'sqlite3'
|
53
|
-
s.add_development_dependency 'webdrivers', '~> 4.2.0'
|
31
|
+
s.add_development_dependency 'spree_dev_tools'
|
54
32
|
end
|