Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
update to spree 3-3
Browse files Browse the repository at this point in the history
  • Loading branch information
bbonislawski committed Sep 27, 2017
1 parent a1b0d43 commit 5ea6ffa
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ spec/dummy
.bundle
.node-version
.ruby-version
gemfiles/*.lock
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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'@'%';"
23 changes: 23 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion db/migrate/20130422122600_add_subscribed_to_spree_users.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/201304241925_create_order_sources.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20130509170447_create_subscriber.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 9 additions & 0 deletions gemfiles/spree_3_1.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_3_2.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_3_3.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
9 changes: 9 additions & 0 deletions gemfiles/spree_master.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
4 changes: 2 additions & 2 deletions lib/spree/chimpy/controller_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions lib/spree/chimpy/interface/products.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
end
1 change: 1 addition & 0 deletions lib/spree_chimpy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spree_core'
require 'spree_extension'
require 'spree/chimpy/engine'
require 'spree/chimpy/subscription'
require 'spree/chimpy/workers/delayed_job'
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/controller_filters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/spree/chimpy/subscribers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
8 changes: 4 additions & 4 deletions spec/features/spree/admin/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
15 changes: 3 additions & 12 deletions spec/features/spree/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,23 @@
end

scenario 'guest subscription deface data-hook confirmation' do
skip 'its not set by default'
page.find('#footer-right')
end

scenario 'user subscription with opt_in' do
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'

Expand Down
2 changes: 1 addition & 1 deletion spec/models/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions spec/requests/subscribers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
require 'spec_helper'

describe 'Subscribers' do

context 'with valid subscription' do
it 'redirects to referer' do
post '/subscribers',
{ chimpy_subscriber: { email: '[email protected]', subscribed: true } },
{ referer: 'http://foo.bar' }
post '/subscribers', params: {
chimpy_subscriber: { email: '[email protected]', subscribed: true } },
headers: { referer: 'http://foo.bar' }

expect(response).to be_redirect
expect(response.location).to eq('http://foo.bar')
end

it 'redirects to root URL if no referer' do
post '/subscribers',
{ chimpy_subscriber: { email: '[email protected]', subscribed: true } },
{ referer: nil }
params: { chimpy_subscriber: { email: '[email protected]', subscribed: true } },
headers: { referer: nil }

expect(response).to be_redirect
expect(response.location).to eq('http://www.example.com/')
Expand All @@ -24,11 +23,11 @@

context 'with json response' do
it 'returns 200 with json data' do
post '/subscribers', format: :json, chimpy_subscriber: { email: '[email protected]', subscribed: true }
post '/subscribers', params: { format: :json, chimpy_subscriber: { email: '[email protected]', subscribed: true } }

expect(response).to be_success
json_response = JSON.parse(response.body)
expect(json_response['email']).to eq('[email protected]')
end
end
end
end
5 changes: 2 additions & 3 deletions spec/support/spree.rb
Original file line number Diff line number Diff line change
@@ -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
end
26 changes: 15 additions & 11 deletions spree_chimpy.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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

0 comments on commit 5ea6ffa

Please sign in to comment.