solidus_social 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +35 -0
  3. data/.gem_release.yml +5 -0
  4. data/.github/stale.yml +17 -0
  5. data/.gitignore +6 -8
  6. data/.rspec +3 -3
  7. data/.rubocop.yml +3 -149
  8. data/.rubocop_todo.yml +42 -0
  9. data/CHANGELOG.md +31 -9
  10. data/Gemfile +21 -20
  11. data/{LICENSE.md → LICENSE} +2 -2
  12. data/README.md +56 -14
  13. data/Rakefile +4 -19
  14. data/app/controllers/spree/admin/authentication_methods_controller.rb +2 -0
  15. data/app/controllers/spree/omniauth_callbacks_controller.rb +8 -6
  16. data/app/controllers/spree/user_authentications_controller.rb +3 -1
  17. data/app/decorators/controllers/solidus_social/spree/user_registrations_controller_decorator.rb +27 -0
  18. data/app/decorators/models/solidus_social/spree/user_decorator.rb +28 -0
  19. data/app/helpers/spree/omniauth_callbacks_helper.rb +2 -0
  20. data/app/models/spree/authentication_method.rb +3 -1
  21. data/app/models/spree/social_configuration.rb +2 -0
  22. data/app/models/spree/user_authentication.rb +3 -1
  23. data/app/overrides/add_authentications_to_account_summary.rb +2 -0
  24. data/app/overrides/admin_configuration_decorator.rb +3 -1
  25. data/app/overrides/user_registrations_decorator.rb +2 -0
  26. data/app/views/spree/admin/authentication_methods/_form.html.erb +4 -4
  27. data/app/views/spree/admin/authentication_methods/edit.html.erb +2 -2
  28. data/app/views/spree/admin/authentication_methods/index.html.erb +10 -10
  29. data/app/views/spree/admin/authentication_methods/new.html.erb +2 -2
  30. data/app/views/spree/shared/_social.html.erb +5 -5
  31. data/app/views/spree/shared/_user_form.html.erb +3 -3
  32. data/app/views/spree/users/_new-customer.html.erb +2 -2
  33. data/app/views/spree/users/_social.html.erb +5 -5
  34. data/bin/console +17 -0
  35. data/bin/rails +15 -4
  36. data/bin/rake +7 -0
  37. data/bin/sandbox +72 -0
  38. data/bin/setup +8 -0
  39. data/config/locales/en.yml +1 -0
  40. data/config/routes.rb +6 -4
  41. data/db/migrate/20120120163432_create_user_authentications.rb +2 -0
  42. data/db/migrate/20120123163222_create_authentication_methods.rb +2 -0
  43. data/lib/generators/solidus_social/install/install_generator.rb +7 -5
  44. data/lib/generators/solidus_social/install/templates/config/initializers/solidus_social.rb +3 -1
  45. data/lib/solidus_social.rb +22 -7
  46. data/lib/solidus_social/engine.rb +29 -54
  47. data/lib/solidus_social/facebook_omniauth_strategy_ext.rb +25 -0
  48. data/lib/solidus_social/factories.rb +4 -0
  49. data/lib/solidus_social/version.rb +3 -16
  50. data/solidus_social.gemspec +43 -46
  51. data/spec/controllers/spree/omniauth_callbacks_controller_spec.rb +14 -9
  52. data/spec/features/spree/admin/authentication_methods_configuration_spec.rb +13 -10
  53. data/spec/features/spree/sign_in_spec.rb +13 -10
  54. data/spec/lib/solidus_social/engine_spec.rb +9 -0
  55. data/spec/lib/{spree_social/engine_spec.rb → solidus_social_speec.rb} +3 -1
  56. data/spec/lib/spree/social_config_spec.rb +2 -0
  57. data/spec/models/spree/authentication_method_spec.rb +4 -2
  58. data/spec/models/spree/social_configuration_spec.rb +2 -0
  59. data/spec/models/spree/user_decorator_spec.rb +5 -3
  60. data/spec/spec_helper.rb +17 -29
  61. data/spec/support/omniauth.rb +4 -0
  62. metadata +56 -196
  63. data/.hound.yml +0 -26
  64. data/.travis.yml +0 -32
  65. data/app/assets/javascripts/spree/backend/solidus_social.js +0 -1
  66. data/app/assets/javascripts/spree/frontend/solidus_social.js +0 -1
  67. data/app/assets/stylesheets/spree/backend/solidus_social.css +0 -3
  68. data/app/controllers/spree/user_registrations_controller_decorator.rb +0 -15
  69. data/app/models/spree/user_decorator.rb +0 -16
  70. data/spec/support/capybara.rb +0 -11
  71. data/spec/support/database_cleaner.rb +0 -23
  72. data/spec/support/devise.rb +0 -3
  73. data/spec/support/factory_girl.rb +0 -7
  74. data/spec/support/spree.rb +0 -8
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ gem install bundler --conservative
7
+ bundle update
8
+ bin/rake clobber
@@ -10,6 +10,7 @@ en:
10
10
  destroy: 'Successfully destroyed authentication method.'
