solidus_social 1.0.0 → 1.4.0
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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.gitignore +6 -8
- data/.rspec +3 -3
- data/.rubocop.yml +3 -7
- data/.rubocop_todo.yml +42 -0
- data/CHANGELOG.md +34 -4
- data/Gemfile +23 -0
- data/{LICENSE.md → LICENSE} +2 -2
- data/README.md +133 -78
- data/Rakefile +4 -13
- data/app/controllers/spree/admin/authentication_methods_controller.rb +2 -12
- data/app/controllers/spree/omniauth_callbacks_controller.rb +46 -42
- data/app/controllers/spree/user_authentications_controller.rb +3 -1
- data/app/core/spree/permission_sets/authentication_method_display.rb +11 -0
- data/app/core/spree/permission_sets/authentication_method_management.rb +11 -0
- data/app/decorators/controllers/solidus_social/spree/user_registrations_controller_decorator.rb +27 -0
- data/app/decorators/models/solidus_social/spree/user_decorator.rb +28 -0
- data/app/helpers/spree/omniauth_callbacks_helper.rb +2 -0
- data/app/models/spree/authentication_method.rb +8 -2
- data/app/models/spree/social_configuration.rb +3 -0
- data/app/models/spree/user_authentication.rb +3 -1
- data/app/overrides/add_authentications_to_account_summary.rb +2 -0
- data/app/overrides/admin_configuration_decorator.rb +9 -2
- data/app/overrides/user_registrations_decorator.rb +2 -0
- data/app/views/spree/admin/authentication_methods/_form.html.erb +6 -22
- data/app/views/spree/admin/authentication_methods/edit.html.erb +5 -3
- data/app/views/spree/admin/authentication_methods/index.html.erb +22 -18
- data/app/views/spree/admin/authentication_methods/new.html.erb +5 -3
- data/app/views/spree/shared/_social.html.erb +5 -5
- data/app/views/spree/shared/_user_form.html.erb +3 -3
- data/app/views/spree/users/_new-customer.html.erb +2 -2
- data/app/views/spree/users/_social.html.erb +24 -22
- data/bin/console +17 -0
- data/bin/rails +15 -4
- data/bin/rake +7 -0
- data/bin/sandbox +72 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/es-MX.yml +8 -4
- data/config/locales/es.yml +30 -0
- data/config/locales/it.yml +26 -0
- data/config/routes.rb +7 -5
- data/db/migrate/20120120163432_create_user_authentications.rb +3 -1
- data/db/migrate/20120123163222_create_authentication_methods.rb +3 -1
- data/lib/generators/solidus_social/install/install_generator.rb +13 -5
- data/lib/generators/solidus_social/install/templates/config/initializers/solidus_social.rb +50 -0
- data/lib/solidus_social.rb +24 -8
- data/lib/solidus_social/engine.rb +29 -55
- data/lib/solidus_social/facebook_omniauth_strategy_ext.rb +25 -0
- data/lib/solidus_social/factories.rb +4 -0
- data/lib/solidus_social/version.rb +3 -16
- data/solidus_social.gemspec +43 -46
- data/spec/controllers/spree/omniauth_callbacks_controller_spec.rb +42 -9
- data/spec/features/spree/admin/authentication_methods_configuration_spec.rb +21 -27
- data/spec/features/spree/sign_in_spec.rb +27 -19
- data/spec/lib/solidus_social/engine_spec.rb +9 -0
- data/spec/lib/solidus_social_speec.rb +25 -0
- data/spec/lib/spree/social_config_spec.rb +11 -0
- data/spec/models/spree/authentication_method_spec.rb +19 -0
- data/spec/models/spree/social_configuration_spec.rb +6 -0
- data/spec/models/spree/user_decorator_spec.rb +25 -2
- data/spec/spec_helper.rb +17 -29
- data/spec/support/omniauth.rb +4 -0
- metadata +71 -198
- data/.hound.yml +0 -26
- data/.travis.yml +0 -19
- data/Guardfile +0 -10
- data/app/assets/javascripts/spree/backend/solidus_social.js +0 -1
- data/app/assets/javascripts/spree/frontend/solidus_social.js +0 -1
- data/app/assets/stylesheets/spree/backend/solidus_social.css +0 -3
- data/app/controllers/spree/user_registrations_controller_decorator.rb +0 -15
- data/app/models/spree/user_decorator.rb +0 -16
- data/app/views/spree/admin/shared/_configurations_menu.html.erb +0 -4
- data/config/initializers/devise.rb +0 -13
- data/spec/lib/spree_social/engine_spec.rb +0 -16
- data/spec/support/capybara.rb +0 -18
- data/spec/support/database_cleaner.rb +0 -24
- data/spec/support/devise.rb +0 -3
- data/spec/support/factory_girl.rb +0 -7
- data/spec/support/spree.rb +0 -8
data/lib/solidus_social.rb
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'solidus_core'
|
4
|
+
require 'solidus_support'
|
2
5
|
require 'solidus_auth_devise'
|
3
|
-
|
4
|
-
require 'omniauth-facebook'
|
5
|
-
require 'omniauth-github'
|
6
|
-
require 'omniauth-google-oauth2'
|
7
|
-
require 'omniauth-amazon'
|
8
|
-
require 'solidus_social/engine'
|
6
|
+
|
9
7
|
require 'solidus_social/version'
|
10
|
-
require '
|
8
|
+
require 'solidus_social/engine'
|
9
|
+
|
10
|
+
module SolidusSocial
|
11
|
+
def self.configured_providers
|
12
|
+
::Spree::SocialConfig.providers.keys.map(&:to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.init_providers
|
16
|
+
::Spree::SocialConfig.providers.each do |provider, credentials|
|
17
|
+
setup_key_for(provider, credentials[:api_key], credentials[:api_secret])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.setup_key_for(provider, key, secret)
|
22
|
+
Devise.setup do |config|
|
23
|
+
config.omniauth provider, key, secret, setup: true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,69 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'omniauth-twitter'
|
4
|
+
require 'omniauth-facebook'
|
5
|
+
require 'omniauth-github'
|
6
|
+
require 'omniauth-google-oauth2'
|
7
|
+
require 'omniauth-amazon'
|
8
|
+
require 'deface'
|
9
|
+
require 'coffee_script'
|
10
|
+
require 'spree/core'
|
11
|
+
require 'solidus_social/facebook_omniauth_strategy_ext'
|
9
12
|
|
13
|
+
module SolidusSocial
|
10
14
|
class Engine < Rails::Engine
|
11
|
-
|
15
|
+
include SolidusSupport::EngineExtensions
|
12
16
|
|
13
|
-
|
17
|
+
isolate_namespace ::Spree
|
14
18
|
|
15
|
-
|
16
|
-
Spree::SocialConfig = Spree::SocialConfiguration.new
|
17
|
-
end
|
19
|
+
engine_name 'solidus_social'
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
21
|
+
# use rspec for tests
|
22
|
+
config.generators do |g|
|
23
|
+
g.test_framework :rspec
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
USER_DECORATOR_PATH = root.join(
|
27
|
+
"app/decorators/models/solidus_social/spree/user_decorator.rb"
|
28
|
+
).to_s
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
return unless ActiveRecord::Base.connection.table_exists?('spree_authentication_methods')
|
31
|
-
key, secret = nil
|
32
|
-
Spree::AuthenticationMethod.where(environment: ::Rails.env).each do |auth_method|
|
33
|
-
next unless auth_method.provider == provider
|
34
|
-
key = auth_method.api_key
|
35
|
-
secret = auth_method.api_secret
|
36
|
-
Rails.logger.info("[Spree Social] Loading #{auth_method.provider.capitalize} as authentication source")
|
30
|
+
initializer 'solidus_social.environment', before: 'spree.environment' do
|
31
|
+
::Spree::SocialConfig = ::Spree::SocialConfiguration.new
|
37
32
|
end
|
38
|
-
setup_key_for(provider.to_sym, key, secret)
|
39
|
-
end
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
config.omniauth provider, key, secret, setup: true
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
module OmniAuth
|
49
|
-
module Strategies
|
50
|
-
class Facebook < OAuth2
|
51
|
-
MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' \
|
52
|
-
'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' \
|
53
|
-
'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' \
|
54
|
-
'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' \
|
55
|
-
'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' \
|
56
|
-
'mobile'
|
57
|
-
def request_phase
|
58
|
-
options[:scope] ||= 'email'
|
59
|
-
options[:info_fields] ||= 'email'
|
60
|
-
options[:display] = mobile_request? ? 'touch' : 'page'
|
61
|
-
super
|
62
|
-
end
|
34
|
+
initializer 'solidus_social.decorate_spree_user' do |app|
|
35
|
+
next unless app.respond_to?(:reloader)
|
63
36
|
|
64
|
-
|
65
|
-
|
66
|
-
|
37
|
+
app.reloader.after_class_unload do
|
38
|
+
# Reload and decorate the spree user class immediately after it is
|
39
|
+
# unloaded so that it is available to devise when loading routes
|
40
|
+
load USER_DECORATOR_PATH
|
67
41
|
end
|
68
42
|
end
|
69
43
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module SolidusSocial
|
2
|
+
# Patch the Facebook strategy discriminating between mobile and desktop.
|
3
|
+
module FacebookOmniauthStrategyExt
|
4
|
+
MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' \
|
5
|
+
'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' \
|
6
|
+
'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' \
|
7
|
+
'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' \
|
8
|
+
'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' \
|
9
|
+
'mobile'
|
10
|
+
|
11
|
+
def request_phase
|
12
|
+
options[:scope] ||= 'email'
|
13
|
+
options[:info_fields] ||= 'email'
|
14
|
+
options[:display] = mobile_request? ? 'touch' : 'page'
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def mobile_request?
|
19
|
+
ua = Rack::Request.new(@env).user_agent.to_s
|
20
|
+
ua.downcase =~ Regexp.new(MOBILE_USER_AGENTS)
|
21
|
+
end
|
22
|
+
|
23
|
+
OmniAuth::Strategies::Facebook.prepend self
|
24
|
+
end
|
25
|
+
end
|
@@ -1,18 +1,5 @@
|
|
1
|
-
|
2
|
-
module_function
|
3
|
-
|
4
|
-
# Returns the version of the currently loaded SolidusSocial as a
|
5
|
-
# <tt>Gem::Version</tt>.
|
6
|
-
def version
|
7
|
-
Gem::Version.new VERSION::STRING
|
8
|
-
end
|
1
|
+
# frozen_string_literal: true
|
9
2
|
|
10
|
-
|
11
|
-
|
12
|
-
MINOR = 0
|
13
|
-
TINY = 0
|
14
|
-
PRE = nil
|
15
|
-
|
16
|
-
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
17
|
-
end
|
3
|
+
module SolidusSocial
|
4
|
+
VERSION = '1.4.0'
|
18
5
|
end
|
data/solidus_social.gemspec
CHANGED
@@ -1,47 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
s.add_development_dependency 'guard-rspec'
|
45
|
-
s.add_development_dependency 'rubocop', '>= 0.24.1'
|
46
|
-
s.add_development_dependency 'rake', '< 11'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/solidus_social/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'solidus_social'
|
7
|
+
spec.version = SolidusSocial::VERSION
|
8
|
+
spec.authors = ['John Dyer']
|
9
|
+
spec.email = 'jdyer@spreecommerce.com'
|
10
|
+
|
11
|
+
spec.summary = 'Adds social network login services (OAuth) to Solidus'
|
12
|
+
spec.homepage = 'https://github.com/solidusio-contrib/solidus_social#readme'
|
13
|
+
spec.license = 'BSD-3-Clause'
|
14
|
+
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_social'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_social/blob/master/CHANGELOG.md'
|
19
|
+
|
20
|
+
spec.required_ruby_version = '>= 2.4'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
25
|
+
spec.files = files.grep_v(%r{^(test|spec|features)/})
|
26
|
+
spec.test_files = files.grep(%r{^(test|spec|features)/})
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency 'deface'
|
32
|
+
spec.add_dependency 'oa-core'
|
33
|
+
spec.add_dependency 'omniauth'
|
34
|
+
spec.add_dependency 'omniauth-amazon'
|
35
|
+
spec.add_dependency 'omniauth-facebook'
|
36
|
+
spec.add_dependency 'omniauth-github'
|
37
|
+
spec.add_dependency 'omniauth-google-oauth2'
|
38
|
+
spec.add_dependency 'omniauth-twitter'
|
39
|
+
spec.add_dependency 'solidus_auth_devise'
|
40
|
+
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
|
41
|
+
spec.add_dependency 'solidus_support', '~> 0.5'
|
42
|
+
|
43
|
+
spec.add_development_dependency 'solidus_dev_support'
|
47
44
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
2
4
|
let(:user) { create(:user) }
|
3
5
|
let(:omni_params) { double('omni', :[] => nil).as_null_object }
|
@@ -45,18 +47,19 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
|
50
|
+
describe '#callback' do
|
49
51
|
context 'when user is authenticated' do
|
50
52
|
before do
|
51
53
|
allow(controller).to receive(:spree_current_user).and_return(user)
|
52
54
|
end
|
53
55
|
|
54
|
-
|
56
|
+
it_behaves_like 'denied_permissions'
|
55
57
|
|
56
58
|
context 'when existing user_authentication' do
|
57
59
|
let(:user_authentication) { double('user_authentication', user: user) }
|
60
|
+
|
58
61
|
before do
|
59
|
-
allow(Spree::UserAuthentication).to receive(:
|
62
|
+
allow(Spree::UserAuthentication).to receive(:find_by).and_return(user_authentication)
|
60
63
|
end
|
61
64
|
|
62
65
|
it 'does not need to create the user_authentication' do
|
@@ -77,7 +80,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
77
80
|
|
78
81
|
context 'when no existing user_authentication' do
|
79
82
|
before do
|
80
|
-
allow(Spree::UserAuthentication).to receive(:
|
83
|
+
allow(Spree::UserAuthentication).to receive(:find_by).and_return(nil)
|
81
84
|
end
|
82
85
|
|
83
86
|
it 'creates a new user_authentication' do
|
@@ -96,7 +99,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
96
99
|
controller.twitter
|
97
100
|
end
|
98
101
|
|
99
|
-
|
102
|
+
it_behaves_like 'associate_order'
|
100
103
|
end
|
101
104
|
end
|
102
105
|
|
@@ -105,12 +108,13 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
105
108
|
allow(controller).to receive(:spree_current_user).and_return(nil)
|
106
109
|
end
|
107
110
|
|
108
|
-
|
111
|
+
it_behaves_like 'denied_permissions'
|
109
112
|
|
110
113
|
context 'when existing user_authentication' do
|
111
114
|
let(:user_authentication) { double('user_authentication', user: user) }
|
115
|
+
|
112
116
|
before do
|
113
|
-
allow(Spree::UserAuthentication).to receive(:
|
117
|
+
allow(Spree::UserAuthentication).to receive(:find_by).and_return(user_authentication)
|
114
118
|
end
|
115
119
|
|
116
120
|
it 'does not need to create the user_authentication' do
|
@@ -131,8 +135,9 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
131
135
|
|
132
136
|
context 'when no existing user_authentication' do
|
133
137
|
let(:user) { Spree::User.new }
|
138
|
+
|
134
139
|
before do
|
135
|
-
allow(Spree::UserAuthentication).to receive(:
|
140
|
+
allow(Spree::UserAuthentication).to receive(:find_by).and_return(nil)
|
136
141
|
allow(controller).to receive(:auth_hash).and_return('provider' => 'facebook', 'info' => { 'email' => 'spree@gmail.com' }, 'uid' => '123')
|
137
142
|
end
|
138
143
|
|
@@ -141,13 +146,41 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
141
146
|
expect(controller).to receive(:sign_in_and_redirect)
|
142
147
|
expect { controller.twitter }.to change(Spree::User, :count).by(1)
|
143
148
|
end
|
149
|
+
|
150
|
+
context 'when `Spree.user_class` has changed' do
|
151
|
+
before do
|
152
|
+
@previous_user_class = Spree.user_class.to_s
|
153
|
+
Spree.user_class = Spree::LegacyUser.to_s
|
154
|
+
|
155
|
+
# the application was initialized with Spree::User, so some
|
156
|
+
# some methods do not exist on LegacyUser. In practice, this will
|
157
|
+
# not happen as Spree.user_class will not change on the fly like
|
158
|
+
# this.
|
159
|
+
# this statement simply stubs the required missing method
|
160
|
+
allow_any_instance_of(Spree::LegacyUser)
|
161
|
+
.to receive(:apply_omniauth)
|
162
|
+
end
|
163
|
+
|
164
|
+
after do
|
165
|
+
# in order to not affect other tests, restore the original class
|
166
|
+
Spree.user_class = @previous_user_class
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'creates a new user' do
|
170
|
+
expect(Spree::User).not_to receive :new
|
171
|
+
expect_any_instance_of(Spree::User).not_to receive :save
|
172
|
+
|
173
|
+
expect { controller.twitter }
|
174
|
+
.to change(Spree::LegacyUser, :count).by(1)
|
175
|
+
end
|
176
|
+
end
|
144
177
|
end
|
145
178
|
|
146
179
|
context 'email belongs to existing user' do
|
147
180
|
before { @user = create(:user, email: 'spree@gmail.com') }
|
148
181
|
|
149
182
|
it 'does not create new user' do
|
150
|
-
expect { controller.twitter }.
|
183
|
+
expect { controller.twitter }.not_to change(Spree::User, :count)
|
151
184
|
end
|
152
185
|
|
153
186
|
it 'assigns authentication to existing user' do
|
@@ -1,77 +1,71 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe 'Admin Authentication Methods', :js do
|
2
4
|
stub_authorization!
|
3
5
|
|
4
6
|
context 'elements' do
|
5
|
-
|
7
|
+
it 'has configuration tab' do
|
6
8
|
visit spree.admin_path
|
7
9
|
click_link 'Settings'
|
8
|
-
expect(page).to have_text
|
10
|
+
expect(page).to have_text(/Social Authentication Methods/i)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
14
|
context 'when no auth methods exists' do
|
13
|
-
|
15
|
+
before do
|
14
16
|
visit spree.admin_path
|
15
17
|
click_link 'Settings'
|
16
18
|
click_link 'Social Authentication Methods'
|
17
19
|
end
|
18
20
|
|
19
|
-
|
20
|
-
expect(page).to have_text
|
21
|
+
it 'can create new' do
|
22
|
+
expect(page).to have_text /NO AUTHENTICATION METHODS FOUND, ADD ONE!/i
|
21
23
|
|
22
24
|
click_link 'New Authentication Method'
|
23
|
-
expect(page).to have_text
|
24
|
-
|
25
|
+
expect(page).to have_text /BACK TO AUTHENTICATION METHODS LIST/i
|
26
|
+
select2 'Test', from: 'Environment'
|
25
27
|
select2 'Github', from: 'Social Provider'
|
26
|
-
fill_in 'API Key', with: 'KEY123'
|
27
|
-
fill_in 'API Secret', with: 'SEC123'
|
28
28
|
|
29
29
|
click_button 'Create'
|
30
30
|
expect(page).to have_text 'successfully created!'
|
31
31
|
end
|
32
|
-
|
33
|
-
scenario 'does not save with empty fields' do
|
34
|
-
click_link 'New Authentication Method'
|
35
|
-
click_button 'Create'
|
36
|
-
expect(page).to have_text 'errors prohibited this record from being saved'
|
37
|
-
end
|
38
32
|
end
|
39
33
|
|
40
34
|
context 'when auth method exists' do
|
41
|
-
|
35
|
+
let!(:authentication_method) do
|
42
36
|
Spree::AuthenticationMethod.create!(
|
43
37
|
provider: 'facebook',
|
44
38
|
api_key: 'fake',
|
45
39
|
api_secret: 'fake',
|
46
40
|
environment: Rails.env,
|
47
|
-
active: true
|
41
|
+
active: true
|
42
|
+
)
|
48
43
|
end
|
49
44
|
|
50
|
-
|
45
|
+
before do
|
51
46
|
visit spree.admin_path
|
52
47
|
click_link 'Settings'
|
53
48
|
click_link 'Social Authentication Methods'
|
54
49
|
end
|
55
50
|
|
56
|
-
|
51
|
+
it 'can be updated' do
|
57
52
|
within_row(1) do
|
58
53
|
click_icon :edit
|
59
54
|
end
|
60
55
|
|
61
|
-
|
62
|
-
fill_in 'API Secret', with: 'fake'
|
56
|
+
find('#authentication_method_active_false').click
|
63
57
|
|
64
58
|
click_button 'Update'
|
65
59
|
expect(page).to have_text 'successfully updated!'
|
66
60
|
end
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
62
|
+
it 'can be deleted' do
|
63
|
+
accept_confirm do
|
64
|
+
within_row(1) do
|
65
|
+
click_icon :trash
|
66
|
+
end
|
71
67
|
end
|
72
68
|
|
73
|
-
page.driver.browser.switch_to.alert.accept unless Capybara.javascript_driver == :poltergeist
|
74
|
-
|
75
69
|
expect(page).to have_text 'successfully removed!'
|
76
70
|
expect(page).not_to have_text authentication_method.provider
|
77
71
|
end
|