solidus_social 1.2.0 → 1.3.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/.github/stale.yml +17 -0
- data/.gitignore +6 -8
- data/.rspec +3 -3
- data/.rubocop.yml +3 -149
- data/.rubocop_todo.yml +42 -0
- data/CHANGELOG.md +31 -9
- data/Gemfile +21 -20
- data/{LICENSE.md → LICENSE} +2 -2
- data/README.md +56 -14
- data/Rakefile +4 -19
- data/app/controllers/spree/admin/authentication_methods_controller.rb +2 -0
- data/app/controllers/spree/omniauth_callbacks_controller.rb +8 -6
- data/app/controllers/spree/user_authentications_controller.rb +3 -1
- 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 +3 -1
- data/app/models/spree/social_configuration.rb +2 -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 +3 -1
- data/app/overrides/user_registrations_decorator.rb +2 -0
- data/app/views/spree/admin/authentication_methods/_form.html.erb +4 -4
- data/app/views/spree/admin/authentication_methods/edit.html.erb +2 -2
- data/app/views/spree/admin/authentication_methods/index.html.erb +10 -10
- data/app/views/spree/admin/authentication_methods/new.html.erb +2 -2
- 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 +5 -5
- 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/routes.rb +6 -4
- data/db/migrate/20120120163432_create_user_authentications.rb +2 -0
- data/db/migrate/20120123163222_create_authentication_methods.rb +2 -0
- data/lib/generators/solidus_social/install/install_generator.rb +7 -5
- data/lib/generators/solidus_social/install/templates/config/initializers/solidus_social.rb +3 -1
- data/lib/solidus_social.rb +22 -7
- data/lib/solidus_social/engine.rb +29 -54
- 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 +14 -9
- data/spec/features/spree/admin/authentication_methods_configuration_spec.rb +13 -10
- data/spec/features/spree/sign_in_spec.rb +13 -10
- data/spec/lib/solidus_social/engine_spec.rb +9 -0
- data/spec/lib/{spree_social/engine_spec.rb → solidus_social_speec.rb} +3 -1
- data/spec/lib/spree/social_config_spec.rb +2 -0
- data/spec/models/spree/authentication_method_spec.rb +4 -2
- data/spec/models/spree/social_configuration_spec.rb +2 -0
- data/spec/models/spree/user_decorator_spec.rb +5 -3
- data/spec/spec_helper.rb +17 -29
- data/spec/support/omniauth.rb +4 -0
- metadata +56 -196
- data/.hound.yml +0 -26
- data/.travis.yml +0 -32
- 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/spec/support/capybara.rb +0 -11
- data/spec/support/database_cleaner.rb +0 -23
- data/spec/support/devise.rb +0 -3
- data/spec/support/factory_girl.rb +0 -7
- data/spec/support/spree.rb +0 -8
data/Rakefile
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
|
2
|
-
Bundler::GemHelper.install_tasks
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require '
|
5
|
-
|
3
|
+
require 'solidus_dev_support/rake_tasks'
|
4
|
+
SolidusDevSupport::RakeTasks.install
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
task :default do
|
10
|
-
if Dir["spec/dummy"].empty?
|
11
|
-
Rake::Task[:test_app].invoke
|
12
|
-
Dir.chdir("../../")
|
13
|
-
end
|
14
|
-
Rake::Task[:spec].invoke
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Generates a dummy app for testing'
|
18
|
-
task :test_app do
|
19
|
-
ENV['LIB_NAME'] = 'solidus_social'
|
20
|
-
Rake::Task['common:test_app'].invoke('Spree::User')
|
21
|
-
end
|
6
|
+
task default: 'extension:specs'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
4
|
include Spree::Core::ControllerHelpers::Common
|
3
5
|
include Spree::Core::ControllerHelpers::Order
|
@@ -18,14 +20,14 @@ class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
18
20
|
|
19
21
|
def omniauth_callback
|
20
22
|
if request.env['omniauth.error'].present?
|
21
|
-
flash[:error] = I18n.t('devise.omniauth_callbacks.failure', kind: auth_hash['provider'], reason:
|
23
|
+
flash[:error] = I18n.t('devise.omniauth_callbacks.failure', kind: auth_hash['provider'], reason: I18n.t('spree.user_was_not_valid'))
|
22
24
|
redirect_back_or_default(root_url)
|
23
25
|
return
|
24
26
|
end
|
25
27
|
|
26
|
-
authentication = Spree::UserAuthentication.
|
28
|
+
authentication = Spree::UserAuthentication.find_by(provider: auth_hash['provider'], uid: auth_hash['uid'])
|
27
29
|
|
28
|
-
if authentication.present?
|
30
|
+
if authentication.present? && authentication.try(:user).present?
|
29
31
|
flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: auth_hash['provider'])
|
30
32
|
sign_in_and_redirect :spree_user, authentication.user
|
31
33
|
elsif spree_current_user
|
@@ -34,14 +36,14 @@ class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
34
36
|
flash[:notice] = I18n.t('devise.sessions.signed_in')
|
35
37
|
redirect_back_or_default(account_url)
|
36
38
|
else
|
37
|
-
user = Spree.user_class.
|
39
|
+
user = Spree.user_class.find_by(email: auth_hash['info']['email']) || Spree.user_class.new
|
38
40
|
user.apply_omniauth(auth_hash)
|
39
41
|
if user.save
|
40
42
|
flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: auth_hash['provider'])
|
41
43
|
sign_in_and_redirect :spree_user, user
|
42
44
|
else
|
43
45
|
session[:omniauth] = auth_hash.except('extra')
|
44
|
-
flash[:notice] =
|
46
|
+
flash[:notice] = I18n.t('spree.one_more_step', kind: auth_hash['provider'].capitalize)
|
45
47
|
redirect_to new_spree_user_registration_url
|
46
48
|
return
|
47
49
|
end
|
@@ -60,7 +62,7 @@ class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def passthru
|
63
|
-
render file: "#{Rails.root}/public/404", formats: [:html], status:
|
65
|
+
render file: "#{Rails.root}/public/404", formats: [:html], status: :not_found, layout: false
|
64
66
|
end
|
65
67
|
|
66
68
|
def auth_hash
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Spree::UserAuthenticationsController < Spree::StoreController
|
2
4
|
def index
|
3
5
|
@authentications = spree_current_user.user_authentications if spree_current_user
|
@@ -6,7 +8,7 @@ class Spree::UserAuthenticationsController < Spree::StoreController
|
|
6
8
|
def destroy
|
7
9
|
@authentication = spree_current_user.user_authentications.find(params[:id])
|
8
10
|
@authentication.destroy
|
9
|
-
flash[:notice] =
|
11
|
+
flash[:notice] = I18n.t('spree.destroy', scope: :authentications)
|
10
12
|
redirect_to spree.account_path
|
11
13
|
end
|
12
14
|
end
|
data/app/decorators/controllers/solidus_social/spree/user_registrations_controller_decorator.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusSocial
|
4
|
+
module Spree
|
5
|
+
module UserRegistrationsControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
after_action :clear_omniauth, only: :create
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def build_resource(*args)
|
15
|
+
super
|
16
|
+
@spree_user.apply_omniauth(session[:omniauth]) if session[:omniauth]
|
17
|
+
@spree_user
|
18
|
+
end
|
19
|
+
|
20
|
+
def clear_omniauth
|
21
|
+
session[:omniauth] = nil unless @spree_user.new_record?
|
22
|
+
end
|
23
|
+
|
24
|
+
::Spree::UserRegistrationsController.prepend self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusSocial
|
4
|
+
module Spree
|
5
|
+
module UserDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.class_eval do
|
8
|
+
has_many :user_authentications, dependent: :destroy
|
9
|
+
|
10
|
+
devise :omniauthable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def apply_omniauth(omniauth)
|
15
|
+
if omniauth.fetch('info', {})['email'].present?
|
16
|
+
self.email = omniauth['info']['email'] if email.blank?
|
17
|
+
end
|
18
|
+
user_authentications.build(provider: omniauth['provider'], uid: omniauth['uid'])
|
19
|
+
end
|
20
|
+
|
21
|
+
def password_required?
|
22
|
+
(user_authentications.empty? || password.present?) && super
|
23
|
+
end
|
24
|
+
|
25
|
+
::Spree.user_class.prepend self
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Spree::AuthenticationMethod < ApplicationRecord
|
2
4
|
def self.provider_options
|
3
5
|
SolidusSocial.configured_providers.map { |provider_name| [provider_name.split("_").first.camelize, provider_name] }
|
4
6
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Deface::Override.new(virtual_path: 'spree/admin/shared/_configuration_menu',
|
2
4
|
name: 'add_social_providers_link_configuration_menu',
|
3
5
|
insert_bottom: '[data-hook="admin_configurations_sidebar_menu"]',
|
4
|
-
text: '<%= configurations_sidebar_menu_item
|
6
|
+
text: '<%= configurations_sidebar_menu_item I18n.t("spree.social_authentication_methods"), spree.admin_authentication_methods_path %>',
|
5
7
|
disabled: false)
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<div class="alpha five columns">
|
11
11
|
<div data-hook="environment" class="field">
|
12
12
|
<%= f.field_container :provider do %>
|
13
|
-
<%= f.label :provider,
|
13
|
+
<%= f.label :provider, I18n.t('spree.social_provider') %>
|
14
14
|
<%= f.select :provider, Spree::AuthenticationMethod.provider_options, {}, { include_blank: false, class: 'select2 fullwidth' } %>
|
15
15
|
<% end %>
|
16
16
|
</div>
|
@@ -18,11 +18,11 @@
|
|
18
18
|
<div class="alpha five columns">
|
19
19
|
<div data-hook="environment" class="field">
|
20
20
|
<%= f.field_container :active do %>
|
21
|
-
<span style="padding:0 10px 2px;"><%= f.label :active,
|
21
|
+
<span style="padding:0 10px 2px;"><%= f.label :active, I18n.t('spree.active') %></span>
|
22
22
|
<%= f.radio_button :active, :true %>
|
23
|
-
<span style="padding:0 2px;"><%=
|
23
|
+
<span style="padding:0 2px;"><%= I18n.t('spree.say_yes') %></span>
|
24
24
|
<%= f.radio_button :active, :false %>
|
25
|
-
<span style="padding:0 2px"><%=
|
25
|
+
<span style="padding:0 2px"><%= I18n.t('spree.say_no') %></span>
|
26
26
|
<% end %>
|
27
27
|
</div>
|
28
28
|
</div>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<%= render 'spree/admin/shared/configuration_menu' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%=
|
4
|
+
<%= I18n.t('spree.edit_social_method') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<% content_for :page_actions do %>
|
8
|
-
<li><%= link_to_with_icon 'icon-arrow-left',
|
8
|
+
<li><%= link_to_with_icon 'icon-arrow-left', I18n.t('spree.back_to_authentication_methods_list'), admin_authentication_methods_path, class: 'button' %></li>
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
<%= render 'spree/shared/error_messages', target: @authentication_method %>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<%= render 'spree/admin/shared/configuration_menu' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%=
|
4
|
+
<%= I18n.t('spree.social_authentication_methods') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<% content_for :page_actions do %>
|
8
8
|
<ul class="actions inline-menu">
|
9
9
|
<li>
|
10
|
-
<%=
|
10
|
+
<%= link_to I18n.t('spree.new_social_method'), new_object_url, id: 'admin_new_slide_link' %>
|
11
11
|
</li>
|
12
12
|
</ul>
|
13
13
|
<% end %>
|
@@ -23,11 +23,11 @@
|
|
23
23
|
<col style="width: 20%" />
|
24
24
|
</colgroup>
|
25
25
|
<thead data-hook="admin_social_methods_index_headers">
|
26
|
-
<th><%=
|
27
|
-
<th><%=
|
28
|
-
<th><%=
|
29
|
-
<th><%=
|
30
|
-
<th><%=
|
26
|
+
<th><%= I18n.t('spree.social_provider') %></th>
|
27
|
+
<th><%= I18n.t('spree.social_api_key') %></th>
|
28
|
+
<th><%= I18n.t('spree.social_api_secret') %></th>
|
29
|
+
<th><%= I18n.t('spree.environment') %></th>
|
30
|
+
<th><%= I18n.t('spree.active') %></th>
|
31
31
|
<th data-hook="admin_social_methods_index_header_actions" class="actions"></th>
|
32
32
|
</thead>
|
33
33
|
<tbody>
|
@@ -37,7 +37,7 @@
|
|
37
37
|
<td class="align-center"><%= truncate method.api_key, length: 10 %></td>
|
38
38
|
<td class="align-center"><%= truncate method.api_secret, length: 10 %></td>
|
39
39
|
<td class="align-center"><%= method.environment.to_s.titleize %></td>
|
40
|
-
<td class="align-center"><%= method.active ?
|
40
|
+
<td class="align-center"><%= method.active ? I18n.t('spree.yes') : I18n.t('spree.no') %></td>
|
41
41
|
<td class="actions">
|
42
42
|
<%= link_to_edit method, no_text: true %>
|
43
43
|
<%= link_to_delete method, no_text: true %>
|
@@ -48,7 +48,7 @@
|
|
48
48
|
</table>
|
49
49
|
<% else %>
|
50
50
|
<div class="alpha twelve columns no-objects-found">
|
51
|
-
<%=
|
52
|
-
<%=
|
51
|
+
<%= I18n.t('spree.no_authentication_methods_found') %>,
|
52
|
+
<%= I18n.t('spree.add_one') %>!
|
53
53
|
</div>
|
54
54
|
<% end %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<%= render 'spree/admin/shared/configuration_menu' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%=
|
4
|
+
<%= I18n.t('spree.new_social_method') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<% content_for :page_actions do %>
|
8
|
-
<li><%= link_to_with_icon 'icon-arrow-left',
|
8
|
+
<li><%= link_to_with_icon 'icon-arrow-left', I18n.t('spree.back_to_authentication_methods_list'), admin_authentication_methods_path, class: 'button' %></li>
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
<%= render 'spree/shared/error_messages', target: @authentication_method %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<div id="social-signin-links">
|
2
2
|
<% if (!spree_current_user || !spree_current_user.user_authentications) && Spree::AuthenticationMethod.active_authentication_methods? %>
|
3
|
-
<h2><%=
|
3
|
+
<h2><%= I18n.t('spree.sign_in_through_one_of_these_services') %></h2>
|
4
4
|
<% end %>
|
5
|
-
|
5
|
+
|
6
6
|
<% Spree::AuthenticationMethod.available_for(spree_current_user).each do |method| %>
|
7
|
-
<%= link_to(content_tag(:i, '', class: "icon-spree-#{method.provider.
|
8
|
-
spree.send("spree_user_#{method.provider}_omniauth_authorize_path"),
|
9
|
-
title:
|
7
|
+
<%= link_to(content_tag(:i, '', class: "icon-spree-#{method.provider.dasherize}-circled"),
|
8
|
+
spree.send("spree_user_#{method.provider}_omniauth_authorize_path", r: rand),
|
9
|
+
title: t('spree.sign_in_with', provider: method.provider)) if method.active %>
|
10
10
|
<% end %>
|
11
11
|
</div>
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<p>
|
2
|
-
<%= f.label :email,
|
2
|
+
<%= f.label :email, I18n.t('spree.email') %><br />
|
3
3
|
<%= f.email_field :email, class: 'title' %>
|
4
4
|
</p>
|
5
5
|
<% if spree_current_user.nil? || spree_current_user.password_required? %>
|
6
6
|
<div id="password-credentials">
|
7
7
|
<p>
|
8
|
-
<%= f.label :password,
|
8
|
+
<%= f.label :password, I18n.t('spree.password') %><br />
|
9
9
|
<%= f.password_field :password, class: 'title' %>
|
10
10
|
</p>
|
11
11
|
|
12
12
|
<p>
|
13
|
-
<%= f.label :password_confirmation,
|
13
|
+
<%= f.label :password_confirmation, I18n.t('spree.confirm_password') %><br />
|
14
14
|
<%= f.password_field :password_confirmation, class: 'title' %>
|
15
15
|
</p>
|
16
16
|
</div>
|
@@ -3,25 +3,25 @@
|
|
3
3
|
<div id="existing-customer">
|
4
4
|
<% if spree_current_user.user_authentications %>
|
5
5
|
<% unless spree_current_user.user_authentications.empty? %>
|
6
|
-
<p><strong><%=
|
6
|
+
<p><strong><%= I18n.t('spree.you_have_signed_in_with_these_services') %>:</strong></p>
|
7
7
|
<div class="authentications">
|
8
8
|
<% for user_authentication in spree_current_user.user_authentications %>
|
9
9
|
<div class="authentication">
|
10
10
|
<div class="provider columns two">
|
11
|
-
<%= content_tag(:i, '', class: "icon-spree-#{user_authentication.provider.
|
11
|
+
<%= content_tag(:i, '', class: "icon-spree-#{user_authentication.provider.dasherize}-circled columns") %>
|
12
12
|
<%= user_authentication.provider %>
|
13
13
|
</div>
|
14
14
|
<div class="uid columns two"><%= user_authentication.uid %></div>
|
15
|
-
<%= link_to 'X', user_authentication, data: { confirm:
|
15
|
+
<%= link_to 'X', user_authentication, data: { confirm: I18n.t('spree.remove_authentication_option_confirmation') }, method: :delete, class: 'remove' %>
|
16
16
|
</div>
|
17
17
|
<% end %>
|
18
18
|
<div class="clear"></div>
|
19
19
|
</div>
|
20
20
|
<% end %>
|
21
21
|
<% end %>
|
22
|
-
|
22
|
+
|
23
23
|
<% if Spree::AuthenticationMethod.available_for(spree_current_user).present? %>
|
24
|
-
<%= content_tag(:p, content_tag(:strong,
|
24
|
+
<%= content_tag(:p, content_tag(:strong, I18n.t('spree.add_another_service'))) %>
|
25
25
|
<%= render 'spree/shared/social' %>
|
26
26
|
<% end %>
|
27
27
|
</div>
|
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "solidus_social"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
# require "pry"
|
14
|
+
# Pry.start
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/rails
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
ENGINE_PATH = File.expand_path('../../lib/solidus_social/engine', __FILE__)
|
3
|
+
# frozen_string_literal: true
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
app_root = 'sandbox'
|
6
|
+
|
7
|
+
unless File.exist? "#{app_root}/bin/rails"
|
8
|
+
warn 'Creating the sandbox app...'
|
9
|
+
Dir.chdir "#{__dir__}/.." do
|
10
|
+
system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
|
11
|
+
warn 'Automatic creation of the sandbox app failed'
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.chdir app_root
|
18
|
+
exec 'bin/rails', *ARGV
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
case "$DB" in
|
6
|
+
postgres|postgresql)
|
7
|
+
RAILSDB="postgresql"
|
8
|
+
;;
|
9
|
+
mysql)
|
10
|
+
RAILSDB="mysql"
|
11
|
+
;;
|
12
|
+
sqlite|'')
|
13
|
+
RAILSDB="sqlite3"
|
14
|
+
;;
|
15
|
+
*)
|
16
|
+
echo "Invalid DB specified: $DB"
|
17
|
+
exit 1
|
18
|
+
;;
|
19
|
+
esac
|
20
|
+
|
21
|
+
extension_name="solidus_social"
|
22
|
+
|
23
|
+
# Stay away from the bundler env of the containing extension.
|
24
|
+
function unbundled {
|
25
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
26
|
+
}
|
27
|
+
|
28
|
+
rm -rf ./sandbox
|
29
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
30
|
+
--skip-bundle \
|
31
|
+
--skip-git \
|
32
|
+
--skip-keeps \
|
33
|
+
--skip-rc \
|
34
|
+
--skip-spring \
|
35
|
+
--skip-test \
|
36
|
+
--skip-javascript
|
37
|
+
|
38
|
+
if [ ! -d "sandbox" ]; then
|
39
|
+
echo 'sandbox rails application failed'
|
40
|
+
exit 1
|
41
|
+
fi
|
42
|
+
|
43
|
+
cd ./sandbox
|
44
|
+
cat <<RUBY >> Gemfile
|
45
|
+
|
46
|
+
gem '$extension_name', path: '..'
|
47
|
+
gem 'solidus_auth_devise', '>= 2.1.0'
|
48
|
+
gem 'rails-i18n'
|
49
|
+
gem 'solidus_i18n'
|
50
|
+
|
51
|
+
group :test, :development do
|
52
|
+
platforms :mri do
|
53
|
+
gem 'pry-byebug'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
RUBY
|
57
|
+
|
58
|
+
unbundled bundle install --gemfile Gemfile
|
59
|
+
|
60
|
+
unbundled bundle exec rake db:drop db:create
|
61
|
+
|
62
|
+
unbundled bundle exec rails generate spree:install \
|
63
|
+
--auto-accept \
|
64
|
+
--user_class=Spree::User \
|
65
|
+
--enforce_available_locales=true \
|
66
|
+
$@
|
67
|
+
|
68
|
+
unbundled bundle exec rails generate solidus:auth:install
|
69
|
+
|
70
|
+
echo
|
71
|
+
echo "🚀 Sandbox app successfully created for $extension_name!"
|
72
|
+
echo "🚀 This app is intended for test purposes."
|