Initial commit - fresh start
This commit is contained in:
17
spec/support/devise.rb
Normal file
17
spec/support/devise.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
if defined?(Warden)
|
||||
include Warden::Test::Helpers
|
||||
Warden.test_mode!
|
||||
end
|
||||
|
||||
if defined?(Devise)
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include Devise::Test::IntegrationHelpers, type: :feature
|
||||
config.include Devise::Test::IntegrationHelpers, type: :request
|
||||
|
||||
config.include Warden::Test::Helpers
|
||||
config.before :suite do
|
||||
Warden.test_mode!
|
||||
end
|
||||
end
|
||||
end
|
||||
35
spec/support/spree/testing_support/auth_helpers.rb
Normal file
35
spec/support/spree/testing_support/auth_helpers.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
module Spree
|
||||
module TestingSupport
|
||||
module AuthHelpers
|
||||
def login_button
|
||||
Spree.t(:login)
|
||||
end
|
||||
|
||||
def logout_button
|
||||
Spree.t(:logout)
|
||||
end
|
||||
|
||||
def log_in(email:, password: nil, remember_me: true, locale: nil, checkout: false)
|
||||
if checkout
|
||||
visit "/checkout/#{order.token}"
|
||||
find('a[href*="/user/sign_in"]').click
|
||||
else
|
||||
visit "/user/sign_in?locale=#{locale}"
|
||||
end
|
||||
|
||||
fill_in 'user_email', with: email, wait: 5
|
||||
fill_in 'user_password', with: password, wait: 5
|
||||
click_button login_button
|
||||
|
||||
expect(page).to have_content 'Signed in successfully'
|
||||
end
|
||||
|
||||
def log_out
|
||||
visit '/account'
|
||||
click_on logout_button
|
||||
|
||||
expect(page).to have_content 'Signed out successfully'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user