From 1e906903a9efa77c41966a92e642c9f89e7102ab Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 13:55:04 +0200 Subject: [PATCH 1/8] We're not using Circle CI anymore --- circle.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 circle.yml diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 7f49f13f3..000000000 --- a/circle.yml +++ /dev/null @@ -1,13 +0,0 @@ -machine: - environment: - DB: postgres - services: - - postgresql - ruby: - version: '2.2.4' - -dependencies: - pre: - - gem install bundler - post: - - bundle exec rake test_app From 64e4e769615e424d15602d92087af74361826b7d Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 13:56:43 +0200 Subject: [PATCH 2/8] Removing unused Versionfile --- Versionfile | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Versionfile diff --git a/Versionfile b/Versionfile deleted file mode 100644 index ed3182e5d..000000000 --- a/Versionfile +++ /dev/null @@ -1,5 +0,0 @@ -"2.2.x" => { :branch => "2-2-stable" } -"2.1.x" => { :branch => "2-1-stable" } -"2.0.x" => { :branch => "2-0-stable" } -"1.3.x" => { :branch => "1-3-stable" } -"1.2.x" => { :branch => "1-2-stable" } \ No newline at end of file From 12f70057cff018ca30bea1d9922eb250f1624bb4 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 13:57:07 +0200 Subject: [PATCH 3/8] Require ruby 2.2.7 --- spree_auth_devise.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spree_auth_devise.gemspec b/spree_auth_devise.gemspec index e6cfcb690..b8da0f116 100644 --- a/spree_auth_devise.gemspec +++ b/spree_auth_devise.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |s| s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.' s.description = s.summary - s.required_ruby_version = '>= 2.2.2' + s.required_ruby_version = '>= 2.2.7' s.author = 'Sean Schofield' s.email = 'sean@spreecommerce.com' From 1e240247f607bd5b2980b798f636092400e735d9 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 14:13:10 +0200 Subject: [PATCH 4/8] rubocop -a --- Rakefile | 2 +- app/mailers/spree/user_mailer.rb | 12 +++---- app/models/spree/auth_configuration.rb | 6 ++-- app/models/spree/user.rb | 33 ++++++++--------- app/overrides/auth_shared_login_bar.rb | 13 ++++--- config.ru | 2 +- config/initializers/devise.rb | 2 +- config/initializers/warden.rb | 4 +-- config/routes.rb | 35 +++++++++---------- db/default/users.rb | 10 +++--- db/migrate/20101026184949_create_users.rb | 14 ++++---- ...605211305_make_users_email_index_unique.rb | 4 +-- .../spree/admin/admin_controller_decorator.rb | 14 ++++---- .../admin_orders_controller_decorator.rb | 29 +++++++-------- .../admin_resource_controller_decorator.rb | 2 +- .../customer_details_controller_decorator.rb | 17 ++++----- .../spree/admin/user_passwords_controller.rb | 3 +- .../spree/admin/user_sessions_controller.rb | 34 +++++++++--------- .../spree/checkout_controller_decorator.rb | 33 ++++++++--------- .../spree/user_confirmations_controller.rb | 1 - .../spree/user_passwords_controller.rb | 2 +- .../spree/user_sessions_controller.rb | 23 ++++++------ .../frontend/spree/users_controller.rb | 31 ++++++++-------- .../spree/auth/install/install_generator.rb | 2 +- lib/spree/auth/devise.rb | 2 +- lib/spree/auth/engine.rb | 10 +++--- lib/tasks/auth.rake | 2 +- .../spree/checkout_controller_spec.rb | 3 +- .../spree/products_controller_spec.rb | 1 - .../spree/user_passwords_controller_spec.rb | 5 ++- .../user_registrations_controller_spec.rb | 1 - .../spree/user_sessions_controller_spec.rb | 1 - .../spree/users_controller_spec.rb | 1 - spec/factories/confirmed_user.rb | 2 +- spec/features/account_spec.rb | 1 - spec/features/admin/orders_spec.rb | 1 - spec/features/admin/password_reset_spec.rb | 1 - spec/features/admin/products_spec.rb | 1 - spec/features/admin/sign_in_spec.rb | 1 - spec/features/admin/sign_out_spec.rb | 1 - spec/features/admin_permissions_spec.rb | 1 - spec/features/change_email_spec.rb | 1 - spec/features/checkout_spec.rb | 16 ++++----- spec/features/confirmation_spec.rb | 2 +- spec/features/order_spec.rb | 1 - spec/features/password_reset_spec.rb | 1 - spec/features/sign_in_spec.rb | 1 - spec/features/sign_out_spec.rb | 1 - spec/features/sign_up_spec.rb | 1 - spec/mailers/user_mailer_spec.rb | 1 - spec/models/order_spec.rb | 1 - spec/models/user_spec.rb | 1 - spec/support/ability.rb | 2 +- spec/support/authentication_helpers.rb | 2 +- spec/support/capybara.rb | 2 +- spec/support/confirm_helpers.rb | 2 +- spec/support/database_cleaner.rb | 1 - spree_auth_devise.gemspec | 2 +- 58 files changed, 189 insertions(+), 212 deletions(-) diff --git a/Rakefile b/Rakefile index b8a1ab480..d0a87beb4 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ require 'spree/testing_support/common_rake' RSpec::Core::RakeTask.new -task :default => :spec +task default: :spec desc 'Generates a dummy app for testing' task :test_app do diff --git a/app/mailers/spree/user_mailer.rb b/app/mailers/spree/user_mailer.rb index 9350d4642..41f088ed4 100644 --- a/app/mailers/spree/user_mailer.rb +++ b/app/mailers/spree/user_mailer.rb @@ -1,16 +1,16 @@ module Spree class UserMailer < BaseMailer - def reset_password_instructions(user, token, *args) - @edit_password_reset_url = spree.edit_spree_user_password_url(:reset_password_token => token, :host => Spree::Store.current.url) + def reset_password_instructions(user, token, *_args) + @edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: Spree::Store.current.url) - mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :reset_password_instructions]) + mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]) end - def confirmation_instructions(user, token, opts={}) - @confirmation_url = spree.spree_user_confirmation_url(:confirmation_token => token, :host => Spree::Store.current.url) + def confirmation_instructions(user, token, _opts = {}) + @confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: Spree::Store.current.url) @email = user.email - mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :confirmation_instructions]) + mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions]) end end end diff --git a/app/models/spree/auth_configuration.rb b/app/models/spree/auth_configuration.rb index cef022f86..55bbb8018 100644 --- a/app/models/spree/auth_configuration.rb +++ b/app/models/spree/auth_configuration.rb @@ -1,7 +1,7 @@ module Spree class AuthConfiguration < Preferences::Configuration - preference :registration_step, :boolean, :default => true - preference :signout_after_password_change, :boolean, :default => true - preference :confirmable, :boolean, :default => false + preference :registration_step, :boolean, default: true + preference :signout_after_password_change, :boolean, default: true + preference :confirmable, :boolean, default: false end end diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index 7ce20c689..52f686c71 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -5,7 +5,7 @@ class User < Spree::Base include UserPaymentSource devise :database_authenticatable, :registerable, :recoverable, - :rememberable, :trackable, :validatable, :encryptable, :encryptor => 'authlogic_sha512' + :rememberable, :trackable, :validatable, :encryptable, encryptor: 'authlogic_sha512' devise :confirmable if Spree::Auth::Config[:confirmable] acts_as_paranoid @@ -27,23 +27,24 @@ def admin? end protected - def password_required? - !persisted? || password.present? || password_confirmation.present? - end + + def password_required? + !persisted? || password.present? || password_confirmation.present? + end private - def set_login - # for now force login to be same as email, eventually we will make this configurable, etc. - self.login ||= self.email if self.email - end - - def scramble_email_and_password - self.email = SecureRandom.uuid + "@example.net" - self.login = self.email - self.password = SecureRandom.hex(8) - self.password_confirmation = self.password - self.save - end + def set_login + # for now force login to be same as email, eventually we will make this configurable, etc. + self.login ||= email if email + end + + def scramble_email_and_password + self.email = SecureRandom.uuid + "@example.net" + self.login = email + self.password = SecureRandom.hex(8) + self.password_confirmation = password + save + end end end diff --git a/app/overrides/auth_shared_login_bar.rb b/app/overrides/auth_shared_login_bar.rb index 86a5ce49d..5c79bf4f8 100644 --- a/app/overrides/auth_shared_login_bar.rb +++ b/app/overrides/auth_shared_login_bar.rb @@ -1,7 +1,6 @@ -Deface::Override.new(:virtual_path => "spree/shared/_nav_bar", - :name => "auth_shared_login_bar", - :insert_before => "li#search-bar", - :partial => "spree/shared/login_bar", - :disabled => false, - :original => 'c00d67dfc0496d21a351b48c41a728412cb5ed2c') - +Deface::Override.new(virtual_path: "spree/shared/_nav_bar", + name: "auth_shared_login_bar", + insert_before: "li#search-bar", + partial: "spree/shared/login_bar", + disabled: false, + original: 'c00d67dfc0496d21a351b48c41a728412cb5ed2c') diff --git a/config.ru b/config.ru index 034812541..940f9b42d 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../spec/dummy/config/environment', __FILE__) +require ::File.expand_path('../spec/dummy/config/environment', __FILE__) run Dummy::Application diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 69cc8b116..efdbcf611 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -29,7 +29,7 @@ config.http_authenticatable = true # Set this to true to use Basic Auth for AJAX requests. True by default. - #config.http_authenticatable_on_xhr = false + # config.http_authenticatable_on_xhr = false # The realm used in Http Basic Authentication config.http_authentication_realm = 'Spree Application' diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index f33f742ea..0debe511d 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -1,5 +1,5 @@ # Merges users orders to their account after sign in and sign up. -Warden::Manager.after_set_user except: :fetch do |user, auth, opts| +Warden::Manager.after_set_user except: :fetch do |user, auth, _opts| if auth.cookies.signed[:guest_token].present? if user.is_a?(Spree::User) Spree::Order.incomplete.where(guest_token: auth.cookies.signed[:guest_token], user_id: nil).each do |order| @@ -9,6 +9,6 @@ end end -Warden::Manager.before_logout do |user, auth, opts| +Warden::Manager.before_logout do |_user, auth, _opts| auth.cookies.delete :guest_token end diff --git a/config/routes.rb b/config/routes.rb index 3f71c951a..a45a87d62 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,15 +1,15 @@ Spree::Core::Engine.add_routes do devise_for :spree_user, - :class_name => 'Spree::User', - :controllers => { :sessions => 'spree/user_sessions', - :registrations => 'spree/user_registrations', - :passwords => 'spree/user_passwords', - :confirmations => 'spree/user_confirmations' }, - :skip => [:unlocks, :omniauth_callbacks], - :path_names => { :sign_out => 'logout' }, - :path_prefix => :user + class_name: 'Spree::User', + controllers: { sessions: 'spree/user_sessions', + registrations: 'spree/user_registrations', + passwords: 'spree/user_passwords', + confirmations: 'spree/user_confirmations' }, + skip: [:unlocks, :omniauth_callbacks], + path_names: { sign_out: 'logout' }, + path_prefix: :user - resources :users, :only => [:edit, :update] + resources :users, only: [:edit, :update] devise_scope :spree_user do get '/login' => 'user_sessions#new', :as => :login @@ -28,22 +28,21 @@ put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration get '/account_link' => 'store#account_link' - resource :account, :controller => 'users' + resource :account, controller: 'users' namespace :admin, path: Spree.admin_path do devise_for :spree_user, - :class_name => 'Spree::User', - :controllers => { :sessions => 'spree/admin/user_sessions', - :passwords => 'spree/admin/user_passwords' }, - :skip => [:unlocks, :omniauth_callbacks, :registrations], - :path_names => { :sign_out => 'logout' }, - :path_prefix => :user + class_name: 'Spree::User', + controllers: { sessions: 'spree/admin/user_sessions', + passwords: 'spree/admin/user_passwords' }, + skip: [:unlocks, :omniauth_callbacks, :registrations], + path_names: { sign_out: 'logout' }, + path_prefix: :user devise_scope :spree_user do - get '/authorization_failure', :to => 'user_sessions#authorization_failure', :as => :unauthorized + get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized get '/login' => 'user_sessions#new', :as => :login post '/login' => 'user_sessions#create', :as => :create_new_session get '/logout' => 'user_sessions#destroy', :as => :logout end - end end diff --git a/db/default/users.rb b/db/default/users.rb index 1b839d87c..32ebf97cf 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -39,15 +39,15 @@ def create_admin_user email = 'spree@example.com' else puts 'Create the admin user (press enter for defaults).' - #name = prompt_for_admin_name unless name + # name = prompt_for_admin_name unless name email = prompt_for_admin_email password = prompt_for_admin_password end attributes = { - :password => password, - :password_confirmation => password, - :email => email, - :login => email + password: password, + password_confirmation: password, + email: email, + login: email } load 'spree/user.rb' diff --git a/db/migrate/20101026184949_create_users.rb b/db/migrate/20101026184949_create_users.rb index 27a0b6414..161c0bcbd 100644 --- a/db/migrate/20101026184949_create_users.rb +++ b/db/migrate/20101026184949_create_users.rb @@ -6,17 +6,17 @@ class CreateUsers < ActiveRecord::Migration; end CreateUsers.class_eval do def up unless data_source_exists?("spree_users") - create_table "spree_users", :force => true do |t| - t.string "crypted_password", :limit => 128 - t.string "salt", :limit => 128 + create_table "spree_users", force: true do |t| + t.string "crypted_password", limit: 128 + t.string "salt", limit: 128 t.string "email" t.string "remember_token" t.string "remember_token_expires_at" t.string "persistence_token" t.string "single_access_token" t.string "perishable_token" - t.integer "login_count", :default => 0, :null => false - t.integer "failed_login_count", :default => 0, :null => false + t.integer "login_count", default: 0, null: false + t.integer "failed_login_count", default: 0, null: false t.datetime "last_request_at" t.datetime "current_login_at" t.datetime "last_login_at" @@ -25,8 +25,8 @@ def up t.string "login" t.integer "ship_address_id" t.integer "bill_address_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "openid_identifier" end end diff --git a/db/migrate/20120605211305_make_users_email_index_unique.rb b/db/migrate/20120605211305_make_users_email_index_unique.rb index f8d0deac2..6b091e3f9 100644 --- a/db/migrate/20120605211305_make_users_email_index_unique.rb +++ b/db/migrate/20120605211305_make_users_email_index_unique.rb @@ -5,10 +5,10 @@ class MakeUsersEmailIndexUnique < ActiveRecord::Migration; end end MakeUsersEmailIndexUnique.class_eval do def up - add_index "spree_users", ["email"], :name => "email_idx_unique", :unique => true + add_index "spree_users", ["email"], name: "email_idx_unique", unique: true end def down - remove_index "spree_users", :name => "email_idx_unique" + remove_index "spree_users", name: "email_idx_unique" end end diff --git a/lib/controllers/backend/spree/admin/admin_controller_decorator.rb b/lib/controllers/backend/spree/admin/admin_controller_decorator.rb index 5778475a0..d9a72ea3f 100644 --- a/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +++ b/lib/controllers/backend/spree/admin/admin_controller_decorator.rb @@ -1,5 +1,4 @@ Spree::Admin::BaseController.class_eval do - # Redirect as appropriate when an access request fails. The default action is to redirect to the login screen. # Override this method in your controllers if you want to have special behavior in case the user is not authorized # to access the requested action. For example, a popup window might simply close itself. @@ -15,12 +14,11 @@ def unauthorized protected - def model_class - const_name = controller_name.classify - if Spree.const_defined?(const_name, false) - return "Spree::#{const_name}".constantize - end - nil + def model_class + const_name = controller_name.classify + if Spree.const_defined?(const_name, false) + return "Spree::#{const_name}".constantize end - + nil + end end diff --git a/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb b/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb index 927c655c2..e938b77d6 100644 --- a/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +++ b/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb @@ -2,19 +2,20 @@ before_action :check_authorization private - def load_order_action - [:edit, :update, :cancel, :resume, :approve, :resend, :open_adjustments, :close_adjustments, :cart] - end - - def check_authorization - action = params[:action].to_sym - if load_order_action.include?(action) - load_order - session[:access_token] ||= params[:token] - resource = @order || Spree::Order.new - authorize! action, resource, session[:access_token] - else - authorize! :index, Spree::Order - end + + def load_order_action + [:edit, :update, :cancel, :resume, :approve, :resend, :open_adjustments, :close_adjustments, :cart] + end + + def check_authorization + action = params[:action].to_sym + if load_order_action.include?(action) + load_order + session[:access_token] ||= params[:token] + resource = @order || Spree::Order.new + authorize! action, resource, session[:access_token] + else + authorize! :index, Spree::Order end + end end diff --git a/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb b/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb index 03490679d..aa90216cc 100644 --- a/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb +++ b/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb @@ -1,3 +1,3 @@ Spree::Admin::ResourceController.class_eval do - rescue_from CanCan::AccessDenied, :with => :unauthorized + rescue_from CanCan::AccessDenied, with: :unauthorized end diff --git a/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb b/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb index 978138c39..9caef0641 100644 --- a/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +++ b/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb @@ -2,14 +2,15 @@ before_action :check_authorization private - def check_authorization - load_order - session[:access_token] ||= params[:token] - resource = @order - action = params[:action].to_sym - action = :edit if action == :show # show route renders :edit for this controller + def check_authorization + load_order + session[:access_token] ||= params[:token] - authorize! action, resource, session[:access_token] - end + resource = @order + action = params[:action].to_sym + action = :edit if action == :show # show route renders :edit for this controller + + authorize! action, resource, session[:access_token] + end end diff --git a/lib/controllers/backend/spree/admin/user_passwords_controller.rb b/lib/controllers/backend/spree/admin/user_passwords_controller.rb index b4fd1fe8f..667182c76 100644 --- a/lib/controllers/backend/spree/admin/user_passwords_controller.rb +++ b/lib/controllers/backend/spree/admin/user_passwords_controller.rb @@ -20,7 +20,7 @@ def create if resource.errors.empty? set_flash_message(:notice, :send_instructions) if is_navigational_format? - respond_with resource, :location => spree.admin_login_path + respond_with resource, location: spree.admin_login_path else respond_with_navigational(resource) { render :new } end @@ -43,5 +43,4 @@ def update def translation_scope 'devise.user_passwords' end - end diff --git a/lib/controllers/backend/spree/admin/user_sessions_controller.rb b/lib/controllers/backend/spree/admin/user_sessions_controller.rb index 704028365..c4ec34ca4 100644 --- a/lib/controllers/backend/spree/admin/user_sessions_controller.rb +++ b/lib/controllers/backend/spree/admin/user_sessions_controller.rb @@ -19,7 +19,7 @@ def create } format.js { user = resource.record - render :json => {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json + render json: { ship_address: user.ship_address, bill_address: user.bill_address }.to_json } end else @@ -28,8 +28,7 @@ def create end end - def authorization_failure - end + def authorization_failure; end protected @@ -38,21 +37,22 @@ def translation_scope end private - def accurate_title - Spree.t(:login) - end - def redirect_back_or_default(default) - redirect_to(session["spree_user_return_to"] || default) - session["spree_user_return_to"] = nil - end + def accurate_title + Spree.t(:login) + end - def resolve_layout - case action_name - when "new", "create" - "spree/layouts/login" - else - "spree/layouts/admin" - end + def redirect_back_or_default(default) + redirect_to(session["spree_user_return_to"] || default) + session["spree_user_return_to"] = nil + end + + def resolve_layout + case action_name + when "new", "create" + "spree/layouts/login" + else + "spree/layouts/admin" end + end end diff --git a/lib/controllers/frontend/spree/checkout_controller_decorator.rb b/lib/controllers/frontend/spree/checkout_controller_decorator.rb index cf8373e82..a26c8693d 100644 --- a/lib/controllers/frontend/spree/checkout_controller_decorator.rb +++ b/lib/controllers/frontend/spree/checkout_controller_decorator.rb @@ -18,23 +18,24 @@ def update_registration end private - def order_params - params[:order].present? ? params.require(:order).permit(:email) : {} - end - def skip_state_validation? - %w(registration update_registration).include?(params[:action]) - end + def order_params + params[:order].present? ? params.require(:order).permit(:email) : {} + end - def check_authorization - authorize!(:edit, current_order, cookies.signed[:guest_token]) - end + def skip_state_validation? + %w(registration update_registration).include?(params[:action]) + end - # Introduces a registration step whenever the +registration_step+ preference is true. - def check_registration - return unless Spree::Auth::Config[:registration_step] - return if spree_current_user or current_order.email - store_location - redirect_to spree.checkout_registration_path - end + def check_authorization + authorize!(:edit, current_order, cookies.signed[:guest_token]) + end + + # Introduces a registration step whenever the +registration_step+ preference is true. + def check_registration + return unless Spree::Auth::Config[:registration_step] + return if spree_current_user || current_order.email + store_location + redirect_to spree.checkout_registration_path + end end diff --git a/lib/controllers/frontend/spree/user_confirmations_controller.rb b/lib/controllers/frontend/spree/user_confirmations_controller.rb index 47eb874d8..93a009e5f 100644 --- a/lib/controllers/frontend/spree/user_confirmations_controller.rb +++ b/lib/controllers/frontend/spree/user_confirmations_controller.rb @@ -15,5 +15,4 @@ def after_confirmation_path_for(resource_name, resource) def translation_scope 'devise.confirmations' end - end diff --git a/lib/controllers/frontend/spree/user_passwords_controller.rb b/lib/controllers/frontend/spree/user_passwords_controller.rb index a37ec1c72..6868c7b8e 100644 --- a/lib/controllers/frontend/spree/user_passwords_controller.rb +++ b/lib/controllers/frontend/spree/user_passwords_controller.rb @@ -18,7 +18,7 @@ def create if resource.errors.empty? set_flash_message(:notice, :send_instructions) if is_navigational_format? - respond_with resource, :location => spree.login_path + respond_with resource, location: spree.login_path else respond_with_navigational(resource) { render :new } end diff --git a/lib/controllers/frontend/spree/user_sessions_controller.rb b/lib/controllers/frontend/spree/user_sessions_controller.rb index 69cc8fbda..28d34bc44 100644 --- a/lib/controllers/frontend/spree/user_sessions_controller.rb +++ b/lib/controllers/frontend/spree/user_sessions_controller.rb @@ -16,9 +16,9 @@ def create redirect_back_or_default(after_sign_in_path_for(spree_current_user)) } format.js { - render :json => {:user => spree_current_user, - :ship_address => spree_current_user.ship_address, - :bill_address => spree_current_user.bill_address}.to_json + render json: { user: spree_current_user, + ship_address: spree_current_user.ship_address, + bill_address: spree_current_user.bill_address }.to_json } end else @@ -28,7 +28,7 @@ def create render :new } format.js { - render :json => { error: t('devise.failure.invalid') }, status: :unprocessable_entity + render json: { error: t('devise.failure.invalid') }, status: :unprocessable_entity } end end @@ -41,12 +41,13 @@ def translation_scope end private - def accurate_title - Spree.t(:login) - end - def redirect_back_or_default(default) - redirect_to(session["spree_user_return_to"] || default) - session["spree_user_return_to"] = nil - end + def accurate_title + Spree.t(:login) + end + + def redirect_back_or_default(default) + redirect_to(session["spree_user_return_to"] || default) + session["spree_user_return_to"] = nil + end end diff --git a/lib/controllers/frontend/spree/users_controller.rb b/lib/controllers/frontend/spree/users_controller.rb index 65433fc6e..af829d536 100644 --- a/lib/controllers/frontend/spree/users_controller.rb +++ b/lib/controllers/frontend/spree/users_controller.rb @@ -28,29 +28,30 @@ def update if params[:user][:password].present? # this logic needed b/c devise wants to log us out after password changes user = Spree::User.reset_password_by_token(params[:user]) - sign_in(@user, :event => :authentication, :bypass => !Spree::Auth::Config[:signout_after_password_change]) + sign_in(@user, event: :authentication, bypass: !Spree::Auth::Config[:signout_after_password_change]) end - redirect_to spree.account_url, :notice => Spree.t(:account_updated) + redirect_to spree.account_url, notice: Spree.t(:account_updated) else render :edit end end private - def user_params - params.require(:user).permit(Spree::PermittedAttributes.user_attributes) - end - def load_object - @user ||= spree_current_user - authorize! params[:action].to_sym, @user - end + def user_params + params.require(:user).permit(Spree::PermittedAttributes.user_attributes) + end - def authorize_actions - authorize! params[:action].to_sym, Spree::User.new - end + def load_object + @user ||= spree_current_user + authorize! params[:action].to_sym, @user + end - def accurate_title - Spree.t(:my_account) - end + def authorize_actions + authorize! params[:action].to_sym, Spree::User.new + end + + def accurate_title + Spree.t(:my_account) + end end diff --git a/lib/generators/spree/auth/install/install_generator.rb b/lib/generators/spree/auth/install/install_generator.rb index 686f9badd..5061d9bf6 100644 --- a/lib/generators/spree/auth/install/install_generator.rb +++ b/lib/generators/spree/auth/install/install_generator.rb @@ -5,7 +5,7 @@ class InstallGenerator < Rails::Generators::Base class_option :migrate, type: :boolean, default: true, banner: 'Migrate the database' def self.source_paths - paths = self.superclass.source_paths + paths = superclass.source_paths paths << File.expand_path('../templates', __FILE__) paths.flatten end diff --git a/lib/spree/auth/devise.rb b/lib/spree/auth/devise.rb index 56fca7854..3b6854b61 100644 --- a/lib/spree/auth/devise.rb +++ b/lib/spree/auth/devise.rb @@ -9,7 +9,7 @@ module Spree module Auth mattr_accessor :default_secret_key - def self.config(&block) + def self.config yield(Spree::Auth::Config) end end diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index eecffef0a..acf5610cf 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -7,11 +7,11 @@ class Engine < Rails::Engine isolate_namespace Spree engine_name 'spree_auth' - initializer "spree.auth.environment", :before => :load_config_initializers do |app| + initializer "spree.auth.environment", before: :load_config_initializers do |_app| Spree::Auth::Config = Spree::AuthConfiguration.new end - initializer "spree_auth_devise.set_user_class", :after => :load_config_initializers do + initializer "spree_auth_devise.set_user_class", after: :load_config_initializers do Spree.user_class = "Spree::User" end @@ -20,7 +20,7 @@ class Engine < Rails::Engine puts "[WARNING] You are not setting Devise.secret_key within your application!" puts "You must set this in config/initializers/devise.rb. Here's an example:" puts " " - puts %Q{Devise.secret_key = "#{SecureRandom.hex(50)}"} + puts %{Devise.secret_key = "#{SecureRandom.hex(50)}"} end end @@ -61,12 +61,12 @@ def self.frontend_available? @@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine') end - if self.backend_available? + if backend_available? paths["app/controllers"] << "lib/controllers/backend" paths["app/views"] << "lib/views/backend" end - if self.frontend_available? + if frontend_available? paths["app/controllers"] << "lib/controllers/frontend" paths["app/views"] << "lib/views/frontend" end diff --git a/lib/tasks/auth.rake b/lib/tasks/auth.rake index 12d2d37e1..38bc4fce7 100644 --- a/lib/tasks/auth.rake +++ b/lib/tasks/auth.rake @@ -1,7 +1,7 @@ namespace :spree_auth do namespace :admin do desc "Create admin username and password" - task :create => :environment do + task create: :environment do require File.join(File.dirname(__FILE__), '..', '..', 'db', 'default', 'users.rb') puts "Done!" end diff --git a/spec/controllers/spree/checkout_controller_spec.rb b/spec/controllers/spree/checkout_controller_spec.rb index e5cc5354e..c9477d605 100644 --- a/spec/controllers/spree/checkout_controller_spec.rb +++ b/spec/controllers/spree/checkout_controller_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::CheckoutController, type: :controller do - let(:order) { create(:order_with_totals, email: nil, user: nil) } let(:user) { build(:user, spree_api_key: 'fake') } let(:token) { 'some_token' } @@ -114,7 +113,7 @@ controller.stub :check_authorization order.stub update_attributes: true controller.should_not_receive :check_registration - spree_put :update_registration, { order: { } } + spree_put :update_registration, { order: {} } end it 'renders the registration view if unable to save' do diff --git a/spec/controllers/spree/products_controller_spec.rb b/spec/controllers/spree/products_controller_spec.rb index c9a441fbf..8e058aca7 100644 --- a/spec/controllers/spree/products_controller_spec.rb +++ b/spec/controllers/spree/products_controller_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::ProductsController, type: :controller do - let!(:product) { create(:product, available_on: 1.year.from_now) } let!(:user) { build(:user, spree_api_key: 'fake') } diff --git a/spec/controllers/spree/user_passwords_controller_spec.rb b/spec/controllers/spree/user_passwords_controller_spec.rb index 826e9c106..4d8665f5f 100644 --- a/spec/controllers/spree/user_passwords_controller_spec.rb +++ b/spec/controllers/spree/user_passwords_controller_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do - let(:token) { 'some_token' } before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } @@ -16,7 +15,7 @@ it 'flashes an error' do spree_get :edit expect(flash[:alert]).to include( - "You can't access this page without coming from a password reset " + + "You can't access this page without coming from a password reset " \ 'email' ) end @@ -34,7 +33,7 @@ context 'when updating password with blank password' do it 'shows error flash message, sets spree_user with token and re-displays password edit form' do spree_put :update, { spree_user: { password: '', password_confirmation: '', reset_password_token: token } } - expect(assigns(:spree_user).kind_of?(Spree::User)).to eq true + expect(assigns(:spree_user).is_a?(Spree::User)).to eq true expect(assigns(:spree_user).reset_password_token).to eq token expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user]) expect(response).to render_template :edit diff --git a/spec/controllers/spree/user_registrations_controller_spec.rb b/spec/controllers/spree/user_registrations_controller_spec.rb index e6668e86e..0ffe34ae7 100644 --- a/spec/controllers/spree/user_registrations_controller_spec.rb +++ b/spec/controllers/spree/user_registrations_controller_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } context '#create' do diff --git a/spec/controllers/spree/user_sessions_controller_spec.rb b/spec/controllers/spree/user_sessions_controller_spec.rb index 7b42c21d4..586430329 100644 --- a/spec/controllers/spree/user_sessions_controller_spec.rb +++ b/spec/controllers/spree/user_sessions_controller_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::UserSessionsController, type: :controller do - let(:user) { create(:user) } before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } diff --git a/spec/controllers/spree/users_controller_spec.rb b/spec/controllers/spree/users_controller_spec.rb index 32e1f0cfe..1f09b5766 100644 --- a/spec/controllers/spree/users_controller_spec.rb +++ b/spec/controllers/spree/users_controller_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::UsersController, type: :controller do - let(:admin_user) { create(:user) } let(:user) { create(:user) } let(:role) { create(:role) } diff --git a/spec/factories/confirmed_user.rb b/spec/factories/confirmed_user.rb index 26426a774..a9d22bd65 100644 --- a/spec/factories/confirmed_user.rb +++ b/spec/factories/confirmed_user.rb @@ -4,4 +4,4 @@ confirmation_sent_at { Time.now } confirmation_token "12345" end -end \ No newline at end of file +end diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index 011553f84..9f6a3425e 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Accounts', type: :feature do - context 'editing' do scenario 'can edit an admin user', js: true do user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password') diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index 81f6fa851..98553c2d3 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Admin orders', type: :feature do - background do sign_in_as! create(:admin_user) end diff --git a/spec/features/admin/password_reset_spec.rb b/spec/features/admin/password_reset_spec.rb index 5a29c15de..a47fabae8 100644 --- a/spec/features/admin/password_reset_spec.rb +++ b/spec/features/admin/password_reset_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Admin - Reset Password', type: :feature do - let!(:store) { create(:store) } background do diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index c23c74e8a..0290557b3 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Admin products', type: :feature do - context 'as anonymous user' do # Regression test for #1250 scenario 'redirects to login page when attempting to access product listing' do diff --git a/spec/features/admin/sign_in_spec.rb b/spec/features/admin/sign_in_spec.rb index 80fc67b71..0dc613f50 100644 --- a/spec/features/admin/sign_in_spec.rb +++ b/spec/features/admin/sign_in_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Admin - Sign In', type: :feature do - background do @user = create(:user, email: 'email@person.com') visit spree.admin_login_path diff --git a/spec/features/admin/sign_out_spec.rb b/spec/features/admin/sign_out_spec.rb index 65d8bbbb5..19e72448c 100644 --- a/spec/features/admin/sign_out_spec.rb +++ b/spec/features/admin/sign_out_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Admin - Sign Out', type: :feature do - given!(:user) do create :user, email: 'email@person.com' end diff --git a/spec/features/admin_permissions_spec.rb b/spec/features/admin_permissions_spec.rb index 369fcec76..daa5e862b 100644 --- a/spec/features/admin_permissions_spec.rb +++ b/spec/features/admin_permissions_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Admin Permissions', type: :feature do - context 'orders' do background do user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password') diff --git a/spec/features/change_email_spec.rb b/spec/features/change_email_spec.rb index b463b5f76..bb4e9664e 100644 --- a/spec/features/change_email_spec.rb +++ b/spec/features/change_email_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Change email', type: :feature do - background do user = create(:user) visit spree.root_path diff --git a/spec/features/checkout_spec.rb b/spec/features/checkout_spec.rb index 84c9ebdde..7295e4343 100644 --- a/spec/features/checkout_spec.rb +++ b/spec/features/checkout_spec.rb @@ -47,9 +47,9 @@ str_addr = 'bill_address' select 'United States', from: "order_#{str_addr}_attributes_country_id" %w(firstname lastname address1 city zipcode phone).each do |field| - fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}" + fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s end - select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id" + select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id" check 'order_use_billing' click_button 'Save and Continue' @@ -77,9 +77,9 @@ str_addr = 'bill_address' select 'United States', from: "order_#{str_addr}_attributes_country_id" %w(firstname lastname address1 city zipcode phone).each do |field| - fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}" + fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s end - select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id" + select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id" check 'order_use_billing' click_button 'Save and Continue' @@ -118,9 +118,9 @@ str_addr = 'bill_address' select 'United States', from: "order_#{str_addr}_attributes_country_id" %w(firstname lastname address1 city zipcode phone).each do |field| - fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}" + fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s end - select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id" + select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id" check 'order_use_billing' click_button 'Save and Continue' @@ -145,9 +145,9 @@ str_addr = 'bill_address' select 'United States', from: "order_#{str_addr}_attributes_country_id" %w(firstname lastname address1 city zipcode phone).each do |field| - fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}" + fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s end - select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id" + select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id" check 'order_use_billing' click_button 'Save and Continue' diff --git a/spec/features/confirmation_spec.rb b/spec/features/confirmation_spec.rb index 80ecdb9bd..256b428ed 100644 --- a/spec/features/confirmation_spec.rb +++ b/spec/features/confirmation_spec.rb @@ -25,4 +25,4 @@ expect(page).to have_text 'You have signed up successfully.' expect(Spree::User.last.confirmed?).to be(false) end -end \ No newline at end of file +end diff --git a/spec/features/order_spec.rb b/spec/features/order_spec.rb index 658edcc8b..f967ac354 100644 --- a/spec/features/order_spec.rb +++ b/spec/features/order_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Orders', :js, type: :feature do - scenario 'allow a user to view their cart at any time' do visit spree.cart_path expect(page).to have_text 'Your cart is empty' diff --git a/spec/features/password_reset_spec.rb b/spec/features/password_reset_spec.rb index 6ca96afb1..c8412513f 100644 --- a/spec/features/password_reset_spec.rb +++ b/spec/features/password_reset_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Reset Password', type: :feature do - let!(:store) { create(:store) } background do diff --git a/spec/features/sign_in_spec.rb b/spec/features/sign_in_spec.rb index 1936eba72..2597cc7bb 100644 --- a/spec/features/sign_in_spec.rb +++ b/spec/features/sign_in_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Sign In', type: :feature do - background do @user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret') visit spree.login_path diff --git a/spec/features/sign_out_spec.rb b/spec/features/sign_out_spec.rb index 4824d28a6..78078db93 100644 --- a/spec/features/sign_out_spec.rb +++ b/spec/features/sign_out_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Sign Out', type: :feature do - given!(:user) do create(:user, email: 'email@person.com', diff --git a/spec/features/sign_up_spec.rb b/spec/features/sign_up_spec.rb index dd02d05b2..fefba278d 100644 --- a/spec/features/sign_up_spec.rb +++ b/spec/features/sign_up_spec.rb @@ -1,5 +1,4 @@ RSpec.feature 'Sign Up', type: :feature do - context 'with valid data' do scenario 'create a new user' do visit spree.signup_path diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 47d106d28..4467fa300 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::UserMailer, type: :mailer do - let!(:store) { create(:store) } let(:user) { create(:user) } diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index fbf3705e1..0b96ccd97 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::Order, type: :model do - let(:order) { described_class.new } context '#associate_user!' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4c2d428c3..c3c6c2e0b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,4 @@ RSpec.describe Spree::User, type: :model do - before(:all) { Spree::Role.create name: 'admin' } it '#admin?' do diff --git a/spec/support/ability.rb b/spec/support/ability.rb index ca6427086..9d0402932 100644 --- a/spec/support/ability.rb +++ b/spec/support/ability.rb @@ -8,7 +8,7 @@ class AbilityDecorator include CanCan::Ability - def initialize(user) + def initialize(_user) cannot :manage, Spree::Order end end diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb index fe252cb02..e57ce8d8f 100644 --- a/spec/support/authentication_helpers.rb +++ b/spec/support/authentication_helpers.rb @@ -10,5 +10,5 @@ def sign_in_as!(user) RSpec.configure do |config| config.include AuthenticationHelpers, type: :feature config.include Devise::Test::ControllerHelpers, type: :controller - config.include Rack::Test::Methods, type: :feature + config.include Rack::Test::Methods, type: :feature end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 7320ae7f7..15251bf70 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -3,7 +3,7 @@ require 'capybara/poltergeist' require 'capybara-screenshot/rspec' -RSpec.configure do |config| +RSpec.configure do |_config| Capybara.javascript_driver = :poltergeist Capybara.save_and_open_page_path = ENV['CIRCLE_ARTIFACTS'] if ENV['CIRCLE_ARTIFACTS'] end diff --git a/spec/support/confirm_helpers.rb b/spec/support/confirm_helpers.rb index e5af3dd21..263643744 100644 --- a/spec/support/confirm_helpers.rb +++ b/spec/support/confirm_helpers.rb @@ -8,4 +8,4 @@ def set_confirmable_option(value) RSpec.configure do |c| c.include ConfirmHelpers -end \ No newline at end of file +end diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 53c00bb27..c08b317eb 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,7 +1,6 @@ require 'database_cleaner' RSpec.configure do |config| - config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with :truncation diff --git a/spree_auth_devise.gemspec b/spree_auth_devise.gemspec index b8da0f116..43004afd9 100644 --- a/spree_auth_devise.gemspec +++ b/spree_auth_devise.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.author = 'Sean Schofield' s.email = 'sean@spreecommerce.com' s.homepage = 'http://spreecommerce.com' - s.license = %q{BSD-3} + s.license = 'BSD-3' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- spec/*`.split("\n") From 5ded3ef8a84e38404022101f4b7c5758fca499fc Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 14:55:01 +0200 Subject: [PATCH 5/8] Updated CHANGELOG.md --- CHANGELOG.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9116befd6..54f1dca71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,17 @@ -## Spree Auth Devise v3.2.0 (master, unreleased) +## Spree Auth Devise v3.2.0 (2017-06-15) -* Supports `Spree 3.1` and any other newer version lesser than `4.0` (https://github.com/spree/spree_auth_devise/pull/353) -* `devise` updated to `4.0` (https://github.com/spree/spree_auth_devise/pull/344) +* `Rails 5` support +* Supports `Spree 3.1` `Spree 3.2` and any other newer version lesser than `4.0` (https://github.com/spree/spree_auth_devise/pull/353, https://github.com/spree/spree_auth_devise/pull/386) +* `devise` updated to `4.3` (https://github.com/spree/spree_auth_devise/pull/382) +* `devise-encryptable` updated to `0.2.0` (https://github.com/spree/spree_auth_devise/commit/5f51e6e4e81dbf99fe95848dbd4fa9cba03b6910) * updated development dependencies (https://github.com/spree/spree_auth_devise/pull/351) * include `Spree::UserMethods` in `Spree::User` (https://github.com/spree/spree_auth_devise/pull/343) +* fixed: Unnecessary breaking changes of I18n key (https://github.com/spree/spree_auth_devise/pull/387) +* fixed: use proper scoping to find translations related to order states (https://github.com/spree/spree_auth_devise/pull/384) +* fixed: spree_api is not required anymore (https://github.com/spree/spree_auth_devise/pull/380) +* Install generator: Add option to skip migrations (https://github.com/spree/spree_auth_devise/pull/378) +* Added Portuguese translation (https://github.com/spree/spree_auth_devise/pull/365) +* Replaced registration_error flash with standard error (https://github.com/spree/spree_auth_devise/pull/361) ## Spree Auth Devise v3.1.0 (2016-04-05) From f1cdc92b4f54ef6a7e24d5c691eda92e92d81b7e Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 14:58:06 +0200 Subject: [PATCH 6/8] Bump version to 3.2.0 --- spree_auth_devise.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spree_auth_devise.gemspec b/spree_auth_devise.gemspec index 43004afd9..01e1f7ab1 100644 --- a/spree_auth_devise.gemspec +++ b/spree_auth_devise.gemspec @@ -3,7 +3,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_auth_devise' - s.version = '3.2.0.beta' + s.version = '3.2.0' s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.' s.description = s.summary From e612de27ee600e5860494b907cf151b3952d34a9 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 15:07:05 +0200 Subject: [PATCH 7/8] Fix for local development on Rails 5.0+ --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index dc8d2a73b..3466a56e7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +gem "rails-controller-testing" gem 'spree', github: 'spree/spree', branch: 'master' gemspec From e2b8bf1a554b55303feb1eabf8f61b201d705903 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Thu, 15 Jun 2017 15:10:00 +0200 Subject: [PATCH 8/8] Updated README.md --- README.md | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 352bcbc90..da073222b 100644 --- a/README.md +++ b/README.md @@ -5,38 +5,43 @@ Provides authentication services for Spree, using the Devise gem. + ## Installation -At one stage in the past, this used to be the auth component for Spree. If that's the feature that you're now finding lacking from Spree, that's easily fixed. +1. Add this extension to your Gemfile with this line: -Just add this line to your `Gemfile`: -```ruby -gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master' -``` + #### Spree >= 3.1 -Please ensure you're using the correct branch of `spree_auth_devise` relative to your version of Spree. + ```ruby + gem 'spree_auth_devise', github: 'spree/spree_auth_devise' + ``` -Spree 1.3.x or 1-3-stable: -```ruby -gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-3-stable' -``` + #### Spree 3.0 and Spree 2.x -Spree 1.2.x or 1-2-stable: -```ruby -gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-2-stable' -``` + ```ruby + gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'X-X-stable' + ``` -Then run `bundle install`. Authentication will then work exactly as it did in previous versions of Spree. + The `branch` option is important: it must match the version of Spree you're using. + For example, use `3-0-stable` if you're using Spree `3-0-stable` or any `3.0.x` version. -If you're installing this in a new Spree 1.2+ application, you'll need to install and run the migrations with +2. Install the gem using Bundler: + ```ruby + bundle install + ``` - bundle exec rake spree_auth:install:migrations - bundle exec rake db:migrate - bundle exec rails g spree:auth:install +3. Copy & run migrations + ```ruby + bundle exec rails g spree:auth:install + ``` -and then, run this command in order to set up the admin user for the application. +## Upgrading from Spree 3.0 to 3.1 - bundle exec rake spree_auth:admin:create +If you're upgrading from 3.0 to 3.1 you need to rerun the installer to copy new asset files (javascripts) + +```ruby +bundle exec rails g spree:auth:install +``` ## Configuration @@ -110,6 +115,4 @@ You need to do a quick one-time creation of a test application and then you can Then run the rspec tests. - bundle exec rake spec - -If everything doesn't pass on your machine (using Ruby (1.9.3 or 2.0.0) and (MySQL or PostgreSQL or SQLite3)) then we would consider that a bug. Please file a bug report on the issues page for this project with your test output and we will investigate it. + bundle exec rspec