solidus_auth_devise 1.0.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Gemfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +88 -0
- data/Rakefile +21 -0
- data/app/controllers/metal_decorator.rb +6 -0
- data/app/mailers/spree/user_mailer.rb +15 -0
- data/app/models/spree/auth_configuration.rb +7 -0
- data/app/models/spree/user.rb +50 -0
- data/app/overrides/auth_shared_login_bar.rb +7 -0
- data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +4 -0
- data/bin/rails +7 -0
- data/config/initializers/devise.rb +137 -0
- data/config/initializers/warden.rb +14 -0
- data/config/locales/de.yml +49 -0
- data/config/locales/en.yml +55 -0
- data/config/locales/es.yml +49 -0
- data/config/locales/fr.yml +49 -0
- data/config/locales/it.yml +76 -0
- data/config/locales/nl.yml +49 -0
- data/config/locales/pt-BR.yml +51 -0
- data/config/locales/tr.yml +49 -0
- data/config/routes.rb +48 -0
- data/db/default/users.rb +83 -0
- data/db/migrate/20101026184949_create_users.rb +29 -0
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +37 -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 +5 -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 +26 -0
- data/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +20 -0
- data/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb +3 -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 +45 -0
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +47 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +47 -0
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +21 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +53 -0
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +72 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +53 -0
- data/lib/controllers/frontend/spree/users_controller.rb +57 -0
- data/lib/generators/spree/auth/install/install_generator.rb +26 -0
- data/lib/generators/spree/auth/install/templates/config/initializers/devise.rb +1 -0
- data/lib/solidus/auth.rb +2 -0
- data/lib/solidus_auth_devise.rb +5 -0
- data/lib/spree/auth/devise.rb +20 -0
- data/lib/spree/auth/engine.rb +77 -0
- data/lib/spree/authentication_helpers.rb +26 -0
- data/lib/tasks/auth.rake +9 -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 +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 +42 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +14 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +141 -0
- data/spec/controllers/spree/products_controller_spec.rb +21 -0
- data/spec/controllers/spree/user_passwords_controller_spec.rb +44 -0
- data/spec/controllers/spree/user_registrations_controller_spec.rb +13 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +56 -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 +29 -0
- data/spec/features/admin/password_reset_spec.rb +24 -0
- data/spec/features/admin/payment_methods_spec.rb +16 -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 +24 -0
- data/spec/features/checkout_spec.rb +165 -0
- data/spec/features/confirmation_spec.rb +28 -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 +58 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/ability.rb +15 -0
- data/spec/support/authentication_helpers.rb +14 -0
- data/spec/support/capybara.rb +7 -0
- data/spec/support/confirm_helpers.rb +11 -0
- data/spec/support/database_cleaner.rb +18 -0
- data/spec/support/email.rb +5 -0
- data/spec/support/factory_girl.rb +5 -0
- data/spec/support/spree.rb +26 -0
- metadata +452 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
|
|
2
|
+
|
|
3
|
+
<div id="forgot-password">
|
|
4
|
+
<h6><%= Spree.t(:forgot_password) %></h6>
|
|
5
|
+
|
|
6
|
+
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
|
7
|
+
|
|
8
|
+
<%= form_for Spree::User.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
|
|
9
|
+
<p>
|
|
10
|
+
<%= f.label :email, Spree.t(:email) %><br />
|
|
11
|
+
<%= f.email_field :email %>
|
|
12
|
+
</p>
|
|
13
|
+
<p>
|
|
14
|
+
<%= f.submit Spree.t(:reset_password), :class => 'button primary' %>
|
|
15
|
+
</p>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<% if flash[:alert] %>
|
|
2
|
+
<div class="flash errors"><%= flash[:alert] %></div>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<% @body_id = 'login' %>
|
|
6
|
+
<div id="existing-customer">
|
|
7
|
+
<h6><%= Spree.t(:admin_login) %></h6>
|
|
8
|
+
<div data-hook="login">
|
|
9
|
+
<%= form_for Spree::User.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
|
|
10
|
+
<div id="password-credentials">
|
|
11
|
+
<p>
|
|
12
|
+
<%= f.label :email, Spree.t(:email) %><br />
|
|
13
|
+
<%= f.email_field :email, :class => 'title', :tabindex => 1 %>
|
|
14
|
+
</p>
|
|
15
|
+
<p>
|
|
16
|
+
<%= f.label :password, Spree.t(:password) %><br />
|
|
17
|
+
<%= f.password_field :password, :class => 'title', :tabindex => 2 %>
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
20
|
+
<p>
|
|
21
|
+
<%= f.check_box :remember_me, :tabindex => 3 %>
|
|
22
|
+
<%= f.label :remember_me, Spree.t(:remember_me) %>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p><%= f.submit Spree.t(:login), :class => 'button primary', :tabindex => 4 %></p>
|
|
26
|
+
<% end %>
|
|
27
|
+
<%= Spree.t(:or) %>
|
|
28
|
+
<%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div data-hook="login_extras"></div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% if spree_current_user %>
|
|
2
|
+
<ul id="login-nav" class="inline-menu">
|
|
3
|
+
<li data-hook="user-logged-in-as"><%= Spree.t(:logged_in_as) %>: <%= spree_current_user.email %></li>
|
|
4
|
+
<li data-hook="user-account-link" class='fa fa-user'><%= link_to Spree.t(:account), spree.edit_user_path(spree_current_user) %></li>
|
|
5
|
+
<li data-hook="user-logout-link" class='fa fa-sign-out'><%= link_to Spree.t(:logout), spree.admin_logout_path %></li>
|
|
6
|
+
|
|
7
|
+
<% if spree.respond_to? :root_path %>
|
|
8
|
+
<li data-hook="store-frontend-link" class='fa fa-external-link'>
|
|
9
|
+
<%= link_to Spree.t(:back_to_store), spree.root_path, :target => '_blank' %>
|
|
10
|
+
</li>
|
|
11
|
+
<% end %>
|
|
12
|
+
</ul>
|
|
13
|
+
<% end %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
|
|
2
|
+
<h1><%= Spree.t(:registration) %></h1>
|
|
3
|
+
<div id="registration" data-hook>
|
|
4
|
+
<div id="account" class="columns alpha eight">
|
|
5
|
+
<%= render template: 'spree/user_sessions/new' %>
|
|
6
|
+
</div>
|
|
7
|
+
<% if Spree::Config[:allow_guest_checkout] %>
|
|
8
|
+
<div id="guest_checkout" data-hook class="columns omega eight">
|
|
9
|
+
<h6><%= Spree.t(:guest_user_account) %></h6>
|
|
10
|
+
<% if flash[:registration_error] %>
|
|
11
|
+
<div class='flash error'><%= flash[:registration_error] %></div>
|
|
12
|
+
<% end %>
|
|
13
|
+
<%= form_for @order, :url => update_checkout_registration_path, :method => :put, :html => { :id => 'checkout_form_registration' } do |f| %>
|
|
14
|
+
<p>
|
|
15
|
+
<%= f.label :email, Spree.t(:email) %><br />
|
|
16
|
+
<%= f.email_field :email, :class => 'title' %>
|
|
17
|
+
</p>
|
|
18
|
+
<p><%= f.submit Spree.t(:continue), :class => 'button primary' %></p>
|
|
19
|
+
<% end %>
|
|
20
|
+
</div>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%= form_for Spree::User.new, :as => :spree_user, :url => spree.create_new_session_path do |f| %>
|
|
2
|
+
<div id="password-credentials">
|
|
3
|
+
<p>
|
|
4
|
+
<%= f.label :email, Spree.t(:email) %><br />
|
|
5
|
+
<%= f.email_field :email, :class => 'title', :tabindex => 1, autofocus: true %>
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
<%= f.label :password, Spree.t(:password) %><br />
|
|
9
|
+
<%= f.password_field :password, :class => 'title', :tabindex => 2 %>
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
12
|
+
<p>
|
|
13
|
+
<%= f.check_box :remember_me, :tabindex => 3 %>
|
|
14
|
+
<%= f.label :remember_me, Spree.t(:remember_me) %>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p><%= f.submit Spree.t(:login), :class => 'button primary', :tabindex => 4 %></p>
|
|
18
|
+
<% end %>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<p>
|
|
2
|
+
<%= f.label :email, Spree.t(:email) %><br />
|
|
3
|
+
<%= f.email_field :email, :class => 'title' %>
|
|
4
|
+
</p>
|
|
5
|
+
<div id="password-credentials">
|
|
6
|
+
<p>
|
|
7
|
+
<%= f.label :password, Spree.t(:password) %><br />
|
|
8
|
+
<%= f.password_field :password, :class => 'title' %>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p>
|
|
12
|
+
<%= f.label :password_confirmation, Spree.t(:confirm_password) %><br />
|
|
13
|
+
<%= f.password_field :password_confirmation, :class => 'title' %>
|
|
14
|
+
</p>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div data-hook="signup_below_password_fields"></div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
A request to reset your password has been made.
|
|
2
|
+
If you did not make this request, simply ignore this email.
|
|
3
|
+
|
|
4
|
+
If you did make this request just click the link below:
|
|
5
|
+
|
|
6
|
+
<%= @edit_password_reset_url %>
|
|
7
|
+
|
|
8
|
+
If the above URL does not work try copying and pasting it into your browser.
|
|
9
|
+
If you continue to have problems please feel free to contact us.
|
|
10
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
|
|
2
|
+
<div id="change-password">
|
|
3
|
+
<h6><%= Spree.t(:change_my_password) %></h6>
|
|
4
|
+
|
|
5
|
+
<%= form_for @spree_user, :as => :spree_user, :url => spree.update_password_path, :method => :put do |f| %>
|
|
6
|
+
<p>
|
|
7
|
+
<%= f.label :password, Spree.t(:password) %><br />
|
|
8
|
+
<%= f.password_field :password %><br />
|
|
9
|
+
</p>
|
|
10
|
+
<p>
|
|
11
|
+
<%= f.label :password_confirmation, Spree.t(:confirm_password) %><br />
|
|
12
|
+
<%= f.password_field :password_confirmation %><br />
|
|
13
|
+
</p>
|
|
14
|
+
<%= f.hidden_field :reset_password_token %>
|
|
15
|
+
<%= f.submit Spree.t(:update), :class => 'button primary' %>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
|
|
2
|
+
|
|
3
|
+
<div id="forgot-password">
|
|
4
|
+
<h6><%= Spree.t(:forgot_password) %></h6>
|
|
5
|
+
|
|
6
|
+
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
|
7
|
+
|
|
8
|
+
<%= form_for Spree::User.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
|
|
9
|
+
<p>
|
|
10
|
+
<%= f.label :email, Spree.t(:email) %><br />
|
|
11
|
+
<%= f.email_field :email %>
|
|
12
|
+
</p>
|
|
13
|
+
<p>
|
|
14
|
+
<%= f.submit Spree.t(:reset_password), :class => 'button primary' %>
|
|
15
|
+
</p>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% @body_id = 'signup' %>
|
|
2
|
+
|
|
3
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
|
|
4
|
+
|
|
5
|
+
<div id="new-customer">
|
|
6
|
+
<h6><%= Spree.t(:new_customer) %></h6>
|
|
7
|
+
|
|
8
|
+
<div data-hook="signup">
|
|
9
|
+
<%= form_for resource, :as => :spree_user, :url => spree.registration_path(@user) do |f| %>
|
|
10
|
+
<div data-hook="signup_inside_form">
|
|
11
|
+
<%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
|
|
12
|
+
<p><%= f.submit Spree.t(:create), :class => 'button primary' %></p>
|
|
13
|
+
</div>
|
|
14
|
+
<% end %>
|
|
15
|
+
<%= Spree.t(:or) %> <%= link_to Spree.t(:login_as_existing), spree.login_path %>
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div data-hook="login_extras"></div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% if flash[:alert] %>
|
|
2
|
+
<div class="flash errors"><%= flash[:alert] %></div>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<% @body_id = 'login' %>
|
|
6
|
+
<div id="existing-customer">
|
|
7
|
+
<h6><%= Spree.t(:login_as_existing) %></h6>
|
|
8
|
+
<div data-hook="login">
|
|
9
|
+
<%= render :partial => 'spree/shared/login' %>
|
|
10
|
+
<%= Spree.t(:or) %> <%= link_to Spree.t(:create_a_new_account), spree.signup_path %> | <%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div data-hook="login_extras"></div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
|
|
2
|
+
|
|
3
|
+
<div id="edit-account">
|
|
4
|
+
<h1><%= Spree.t(:editing_user) %></h1>
|
|
5
|
+
|
|
6
|
+
<div data-hook="account_edit">
|
|
7
|
+
<%= form_for Spree::User.new, :as => @user, :url => spree.user_path(@user), :method => :put do |f| %>
|
|
8
|
+
<%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
|
|
9
|
+
<p>
|
|
10
|
+
<%= f.submit Spree.t(:update), :class => 'button primary' %>
|
|
11
|
+
</p>
|
|
12
|
+
<% end %>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<h1><%= accurate_title %></h1>
|
|
2
|
+
|
|
3
|
+
<div data-hook="account_summary" class="account-summary">
|
|
4
|
+
<dl id="user-info">
|
|
5
|
+
<dt><%= Spree.t(:email) %></dt>
|
|
6
|
+
<dd><%= @user.email %> (<%= link_to Spree.t(:edit), spree.edit_account_path %>)</dd>
|
|
7
|
+
</dl>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div data-hook="account_my_orders" class="account-my-orders">
|
|
11
|
+
|
|
12
|
+
<h3><%= Spree.t(:my_orders) %></h3>
|
|
13
|
+
<% if @orders.present? %>
|
|
14
|
+
<table class="order-summary">
|
|
15
|
+
<thead>
|
|
16
|
+
<tr>
|
|
17
|
+
<th class="order-number"><%= I18n.t(:number, :scope => 'activerecord.attributes.spree/order') %></th>
|
|
18
|
+
<th class="order-date"><%= Spree.t(:date) %></th>
|
|
19
|
+
<th class="order-status"><%= Spree.t(:status) %></th>
|
|
20
|
+
<th class="order-payment-state"><%= Spree.t(:payment_state) %></th>
|
|
21
|
+
<th class="order-shipment-state"><%= Spree.t(:shipment_state) %></th>
|
|
22
|
+
<th class="order-total"><%= Spree.t(:total) %></th>
|
|
23
|
+
</tr>
|
|
24
|
+
</thead>
|
|
25
|
+
<tbody>
|
|
26
|
+
<% @orders.each do |order| %>
|
|
27
|
+
<tr class="<%= cycle('even', 'odd') %>">
|
|
28
|
+
<td class="order-number"><%= link_to order.number, order_url(order) %></td>
|
|
29
|
+
<td class="order-date"><%= l order.completed_at.to_date %></td>
|
|
30
|
+
<td class="order-status"><%= Spree.t("order_state.#{order.state}").titleize %></td>
|
|
31
|
+
<td class="order-payment-state"><%= Spree.t("payment_states.#{order.payment_state}").titleize if order.payment_state %></td>
|
|
32
|
+
<td class="order-shipment-state"><%= Spree.t("shipment_states.#{order.shipment_state}").titleize if order.shipment_state %></td>
|
|
33
|
+
<td class="order-total"><%= order.display_total %></td>
|
|
34
|
+
</tr>
|
|
35
|
+
<% end %>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
<% else %>
|
|
39
|
+
<p><%= Spree.t(:you_have_no_orders_yet) %></p>
|
|
40
|
+
<% end %>
|
|
41
|
+
<br />
|
|
42
|
+
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.platform = Gem::Platform::RUBY
|
|
5
|
+
s.name = "solidus_auth_devise"
|
|
6
|
+
s.version = "1.0.0"
|
|
7
|
+
s.summary = "Provides authentication and authorization services for use with Solidus by using Devise and CanCan."
|
|
8
|
+
s.description = s.summary
|
|
9
|
+
|
|
10
|
+
s.author = 'Solidus Team'
|
|
11
|
+
s.email = 'contact@solidus.io'
|
|
12
|
+
|
|
13
|
+
s.required_ruby_version = ">= 2.1"
|
|
14
|
+
s.license = %q{BSD-3}
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
18
|
+
s.require_path = "lib"
|
|
19
|
+
s.requirements << "none"
|
|
20
|
+
|
|
21
|
+
solidus_version = [">= 1.0.0.pre", "< 2"]
|
|
22
|
+
|
|
23
|
+
s.add_dependency "solidus_core", solidus_version
|
|
24
|
+
s.add_dependency "devise", "~> 3.2.3"
|
|
25
|
+
s.add_dependency "devise-encryptable", "0.1.2"
|
|
26
|
+
|
|
27
|
+
s.add_dependency "json"
|
|
28
|
+
s.add_dependency "multi_json"
|
|
29
|
+
|
|
30
|
+
s.add_development_dependency "solidus_backend", solidus_version
|
|
31
|
+
s.add_development_dependency "solidus_frontend", solidus_version
|
|
32
|
+
s.add_development_dependency "rspec-rails", "~> 3.0.0"
|
|
33
|
+
s.add_development_dependency "simplecov", "~> 0.9.0"
|
|
34
|
+
s.add_development_dependency "sqlite3"
|
|
35
|
+
s.add_development_dependency "sass-rails", "~> 4.0.0"
|
|
36
|
+
s.add_development_dependency "coffee-rails", "~> 4.0.0"
|
|
37
|
+
s.add_development_dependency "shoulda-matchers", "~> 2.6.2"
|
|
38
|
+
s.add_development_dependency "factory_girl", "~> 4.4"
|
|
39
|
+
s.add_development_dependency "capybara", "~> 2.4.1"
|
|
40
|
+
s.add_development_dependency "poltergeist", "~> 1.5"
|
|
41
|
+
s.add_development_dependency "database_cleaner", "~> 1.2.0"
|
|
42
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
RSpec.describe OrdersController, type: :controller do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
context '#authorize_admin' do
|
|
7
|
+
it 'grants access to users with an admin role' do
|
|
8
|
+
spree_get :new
|
|
9
|
+
expect(response).to redirect_to spree.edit_admin_order_path(Order.last)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
RSpec.describe Spree::CheckoutController, type: :controller do
|
|
2
|
+
|
|
3
|
+
let(:order) { create(:order_with_line_items, email: nil, user: nil) }
|
|
4
|
+
let(:user) { build(:user, spree_api_key: 'fake') }
|
|
5
|
+
let(:token) { 'some_token' }
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
allow(controller).to receive(:current_order) { order }
|
|
9
|
+
allow(order).to receive(:confirmation_required?) { true }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context '#edit' do
|
|
13
|
+
context 'when registration step enabled' do
|
|
14
|
+
before do
|
|
15
|
+
allow(controller).to receive(:check_authorization)
|
|
16
|
+
Spree::Auth::Config.set(registration_step: true)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context 'when authenticated as registered user' do
|
|
20
|
+
before { allow(controller).to receive(:spree_current_user) { user } }
|
|
21
|
+
|
|
22
|
+
it 'proceeds to the first checkout step' do
|
|
23
|
+
spree_get :edit, { state: 'address' }
|
|
24
|
+
expect(response).to render_template :edit
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'when authenticated as guest' do
|
|
29
|
+
it 'redirects to registration step' do
|
|
30
|
+
spree_get :edit, { state: 'address' }
|
|
31
|
+
expect(response).to redirect_to spree.checkout_registration_path
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'when registration step disabled' do
|
|
37
|
+
before do
|
|
38
|
+
Spree::Auth::Config.set(registration_step: false)
|
|
39
|
+
allow(controller).to receive(:check_authorization)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'when authenticated as registered' do
|
|
43
|
+
before { allow(controller).to receive(:spree_current_user) { user } }
|
|
44
|
+
|
|
45
|
+
it 'proceeds to the first checkout step' do
|
|
46
|
+
spree_get :edit, { state: 'address' }
|
|
47
|
+
expect(response).to render_template :edit
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context 'when authenticated as guest' do
|
|
52
|
+
it 'proceeds to the first checkout step' do
|
|
53
|
+
spree_get :edit, { state: 'address' }
|
|
54
|
+
expect(response).to render_template :edit
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context '#update' do
|
|
61
|
+
context 'when in the confirm state' do
|
|
62
|
+
before do
|
|
63
|
+
order.update_column(:email, 'spree@example.com')
|
|
64
|
+
order.update_column(:state, 'confirm')
|
|
65
|
+
|
|
66
|
+
# So that the order can transition to complete successfully
|
|
67
|
+
allow(order).to receive(:payment_required?) { false }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'with a token' do
|
|
71
|
+
before { allow(order).to receive(:guest_token) { 'ABC' } }
|
|
72
|
+
|
|
73
|
+
it 'redirects to the tokenized order view' do
|
|
74
|
+
request.cookie_jar.signed[:guest_token] = 'ABC'
|
|
75
|
+
spree_post :update, { state: 'confirm' }
|
|
76
|
+
expect(response).to redirect_to spree.token_order_path(order, 'ABC')
|
|
77
|
+
expect(flash.notice).to eq Spree.t(:order_processed_successfully)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'with a registered user' do
|
|
82
|
+
before do
|
|
83
|
+
allow(controller).to receive(:spree_current_user) { user }
|
|
84
|
+
allow(order).to receive(:user) { user }
|
|
85
|
+
allow(order).to receive(:guest_token) { nil }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'redirects to the standard order view' do
|
|
89
|
+
spree_post :update, { state: 'confirm' }
|
|
90
|
+
expect(response).to redirect_to spree.order_path(order)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context '#registration' do
|
|
97
|
+
it 'does not check registration' do
|
|
98
|
+
allow(controller).to receive(:check_authorization)
|
|
99
|
+
expect(controller).not_to receive(:check_registration)
|
|
100
|
+
spree_get :registration
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'checks if the user is authorized for :edit' do
|
|
104
|
+
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
|
105
|
+
request.cookie_jar.signed[:guest_token] = token
|
|
106
|
+
spree_get :registration, {}
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context '#update_registration' do
|
|
111
|
+
let(:user) { build(:user) }
|
|
112
|
+
|
|
113
|
+
it 'does not check registration' do
|
|
114
|
+
controller.stub :check_authorization
|
|
115
|
+
order.stub update_attributes: true
|
|
116
|
+
controller.should_not_receive :check_registration
|
|
117
|
+
spree_put :update_registration, { order: { } }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'renders the registration view if unable to save' do
|
|
121
|
+
allow(controller).to receive(:check_authorization)
|
|
122
|
+
spree_put :update_registration, { order: { email: 'invalid' } }
|
|
123
|
+
expect(flash[:registration_error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages])
|
|
124
|
+
expect(response).to render_template :registration
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'redirects to the checkout_path after saving' do
|
|
128
|
+
allow(order).to receive(:update_attributes) { true }
|
|
129
|
+
allow(controller).to receive(:check_authorization)
|
|
130
|
+
spree_put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
|
|
131
|
+
expect(response).to redirect_to spree.checkout_path
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'checks if the user is authorized for :edit' do
|
|
135
|
+
request.cookie_jar.signed[:guest_token] = token
|
|
136
|
+
allow(order).to receive(:update_attributes) { true }
|
|
137
|
+
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
|
138
|
+
spree_put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|