solidus_auth_devise_devise_token_auth 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +173 -0
- data/Gemfile +36 -0
- data/LICENSE.md +26 -0
- data/README.md +98 -0
- data/Rakefile +21 -0
- data/app/mailers/spree/user_mailer.rb +15 -0
- data/app/models/spree/auth_configuration.rb +9 -0
- data/app/models/spree/user.rb +47 -0
- data/app/overrides/auth_admin_login_navigation_bar.rb +10 -0
- data/app/overrides/auth_shared_login_bar.rb +10 -0
- data/bin/rails +7 -0
- data/circle.yml +6 -0
- data/config/initializers/devise.rb +141 -0
- data/config/initializers/warden.rb +14 -0
- data/config/locales/de.yml +53 -0
- data/config/locales/en.yml +54 -0
- data/config/locales/es.yml +50 -0
- data/config/locales/fr.yml +50 -0
- data/config/locales/it.yml +76 -0
- data/config/locales/nl.yml +50 -0
- data/config/locales/pt-BR.yml +52 -0
- data/config/locales/tr.yml +50 -0
- data/config/locales/zh-CN.yml +54 -0
- data/config/routes.rb +71 -0
- data/db/default/users.rb +75 -0
- data/db/migrate/20101026184949_create_users.rb +29 -0
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +41 -0
- data/db/migrate/20101214150824_convert_user_remember_field.rb +11 -0
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +8 -0
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +9 -0
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +6 -0
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +7 -0
- data/db/seeds.rb +1 -0
- data/lib/assets/javascripts/spree/backend/solidus_auth.js +1 -0
- data/lib/assets/javascripts/spree/frontend/solidus_auth.js +1 -0
- data/lib/assets/stylesheets/spree/backend/solidus_auth.css +3 -0
- data/lib/assets/stylesheets/spree/frontend/solidus_auth.css +3 -0
- data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +11 -0
- data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +15 -0
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +41 -0
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +43 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +66 -0
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +14 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +50 -0
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +40 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +64 -0
- data/lib/controllers/frontend/spree/users_controller.rb +57 -0
- data/lib/generators/solidus/auth/install/install_generator.rb +25 -0
- data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +1 -0
- data/lib/solidus/auth.rb +2 -0
- data/lib/solidus_auth_devise.rb +13 -0
- data/lib/spree/auth/devise.rb +14 -0
- data/lib/spree/auth/engine.rb +80 -0
- data/lib/spree/authentication_helpers.rb +33 -0
- data/lib/tasks/auth.rake +9 -0
- data/lib/views/backend/spree/admin/shared/_navigation_footer.html.erb +25 -0
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +15 -0
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +17 -0
- data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +4 -0
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +31 -0
- data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +13 -0
- data/lib/views/frontend/spree/checkout/registration.html.erb +22 -0
- data/lib/views/frontend/spree/shared/_flashes.html.erb +9 -0
- data/lib/views/frontend/spree/shared/_login.html.erb +18 -0
- data/lib/views/frontend/spree/shared/_login_bar.html.erb +2 -0
- data/lib/views/frontend/spree/shared/_login_bar_items.html.erb +6 -0
- data/lib/views/frontend/spree/shared/_user_form.html.erb +17 -0
- data/lib/views/frontend/spree/user_mailer/confirmation_instructions.text.erb +5 -0
- data/lib/views/frontend/spree/user_mailer/reset_password_instructions.text.erb +10 -0
- data/lib/views/frontend/spree/user_passwords/edit.html.erb +17 -0
- data/lib/views/frontend/spree/user_passwords/new.html.erb +17 -0
- data/lib/views/frontend/spree/user_registrations/new.html.erb +21 -0
- data/lib/views/frontend/spree/user_sessions/authorization_failure.html.erb +4 -0
- data/lib/views/frontend/spree/user_sessions/new.html.erb +13 -0
- data/lib/views/frontend/spree/users/edit.html.erb +14 -0
- data/lib/views/frontend/spree/users/show.html.erb +43 -0
- data/solidus_auth_devise.gemspec +41 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +196 -0
- data/spec/controllers/spree/products_controller_spec.rb +27 -0
- data/spec/controllers/spree/user_passwords_controller_spec.rb +44 -0
- data/spec/controllers/spree/user_registrations_controller_spec.rb +96 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +113 -0
- data/spec/controllers/spree/users_controller_spec.rb +38 -0
- data/spec/factories/confirmed_user.rb +7 -0
- data/spec/features/account_spec.rb +58 -0
- data/spec/features/admin/orders_spec.rb +30 -0
- data/spec/features/admin/password_reset_spec.rb +24 -0
- data/spec/features/admin/products_spec.rb +9 -0
- data/spec/features/admin/sign_in_spec.rb +44 -0
- data/spec/features/admin/sign_out_spec.rb +22 -0
- data/spec/features/admin_permissions_spec.rb +46 -0
- data/spec/features/change_email_spec.rb +26 -0
- data/spec/features/checkout_spec.rb +181 -0
- data/spec/features/confirmation_spec.rb +32 -0
- data/spec/features/order_spec.rb +62 -0
- data/spec/features/password_reset_spec.rb +24 -0
- data/spec/features/sign_in_spec.rb +52 -0
- data/spec/features/sign_out_spec.rb +25 -0
- data/spec/features/sign_up_spec.rb +30 -0
- data/spec/mailers/user_mailer_spec.rb +46 -0
- data/spec/models/order_spec.rb +26 -0
- data/spec/models/user_spec.rb +63 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/ability.rb +15 -0
- data/spec/support/authentication_helpers.rb +14 -0
- data/spec/support/confirm_helpers.rb +13 -0
- data/spec/support/email.rb +5 -0
- data/spec/support/preferences.rb +5 -0
- data/spec/support/spree.rb +10 -0
- metadata +446 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Confirmation' do
|
4
|
+
before do
|
5
|
+
skip "this introduces a run order dependency"
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
set_confirmable_option(true)
|
10
|
+
Spree::UserMailer.stub(:confirmation_instructions).and_return(double(deliver: true))
|
11
|
+
end
|
12
|
+
|
13
|
+
#after(:each) { set_confirmable_option(false) }
|
14
|
+
|
15
|
+
let!(:store) { create(:store) }
|
16
|
+
|
17
|
+
background do
|
18
|
+
ActionMailer::Base.default_url_options[:host] = 'http://example.com'
|
19
|
+
end
|
20
|
+
|
21
|
+
scenario 'create a new user' do
|
22
|
+
visit spree.signup_path
|
23
|
+
|
24
|
+
fill_in 'Email', with: 'email@person.com'
|
25
|
+
fill_in 'Password', with: 'password'
|
26
|
+
fill_in 'Password Confirmation', with: 'password'
|
27
|
+
click_button 'Create'
|
28
|
+
|
29
|
+
expect(page).to have_text 'You have signed up successfully.'
|
30
|
+
expect(Spree::User.last.confirmed?).to be(false)
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
RSpec.feature 'Orders', :js, type: :feature do
|
2
|
+
|
3
|
+
scenario 'allow a user to view their cart at any time' do
|
4
|
+
visit spree.cart_path
|
5
|
+
expect(page).to have_text 'Your cart is empty'
|
6
|
+
end
|
7
|
+
|
8
|
+
# regression test for spree/spree#1687
|
9
|
+
scenario 'merge incomplete orders from different sessions' do
|
10
|
+
skip %{
|
11
|
+
TODO: has been broken for ~2 months as of:
|
12
|
+
https://github.com/spree/spree_auth_devise/commit/3157b47b22c559817d34ec34024587d8aa6136dc
|
13
|
+
I dont think we can decode these sessions anymore since Rails 4 switched to encrypted cookies I believe devise stores session encrypted.
|
14
|
+
}
|
15
|
+
create(:product, name: 'RoR Mug')
|
16
|
+
create(:product, name: 'RoR Shirt')
|
17
|
+
|
18
|
+
user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password')
|
19
|
+
|
20
|
+
using_session('first') do
|
21
|
+
visit spree.root_path
|
22
|
+
|
23
|
+
click_link 'RoR Mug'
|
24
|
+
click_button 'Add To Cart'
|
25
|
+
|
26
|
+
visit spree.login_path
|
27
|
+
fill_in 'Email', with: user.email
|
28
|
+
fill_in 'Password', with: user.password
|
29
|
+
click_button 'Login'
|
30
|
+
|
31
|
+
click_link 'Cart'
|
32
|
+
expect(page).to have_text 'RoR Mug'
|
33
|
+
end
|
34
|
+
|
35
|
+
using_session('second') do
|
36
|
+
visit spree.root_path
|
37
|
+
|
38
|
+
click_link 'RoR Shirt'
|
39
|
+
click_button 'Add To Cart'
|
40
|
+
|
41
|
+
visit spree.login_path
|
42
|
+
fill_in 'Email', with: user.email
|
43
|
+
fill_in 'Password', with: user.password
|
44
|
+
click_button 'Login'
|
45
|
+
|
46
|
+
# Order should have been merged with first session
|
47
|
+
click_link 'Cart'
|
48
|
+
expect(page).to have_text 'RoR Mug'
|
49
|
+
expect(page).to have_text 'RoR Shirt'
|
50
|
+
end
|
51
|
+
|
52
|
+
using_session('first') do
|
53
|
+
visit spree.root_path
|
54
|
+
|
55
|
+
click_link 'Cart'
|
56
|
+
|
57
|
+
# Order should have been merged with second session
|
58
|
+
expect(page).to have_text 'RoR Mug'
|
59
|
+
expect(page).to have_text 'RoR Shirt'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
RSpec.feature 'Reset Password', type: :feature do
|
2
|
+
|
3
|
+
let!(:store) { create(:store) }
|
4
|
+
|
5
|
+
background do
|
6
|
+
ActionMailer::Base.default_url_options[:host] = 'http://example.com'
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'allow a user to supply an email for the password reset' do
|
10
|
+
user = create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret')
|
11
|
+
visit spree.login_path
|
12
|
+
click_link 'Forgot Password?'
|
13
|
+
fill_in 'Email', with: 'foobar@example.com'
|
14
|
+
click_button 'Reset my password'
|
15
|
+
expect(page).to have_text 'You will receive an email with instructions'
|
16
|
+
end
|
17
|
+
|
18
|
+
scenario 'shows errors if no email is supplied' do
|
19
|
+
visit spree.login_path
|
20
|
+
click_link 'Forgot Password?'
|
21
|
+
click_button 'Reset my password'
|
22
|
+
expect(page).to have_text "Email can't be blank"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
RSpec.feature 'Sign In', type: :feature do
|
2
|
+
|
3
|
+
background do
|
4
|
+
@user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret')
|
5
|
+
visit spree.login_path
|
6
|
+
end
|
7
|
+
|
8
|
+
scenario 'ask user to sign in' do
|
9
|
+
visit spree.admin_path
|
10
|
+
expect(page).not_to have_text 'Authorization Failure'
|
11
|
+
end
|
12
|
+
|
13
|
+
scenario 'let a user sign in successfully' do
|
14
|
+
fill_in 'Email', with: @user.email
|
15
|
+
fill_in 'Password', with: @user.password
|
16
|
+
click_button 'Login'
|
17
|
+
|
18
|
+
expect(page).to have_text 'Logged in successfully'
|
19
|
+
expect(page).not_to have_text 'Login'
|
20
|
+
expect(page).to have_text 'Logout'
|
21
|
+
expect(current_path).to eq '/'
|
22
|
+
end
|
23
|
+
|
24
|
+
scenario 'show validation erros' do
|
25
|
+
fill_in 'Email', with: @user.email
|
26
|
+
fill_in 'Password', with: 'wrong_password'
|
27
|
+
click_button 'Login'
|
28
|
+
|
29
|
+
expect(page).to have_text 'Invalid email or password'
|
30
|
+
expect(page).to have_text 'Login'
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario 'allow a user to access a restricted page after logging in' do
|
34
|
+
user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password')
|
35
|
+
visit spree.admin_path
|
36
|
+
|
37
|
+
fill_in 'Email', with: user.email
|
38
|
+
fill_in 'Password', with: user.password
|
39
|
+
click_button 'Login'
|
40
|
+
|
41
|
+
expect(page).to have_text 'admin@person.com'
|
42
|
+
expect(current_path).to eq '/admin/orders'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should store the user previous location" do
|
46
|
+
visit spree.account_path
|
47
|
+
fill_in "Email", with: @user.email
|
48
|
+
fill_in "Password", with: @user.password
|
49
|
+
click_button "Login"
|
50
|
+
expect(current_path).to eq "/account"
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec.feature 'Sign Out', type: :feature do
|
2
|
+
|
3
|
+
given!(:user) do
|
4
|
+
create(:user,
|
5
|
+
email: 'email@person.com',
|
6
|
+
password: 'secret',
|
7
|
+
password_confirmation: 'secret')
|
8
|
+
end
|
9
|
+
|
10
|
+
background do
|
11
|
+
visit spree.login_path
|
12
|
+
fill_in 'Email', with: user.email
|
13
|
+
fill_in 'Password', with: user.password
|
14
|
+
# Regression test for #1257
|
15
|
+
check 'Remember me'
|
16
|
+
click_button 'Login'
|
17
|
+
end
|
18
|
+
|
19
|
+
scenario 'allow a signed in user to logout' do
|
20
|
+
click_link 'Logout'
|
21
|
+
visit spree.root_path
|
22
|
+
expect(page).to have_text 'Login'
|
23
|
+
expect(page).not_to have_text 'Logout'
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
RSpec.feature 'Sign Up', type: :feature do
|
2
|
+
|
3
|
+
context 'with valid data' do
|
4
|
+
scenario 'create a new user' do
|
5
|
+
visit spree.signup_path
|
6
|
+
|
7
|
+
fill_in 'Email', with: 'email@person.com'
|
8
|
+
fill_in 'Password', with: 'password'
|
9
|
+
fill_in 'Password Confirmation', with: 'password'
|
10
|
+
click_button 'Create'
|
11
|
+
|
12
|
+
expect(page).to have_text 'You have signed up successfully.'
|
13
|
+
expect(Spree::User.count).to eq(1)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with invalid data' do
|
18
|
+
scenario 'does not create a new user' do
|
19
|
+
visit spree.signup_path
|
20
|
+
|
21
|
+
fill_in 'Email', with: 'email@person.com'
|
22
|
+
fill_in 'Password', with: 'password'
|
23
|
+
fill_in 'Password Confirmation', with: ''
|
24
|
+
click_button 'Create'
|
25
|
+
|
26
|
+
expect(page).to have_css '#errorExplanation'
|
27
|
+
expect(Spree::User.count).to eq(0)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
RSpec.describe Spree::UserMailer, type: :mailer do
|
2
|
+
|
3
|
+
let!(:store) { create(:store) }
|
4
|
+
let(:user) { create(:user) }
|
5
|
+
|
6
|
+
before do
|
7
|
+
user = create(:user)
|
8
|
+
Spree::UserMailer.reset_password_instructions(user, 'token goes here').deliver_now
|
9
|
+
@message = ActionMailer::Base.deliveries.last
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#reset_password_instructions' do
|
13
|
+
describe 'message contents' do
|
14
|
+
before do
|
15
|
+
described_class.reset_password_instructions(user, 'token goes here').deliver_now
|
16
|
+
@message = ActionMailer::Base.deliveries.last
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'subject includes' do
|
20
|
+
it 'translated devise instructions' do
|
21
|
+
expect(@message.subject).to include(
|
22
|
+
I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'Spree site name' do
|
27
|
+
expect(@message.subject).to include store.name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'body includes' do
|
32
|
+
it 'password reset url' do
|
33
|
+
expect(@message.body.raw_source).to include "http://#{store.url}/user/spree_user/password/edit"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'legacy support for User object' do
|
39
|
+
it 'sends an email' do
|
40
|
+
expect {
|
41
|
+
described_class.reset_password_instructions(user, 'token goes here').deliver_now
|
42
|
+
}.to change(ActionMailer::Base.deliveries, :size).by(1)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec.describe Spree::Order, type: :model do
|
2
|
+
|
3
|
+
let(:order) { described_class.new }
|
4
|
+
|
5
|
+
context '#associate_user!' do
|
6
|
+
let(:user) { build_stubbed(:user, email: 'spree@example.com') }
|
7
|
+
before { allow(order).to receive(:save!) { true } }
|
8
|
+
|
9
|
+
it 'associates the order with the specified user' do
|
10
|
+
order.associate_user! user
|
11
|
+
expect(order.user).to eq user
|
12
|
+
end
|
13
|
+
|
14
|
+
it "sets the order's email attribute to that of the specified user" do
|
15
|
+
order.associate_user! user
|
16
|
+
expect(order.email).to eq user.email
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'destroys any previous association with a guest user' do
|
20
|
+
guest_user = build_stubbed(:user)
|
21
|
+
order.user = guest_user
|
22
|
+
order.associate_user! user
|
23
|
+
expect(order.user).not_to eq guest_user
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
RSpec.describe Spree::User, type: :model do
|
2
|
+
|
3
|
+
before(:all) { Spree::Role.create name: 'admin' }
|
4
|
+
|
5
|
+
it '#admin?' do
|
6
|
+
expect(create(:admin_user).admin?).to be true
|
7
|
+
expect(create(:user).admin?).to be false
|
8
|
+
end
|
9
|
+
|
10
|
+
context "recoverable" do
|
11
|
+
let(:user) { create(:user) }
|
12
|
+
|
13
|
+
it 'generates the reset password token' do
|
14
|
+
expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, {}).and_return(double(deliver: true))
|
15
|
+
expect { user.send_reset_password_instructions }.to change(user, :reset_password_token).to be_present
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#destroy' do
|
20
|
+
# Users with orders are not deletable in Solidus core
|
21
|
+
# therefore we cannot test this behaviour here.
|
22
|
+
# Also there are already sufficient specs in core.
|
23
|
+
let(:user) { create(:user) }
|
24
|
+
|
25
|
+
it 'acts_as_paranoid' do
|
26
|
+
# Instead of testing implementation details of `acts_as_paranoid`
|
27
|
+
# we are testing that we are using `acts_as_paranoid` by using duck typing
|
28
|
+
expect(described_class).to respond_to(:with_deleted)
|
29
|
+
expect(user).to respond_to(:deleted_at)
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with same email address as previously deleted account' do
|
33
|
+
it 'will allow users to register later' do
|
34
|
+
user1 = build(:user)
|
35
|
+
user1.save
|
36
|
+
|
37
|
+
user2 = build(:user)
|
38
|
+
user2.email = user1.email
|
39
|
+
expect(user2.save).to be false
|
40
|
+
expect(user2.errors.messages[:email].first).to eq "has already been taken"
|
41
|
+
|
42
|
+
user1.destroy
|
43
|
+
expect(user2.save).to be true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "confirmable" do
|
49
|
+
before { skip "this introduces a run order dependency" }
|
50
|
+
|
51
|
+
it "is confirmable if the confirmable option is enabled" do
|
52
|
+
set_confirmable_option(true)
|
53
|
+
Spree::UserMailer.stub(:confirmation_instructions).and_return(double(deliver: true))
|
54
|
+
expect(Spree::User.devise_modules).to include(:confirmable)
|
55
|
+
set_confirmable_option(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "is not confirmable if the confirmable option is disabled" do
|
59
|
+
set_confirmable_option(false)
|
60
|
+
expect(Spree::User.devise_modules).to_not include(:confirmable)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start "rails"
|
3
|
+
|
4
|
+
ENV["RAILS_ENV"] ||= "test"
|
5
|
+
|
6
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
7
|
+
|
8
|
+
require "solidus_support/extension/feature_helper"
|
9
|
+
|
10
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.infer_spec_type_from_file_location!
|
14
|
+
config.raise_errors_for_deprecations!
|
15
|
+
|
16
|
+
config.example_status_persistence_file_path = "./spec/examples.txt"
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.after do
|
3
|
+
Spree::Ability.abilities.delete(AbilityDecorator) if Spree::Ability.abilities.include?(AbilityDecorator)
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
if defined? CanCan::Ability
|
8
|
+
class AbilityDecorator
|
9
|
+
include CanCan::Ability
|
10
|
+
|
11
|
+
def initialize(user)
|
12
|
+
cannot :manage, Spree::Order
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module AuthenticationHelpers
|
2
|
+
def sign_in_as!(user)
|
3
|
+
visit '/login'
|
4
|
+
fill_in 'Email', with: user.email
|
5
|
+
fill_in 'Password', with: 'secret'
|
6
|
+
click_button 'Login'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include AuthenticationHelpers, type: :feature
|
12
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
13
|
+
config.include Rack::Test::Methods, type: :feature
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ConfirmHelpers
|
2
|
+
def set_confirmable_option(value)
|
3
|
+
# FIXME: This is terrible terribleness and causes anything loaded
|
4
|
+
# on the user at initialization to be lost.
|
5
|
+
Spree::Auth::Config[:confirmable] = value
|
6
|
+
Spree.send(:remove_const, 'User')
|
7
|
+
load File.expand_path("../../../app/models/spree/user.rb", __FILE__)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |c|
|
12
|
+
c.include ConfirmHelpers
|
13
|
+
end
|