11
11
  back_to_authentication_methods_list: "Back To Authentication Methods List"
12
12
  edit_social_method: "Editing Social Authentication Method"
13
+ environment: "Environment"
13
14
  new_social_method: "New Authentication Method"
14
15
  no_authentication_methods_found: "No Authentication Methods Found"
15
16
  one_more_step: 'One more step to complete your registration from %{kind}'
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Spree::Core::Engine.routes.draw do
2
4
  devise_for :spree_user,
3
- class_name: Spree.user_class,
4
- only: [:omniauth_callbacks],
5
- controllers: { omniauth_callbacks: 'spree/omniauth_callbacks' },
6
- path: Spree::SocialConfig[:path_prefix]
5
+ class_name: Spree.user_class,
6
+ only: [:omniauth_callbacks],
7
+ controllers: { omniauth_callbacks: 'spree/omniauth_callbacks' },
8
+ path: Spree::SocialConfig[:path_prefix]
7
9
  resources :user_authentications
8
10
 
9
11
  get 'account' => 'users#show', as: 'user_root'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateUserAuthentications < SolidusSupport::Migration[4.2]
2
4
  def change
3
5
  create_table :spree_user_authentications do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateAuthenticationMethods < SolidusSupport::Migration[4.2]
2
4
  def change
3
5
  create_table :spree_authentication_methods do |t|
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusSocial
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
- source_root File.dirname(__FILE__) + "/templates"
6
+ source_root "#{__dir__}/templates"
5
7
 
6
8
  class_option :auto_run_migrations, type: :boolean, default: false
7
9
 
8
10
  def add_stylesheets
9
- inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_social\n", before: %r(\*/), verbose: true
11
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_social\n", before: %r{\*/}, verbose: true
10
12
  end
11
13
 
12
14
  def add_migrations
13
- run 'bundle exec rake railties:install:migrations FROM=solidus_social'
15
+ run 'bin/rails railties:install:migrations FROM=solidus_social'
14
16
  end
15
17
 
16
18
  def copy_initializer
@@ -20,9 +22,9 @@ module SolidusSocial
20
22
  def run_migrations
21
23
  run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
22
24
  if run_migrations
23
- run 'bundle exec rake db:migrate'
25
+ run 'bin/rails db:migrate'
24
26
  else
25
- puts 'Skipping rake db:migrate, don\'t forget to run it!'
27
+ puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
26
28
  end
27
29
  end
28
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Spree::SocialConfig.configure do |config|
2
4
  config.use_static_preferences!
3
5
 
@@ -42,7 +44,7 @@ OmniAuth.logger.progname = 'omniauth'
42
44
 
