diff --git a/.gitignore b/.gitignore index 0ace4c2..3040c81 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ spec/dummy .bundle .node-version .ruby-version +gemfiles/*.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4ca5162 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +sudo: required +dist: trusty + +script: + - bundle exec rake test_app + - bundle exec rake spec + +env: + - DB=mysql + - DB=postgres + +language: ruby + +rvm: + - 2.3.1 + - 2.2.7 + +gemfile: + - gemfiles/spree_3_1.gemfile + - gemfiles/spree_3_2.gemfile + - gemfiles/spree_3_3.gemfile + - gemfiles/spree_master.gemfile + +before_install: + - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';" diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..65b5b66 --- /dev/null +++ b/Appraisals @@ -0,0 +1,23 @@ +appraise 'spree-3-1' do + gem 'spree', '~> 3.1.0' + gem 'spree_auth_devise', '~> 3.1.0' + gem 'rails_test_params_backport', group: :test +end + +appraise 'spree-3-2' do + gem 'spree', '~> 3.2.0' + gem 'spree_auth_devise', '~> 3.2.0' + gem 'rails-controller-testing' +end + +appraise 'spree-3-3' do + gem 'spree', '~> 3.3.0' + gem 'spree_auth_devise', '~> 3.3.0' + gem 'rails-controller-testing' +end + +appraise 'spree-master' do + gem 'spree', github: 'spree/spree', branch: 'master' + gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master' + gem 'rails-controller-testing' +end diff --git a/Gemfile b/Gemfile index 77e2cd4..663757b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,6 @@ source 'https://rubygems.org' -gem 'spree', github: 'spree/spree', branch: '2-3-stable' -gem 'spree_auth_devise', github: "spree/spree_auth_devise", branch: '2-3-stable' -gem 'libnotify' -gem 'fuubar' -gem 'byebug' -gem 'pry-byebug' +gem 'spree', github: 'spree/spree', branch: 'master' +gem 'rails-controller-testing' gemspec diff --git a/db/migrate/20130422122600_add_subscribed_to_spree_users.rb b/db/migrate/20130422122600_add_subscribed_to_spree_users.rb index 6de52ea..c657765 100644 --- a/db/migrate/20130422122600_add_subscribed_to_spree_users.rb +++ b/db/migrate/20130422122600_add_subscribed_to_spree_users.rb @@ -1,4 +1,4 @@ -class AddSubscribedToSpreeUsers < ActiveRecord::Migration +class AddSubscribedToSpreeUsers < SpreeExtension::Migration[4.2] def change change_table Spree.user_class.table_name.to_sym do |t| t.boolean :subscribed diff --git a/db/migrate/201304241925_create_order_sources.rb b/db/migrate/201304241925_create_order_sources.rb index 5721e8d..a579a9c 100644 --- a/db/migrate/201304241925_create_order_sources.rb +++ b/db/migrate/201304241925_create_order_sources.rb @@ -1,4 +1,4 @@ -class CreateOrderSources < ActiveRecord::Migration +class CreateOrderSources < SpreeExtension::Migration[4.2] def change create_table :spree_chimpy_order_sources do |t| t.references :order diff --git a/db/migrate/20130509170447_create_subscriber.rb b/db/migrate/20130509170447_create_subscriber.rb index 582b55d..d57f6ce 100644 --- a/db/migrate/20130509170447_create_subscriber.rb +++ b/db/migrate/20130509170447_create_subscriber.rb @@ -1,4 +1,4 @@ -class CreateSubscriber < ActiveRecord::Migration +class CreateSubscriber < SpreeExtension::Migration[4.2] def change create_table :spree_chimpy_subscribers do |t| t.string :email, null: false diff --git a/gemfiles/spree_3_1.gemfile b/gemfiles/spree_3_1.gemfile new file mode 100644 index 0000000..d749eb5 --- /dev/null +++ b/gemfiles/spree_3_1.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "spree", "~> 3.1.0" +gem "spree_auth_devise", "~> 3.1.0" +gem "rails_test_params_backport", group: :test + +gemspec path: "../" diff --git a/gemfiles/spree_3_2.gemfile b/gemfiles/spree_3_2.gemfile new file mode 100644 index 0000000..ed54e0e --- /dev/null +++ b/gemfiles/spree_3_2.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "spree", "~> 3.2.0" +gem "rails-controller-testing" +gem "spree_auth_devise", "~> 3.2.0" + +gemspec path: "../" diff --git a/gemfiles/spree_3_3.gemfile b/gemfiles/spree_3_3.gemfile new file mode 100644 index 0000000..0d1c56a --- /dev/null +++ b/gemfiles/spree_3_3.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "spree", "~> 3.3.0" +gem "rails-controller-testing" +gem "spree_auth_devise", "~> 3.3.0" + +gemspec path: "../" diff --git a/gemfiles/spree_master.gemfile b/gemfiles/spree_master.gemfile new file mode 100644 index 0000000..e4a154f --- /dev/null +++ b/gemfiles/spree_master.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "spree", github: "spree/spree", branch: "master" +gem "rails-controller-testing" +gem "spree_auth_devise", github: "spree/spree_auth_devise", branch: "master" + +gemspec path: "../" diff --git a/lib/spree/chimpy/controller_filters.rb b/lib/spree/chimpy/controller_filters.rb index dd84d09..375c99c 100644 --- a/lib/spree/chimpy/controller_filters.rb +++ b/lib/spree/chimpy/controller_filters.rb @@ -3,8 +3,8 @@ module ControllerFilters extend ActiveSupport::Concern included do - before_filter :set_mailchimp_params - before_filter :find_mail_chimp_params, if: :mailchimp_params? + before_action :set_mailchimp_params + before_action :find_mail_chimp_params, if: :mailchimp_params? include ::Spree::Core::ControllerHelpers::Order end diff --git a/lib/spree/chimpy/interface/products.rb b/lib/spree/chimpy/interface/products.rb index b2c8b1d..9752637 100644 --- a/lib/spree/chimpy/interface/products.rb +++ b/lib/spree/chimpy/interface/products.rb @@ -2,7 +2,7 @@ module Spree::Chimpy module Interface class Products delegate :log, :store_api_call, to: Spree::Chimpy - include Rails.application.routes.url_helpers + include Spree.railtie_routes_url_helpers def initialize(variant) @variant = variant @@ -109,11 +109,11 @@ def self.product_url_or_default(product) product_url(product) else URI::HTTP.build({ - host: Rails.application.routes.default_url_options[:host], + host: Spree::Store.current.url, :path => "/products/#{product.slug}"} ).to_s end end end end -end \ No newline at end of file +end diff --git a/lib/spree_chimpy.rb b/lib/spree_chimpy.rb index 301c880..545d862 100644 --- a/lib/spree_chimpy.rb +++ b/lib/spree_chimpy.rb @@ -1,4 +1,5 @@ require 'spree_core' +require 'spree_extension' require 'spree/chimpy/engine' require 'spree/chimpy/subscription' require 'spree/chimpy/workers/delayed_job' diff --git a/spec/controllers/controller_filters_spec.rb b/spec/controllers/controller_filters_spec.rb index 40961b1..001eaec 100644 --- a/spec/controllers/controller_filters_spec.rb +++ b/spec/controllers/controller_filters_spec.rb @@ -26,7 +26,7 @@ def index it 'sets the attributes for the order if eid/cid is set in the params' do expect(subject).to receive(:find_mail_chimp_params) - get :index, mc_eid: '1234', mc_cid: 'abcd' + get :index, params: { mc_eid: '1234', mc_cid: 'abcd'} end it 'does not call find mail chimp params method if no eid/cid' do diff --git a/spec/controllers/spree/chimpy/subscribers_controller_spec.rb b/spec/controllers/spree/chimpy/subscribers_controller_spec.rb index 0766208..e764e38 100644 --- a/spec/controllers/spree/chimpy/subscribers_controller_spec.rb +++ b/spec/controllers/spree/chimpy/subscribers_controller_spec.rb @@ -7,7 +7,7 @@ context '#create' do it 'raise error when empty hash found' do - expect { spree_post :create, chimpy_subscriber: {} }.to raise_error + expect { post :create, params: { chimpy_subscriber: {} } }.to raise_error end end -end \ No newline at end of file +end diff --git a/spec/features/spree/admin/subscription_spec.rb b/spec/features/spree/admin/subscription_spec.rb index dea417c..0ad8bb8 100644 --- a/spec/features/spree/admin/subscription_spec.rb +++ b/spec/features/spree/admin/subscription_spec.rb @@ -19,8 +19,8 @@ click_button 'Create' expect(current_path).to eq spree.admin_users_path - expect(page).to have_text 'API ACCESS' - expect(page).to have_text 'NO KEY' + expect(page).to have_text 'API Access' + expect(page).to have_text 'No key' find_button('Generate API key').click @@ -41,8 +41,8 @@ click_button 'Create' current_path.should eq spree.admin_users_path - expect(page).to have_text 'API ACCESS' - expect(page).to have_text 'NO KEY' + expect(page).to have_text 'API Access' + expect(page).to have_text 'No key' find_button('Generate API key').click diff --git a/spec/features/spree/subscription_spec.rb b/spec/features/spree/subscription_spec.rb index db3da52..f0c471a 100644 --- a/spec/features/spree/subscription_spec.rb +++ b/spec/features/spree/subscription_spec.rb @@ -6,6 +6,7 @@ end scenario 'guest subscription deface data-hook confirmation' do + skip 'its not set by default' page.find('#footer-right') end @@ -13,25 +14,15 @@ subscribe! expect(current_path).to eq spree.root_path - expect(page).to have_selector '.notice', text: 'Welcome! You have signed up successfully.' + expect(page).to have_selector '.alert-notice', text: 'Welcome! You have signed up successfully.' expect(Spree::User.count).to be(1) expect(Spree::User.first.subscribed).to be_truthy end - scenario 'user subscription with opt_out' do - skip 'does this refer to the double opt_in/out?' - subscribe! - - expect(current_path).to eq spree.root_path - expect(page).to have_selector '.notice', text: 'Welcome! You have signed up successfully.' - expect(Spree::User.count).to be(1) - expect(Spree::User.first.subscribed).to be_falsey - end - def subscribe! expect(page).to have_text 'Sign me up to the newsletter' - fill_in 'Email', with: Faker::Internet.email + fill_in 'Email', with: FFaker::Internet.email fill_in 'Password', with: 'secret123' fill_in 'Password Confirmation', with: 'secret123' diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 5d31431..11c0410 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -22,7 +22,7 @@ it 'doesnt update when order is not completed' do expect(subject).to_not receive(:enqueue) - @not_completed_order.update! + @not_completed_order.update_with_updater! end it 'updates when order is completed' do diff --git a/spec/requests/subscribers_spec.rb b/spec/requests/subscribers_spec.rb index cb04a16..9772942 100644 --- a/spec/requests/subscribers_spec.rb +++ b/spec/requests/subscribers_spec.rb @@ -1,12 +1,11 @@ require 'spec_helper' describe 'Subscribers' do - context 'with valid subscription' do it 'redirects to referer' do - post '/subscribers', - { chimpy_subscriber: { email: 'foo2@bar.com', subscribed: true } }, - { referer: 'http://foo.bar' } + post '/subscribers', params: { + chimpy_subscriber: { email: 'foo2@bar.com', subscribed: true } }, + headers: { referer: 'http://foo.bar' } expect(response).to be_redirect expect(response.location).to eq('http://foo.bar') @@ -14,8 +13,8 @@ it 'redirects to root URL if no referer' do post '/subscribers', - { chimpy_subscriber: { email: 'foo2@bar.com', subscribed: true } }, - { referer: nil } + params: { chimpy_subscriber: { email: 'foo2@bar.com', subscribed: true } }, + headers: { referer: nil } expect(response).to be_redirect expect(response.location).to eq('http://www.example.com/') @@ -24,11 +23,11 @@ context 'with json response' do it 'returns 200 with json data' do - post '/subscribers', format: :json, chimpy_subscriber: { email: 'foo2@bar.com', subscribed: true } + post '/subscribers', params: { format: :json, chimpy_subscriber: { email: 'foo2@bar.com', subscribed: true } } expect(response).to be_success json_response = JSON.parse(response.body) expect(json_response['email']).to eq('foo2@bar.com') end end -end \ No newline at end of file +end diff --git a/spec/support/spree.rb b/spec/support/spree.rb index 78898c1..d643401 100644 --- a/spec/support/spree.rb +++ b/spec/support/spree.rb @@ -1,10 +1,9 @@ require 'spree/testing_support/factories' +require 'spree/testing_support/url_helpers' require 'spree/testing_support/controller_requests' require 'spree/testing_support/authorization_helpers' -require 'spree/testing_support/url_helpers' require 'spree/testing_support/capybara_ext' RSpec.configure do |config| config.include Spree::TestingSupport::UrlHelpers - config.include Spree::TestingSupport::ControllerRequests -end \ No newline at end of file +end diff --git a/spree_chimpy.gemspec b/spree_chimpy.gemspec index 27ecdcb..f64f3d5 100644 --- a/spree_chimpy.gemspec +++ b/spree_chimpy.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_chimpy' - s.version = '2.0.0.alpha' + s.version = '3.3.0' s.summary = 'MailChimp/Spree integration using the mailchimp gem' s.description = s.summary s.required_ruby_version = '>= 1.9.3' @@ -17,20 +17,24 @@ Gem::Specification.new do |s| s.require_path = 'lib' s.requirements << 'none' - s.add_dependency 'spree_core', '~> 2.1' + s.add_dependency 'spree_core', '>= 3.1.0', '< 4.0' + s.add_dependency 'spree_extension' s.add_dependency 'gibbon', '~> 2.2' - s.add_development_dependency 'rspec-rails', '~> 2.14' + s.add_development_dependency 'rspec-rails' s.add_development_dependency 'rubocop' - s.add_development_dependency 'capybara', '~> 2.2.1' + s.add_development_dependency 'capybara' s.add_development_dependency 'poltergeist' - s.add_development_dependency 'factory_girl', '~> 4.4' - s.add_development_dependency 'shoulda-matchers', '~> 2.5' - s.add_development_dependency 'sqlite3', '~> 1.3.9' - s.add_development_dependency 'simplecov', '0.7.1' - s.add_development_dependency 'database_cleaner', '1.2.0' - s.add_development_dependency 'coffee-rails', '~> 4.0.1' - s.add_development_dependency 'sass-rails', '~> 4.0.2' + s.add_development_dependency 'factory_girl' + s.add_development_dependency 'shoulda-matchers' + s.add_development_dependency 'sqlite3' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'database_cleaner' + s.add_development_dependency 'coffee-rails' + s.add_development_dependency 'sass-rails' s.add_development_dependency 'ffaker' s.add_development_dependency 'launchy' + s.add_development_dependency 'appraisal' + s.add_development_dependency 'pg' + s.add_development_dependency 'mysql2' end