43
45
  OmniAuth.config.on_failure = proc do |env|
44
46
  env['devise.mapping'] = Devise.mappings[Spree.user_class.table_name.singularize.to_sym]
45
- controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
47
+ controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
46
48
  controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
47
49
  controller_klass.action(:failure).call(env)
48
50
  end
@@ -1,11 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'solidus_core'
2
4
  require 'solidus_support'
3
5
  require 'solidus_auth_devise'
4
- require 'omniauth-twitter'
5
- require 'omniauth-facebook'
6
- require 'omniauth-github'
7
- require 'omniauth-google-oauth2'
8
- require 'omniauth-amazon'
9
- require 'solidus_social/engine'
6
+
10
7
  require 'solidus_social/version'
11
- require 'coffee_script'
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,68 +1,43 @@
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'
12
+
1
13
  module SolidusSocial
2
14
  class Engine < Rails::Engine
3
- engine_name 'solidus_social'
4
-
5
- config.autoload_paths += %W(#{config.root}/lib)
6
-
7
- initializer 'solidus_social.environment', before: 'spree.environment' do
8
- Spree::SocialConfig = Spree::SocialConfiguration.new
9
- end
15
+ include SolidusSupport::EngineExtensions::Decorators
10
16
 
11
- initializer 'solidus_social.decorate_spree_user' do
12
- next unless Rails.application.respond_to?(:reloader)
17
+ isolate_namespace ::Spree
13
18
 
14
- Rails.application.reloader.after_class_unload do
15
- # Reload and decorate the spree user class immediately after it is
16
- # unloaded so that it is available to devise when loading routes
17
- load File.join(__dir__, '../../app/models/spree/user_decorator.rb')
18
- end
19
- end
19
+ engine_name 'solidus_social'
20
20
 
21
- def self.activate
22
- Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
23
- Rails.configuration.cache_classes ? require(c) : load(c)
24
- end
21
+ # use rspec for tests
22
+ config.generators do |g|
23
+ g.test_framework :rspec
25
24
  end
26
25
 
27
- config.to_prepare(&method(:activate).to_proc)
28
- end
29
-
30
- def self.configured_providers
31
- Spree::SocialConfig.providers.keys.map(&:to_s)
32
- end
33
-
34
- def self.init_providers
35
- Spree::SocialConfig.providers.each do |provider, credentials|
36
- setup_key_for(provider, credentials[:api_key], credentials[:api_secret])
37
- end
38
- end
26
+ USER_DECORATOR_PATH = root.join(
27
+ "app/decorators/models/solidus_social/spree/user_decorator.rb"
28
+ ).to_s
39
29
 
40
- def self.setup_key_for(provider, key, secret)
41
- Devise.setup do |config|
42
- config.omniauth provider, key, secret, setup: true
30
+ initializer 'solidus_social.environment', before: 'spree.environment' do
31
+ ::Spree::SocialConfig = ::Spree::SocialConfiguration.new
43
32
  end
44
- end
45
- end
46
33
 
47
- module OmniAuth
48
- module Strategies
49
- class Facebook < OAuth2
50
- MOBILE_USER_AGENTS = 'palm|blackberry|nokia|phone|midp|mobi|symbian|chtml|ericsson|minimo|' \
51
- 'audiovox|motorola|samsung|telit|upg1|windows ce|ucweb|astel|plucker|' \
52
- 'x320|x240|j2me|sgh|portable|sprint|docomo|kddi|softbank|android|mmp|' \
53
- 'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' \
54
- 'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' \
55
- 'mobile'
56
- def request_phase
57
- options[:scope] ||= 'email'
58
- options[:info_fields] ||= 'email'
59
- options[:display] = mobile_request? ? 'touch' : 'page'
60
- super
61
- end
34
+ initializer 'solidus_social.decorate_spree_user' do |app|
35
+ next unless app.respond_to?(:reloader)
62
36
 
63
- def mobile_request?
64
- ua = Rack::Request.new(@env).user_agent.to_s
65
- ua.downcase =~ Regexp.new(MOBILE_USER_AGENTS)
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
66
41
  end
67
42
  end
68
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
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ end
@@ -1,18 +1,5 @@
1
- module SolidusSocial
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
- module VERSION
11
- MAJOR = 1
12
- MINOR = 2
13
- TINY = 0
14
- PRE = nil
15
-
16
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
17
- end
3
+ module SolidusSocial
4
+ VERSION = '1.3.0'
18
5
  end
@@ -1,47 +1,44 @@
1
- lib = File.expand_path('../lib/', __FILE__)
2
- $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
3
-
4
- require 'solidus_social/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.platform = Gem::Platform::RUBY
8
- s.name = 'solidus_social'
9
- s.version = SolidusSocial.version
10
- s.summary = 'Adds social network login services (OAuth) to Spree'
11
- s.description = s.summary
12
- s.required_ruby_version = '>= 1.9.3'
13
-
14
- s.author = 'John Dyer'
15
- s.email = 'jdyer@spreecommerce.com'
16
- s.homepage = 'http://www.spreecommerce.com'
17
- s.license = 'BSD-3'
18
-
19
- s.files = `git ls-files`.split("\n")
20
- s.test_files = `git ls-files -- spec/*`.split("\n")
21
- s.require_path = 'lib'
22
- s.requirements << 'none'
23
-
24
- s.add_runtime_dependency 'solidus_core', [">= 1.0", "< 3"]
25
- s.add_runtime_dependency 'solidus_support'
26
- s.add_runtime_dependency 'solidus_auth_devise'
27
- s.add_runtime_dependency 'omniauth'
28
- s.add_runtime_dependency 'oa-core'
29
- s.add_runtime_dependency 'omniauth-twitter'
30
- s.add_runtime_dependency 'omniauth-facebook'
31
- s.add_runtime_dependency 'omniauth-github'
32
- s.add_runtime_dependency 'omniauth-google-oauth2'
33
- s.add_runtime_dependency 'omniauth-amazon'
34
-
35
- s.add_development_dependency 'capybara', '~> 2.4'
36
- s.add_development_dependency 'capybara-screenshot'
37
- s.add_development_dependency 'database_cleaner', '1.3'
38
- s.add_development_dependency 'rspec-rails', '~> 3.1'
39
- s.add_development_dependency 'factory_girl', '~> 4.4'
40
- s.add_development_dependency 'selenium-webdriver', '>= 2.41.0'
41
- s.add_development_dependency 'chromedriver-helper'
42
- s.add_development_dependency 'poltergeist', '~> 1.5'
43
- s.add_development_dependency 'simplecov', '~> 0.9.0'
44
- s.add_development_dependency 'sqlite3', '~> 1.3.10'
45
- s.add_development_dependency 'rubocop', '~> 0.39.0'
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 = Gem::Requirement.new('~> 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', '< 3']
41
+ spec.add_dependency 'solidus_support', '~> 0.4.0'
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
- context '#callback' do
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
- it_should_behave_like 'denied_permissions'
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(:find_by_provider_and_uid).and_return(user_authentication)
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(:find_by_provider_and_uid).and_return(nil)
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
- it_should_behave_like 'associate_order'
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
- it_should_behave_like 'denied_permissions'
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(:find_by_provider_and_uid).and_return(user_authentication)
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(:find_by_provider_and_uid).and_return(nil)
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
 
@@ -175,7 +180,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
175
180
  before { @user = create(:user, email: 'spree@gmail.com') }
176
181
 
177
182
  it 'does not create new user' do
178
- expect { controller.twitter }.to_not change(Spree::User, :count)
183
+ expect { controller.twitter }.not_to change(Spree::User, :count)
179
184
  end
180
185
 
181
186
  it 'assigns authentication to existing user' do