Skip to content
This repository was archived by the owner on Mar 6, 2019. It is now read-only.

Upgrade to spree 3.2 #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree', '~> 3.2.0.rc3'
# Provides basic authentication functionality for testing parts of your engine
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
gem 'spree_auth_devise', '~> 3.2.0.beta'

gem "codeclimate-test-reporter", group: :test, require: nil

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
SpreeMollie
===========

Except payments using the [Mollie](https://www.mollie.com) payment provider in Spree

**NOTE This is currently only implemented agains Spree master (3.0.0.beta)**
Accept payments using the [Mollie](https://www.mollie.com) payment provider in Spree

[![wercker status](https://app.wercker.com/status/52c82d6a6ba0e8d59a4bde329939e420/m "wercker status")](https://app.wercker.com/project/bykey/52c82d6a6ba0e8d59a4bde329939e420)

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/spree/mollie_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MollieController < Spree::BaseController
def notify
MolliePaymentService.new(payment_id: params[:id]).update_payment_status

render nothing: true, status: :ok
head :ok
end

def check_payment_status
Expand Down
6 changes: 4 additions & 2 deletions spec/controllers/admin_payments_controller_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require 'spec_helper'

RSpec.describe Spree::Admin::PaymentsController do

routes { Spree::Core::Engine.routes }
stub_authorization!

context 'when payment is complete' do
before do
@order = create(:order_paid_by_mollie)
Expand All @@ -13,7 +15,7 @@
it 'refunding changes state to void' do
VCR.use_cassette('refund_success') do
expect {
post :mollie_refund, order_id: @order.id, id: @payment.id, use_route: :spree
post :mollie_refund, params: { order_id: @order.id, id: @payment.id }
}.to change{ @order.reload.payments.last.state }.from('completed').to('void')
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/controllers/checkout_controller_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require 'spec_helper'
RSpec.describe Spree::CheckoutController do

routes { Spree::Core::Engine.routes }

before :each do
@order = create(:order_with_totals)
end

describe 'Checkout payment:' do
it 'prepare payment for Mollie' do
expect(lambda {patch :update, payment_method_id: 1, state: 'open', use_route: :spree}).
to raise_error(NoMethodError)
expect(patch :update, params: { payment_method_id: 1, state: 'open'}).
to redirect_to(cart_path)
end
end
end
19 changes: 9 additions & 10 deletions spec/controllers/mollie_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

RSpec.describe Spree::MollieController do

routes {Spree::Core::Engine.routes}

shared_examples 'mollie payment is' do |state, order_id|
let(:order) do
order = create(:order_with_pending_mollie_payment)
order
end
let(:order) { create :order_with_pending_mollie_payment }

it "payment returns the #{state} state" do
VCR.use_cassette("get_status_#{state}") do
Expand All @@ -21,28 +20,28 @@

context '#check_payment_status' do
it_behaves_like 'mollie payment is', 'paid', 'tr_dkiVfRMs4W' do
let(:request_to_controller) { Proc.new { get :check_payment_status, order_id: order.number, use_route: :spree } }
let(:request_to_controller) { Proc.new { get :check_payment_status, params: { order_id: order.number }}}
end

it_behaves_like 'mollie payment is', 'failed', 'tr_kKFSWQRRwy' do
let(:request_to_controller) { Proc.new { get :check_payment_status, order_id: order.number, use_route: :spree } }
let(:request_to_controller) { Proc.new { get :check_payment_status, params: { order_id: order.number }}}
end
end

context '#notify' do
it_behaves_like 'mollie payment is', 'paid', 'tr_dkiVfRMs4W' do
let(:request_to_controller) { Proc.new { post :notify, id: 'tr_dkiVfRMs4W', use_route: :spree } }
let(:request_to_controller) { Proc.new { post :notify, params: { id: 'tr_dkiVfRMs4W' }}}
end

it_behaves_like 'mollie payment is', 'failed', 'tr_kKFSWQRRwy' do
let(:request_to_controller) { Proc.new { post :notify, id: 'tr_kKFSWQRRwy', use_route: :spree } }
let(:request_to_controller) { Proc.new { post :notify, params: { id: 'tr_kKFSWQRRwy' }}}
end

describe "when no PaymentMethod available" do
let(:order) { create(:completed_order_with_pending_payment) }

it 'raises NoMethodError' do
expect(lambda { post :notify, id: 'TEST_ID', status: 'paid', use_route: :spree}).
expect(lambda { post :notify, params: { id: 'TEST_ID', status: 'paid'}}).
to raise_error(NoMethodError)
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/features/admin/order/mollie_payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

stub_authorization!

let!(:country) { create(:country, name: 'United States of America', iso: 'US') }
let!(:state) { create(:state, name: "Alabama", country: country, abbr: 'AL') }
let!(:product) { create(:product, :name => 'iPad') }
let!(:shipping_method) { create(:shipping_method) }
before(:each) do
Expand All @@ -26,8 +28,6 @@ def fill_in_billing
end

def prepare_order_for_payment
page.driver.block_unknown_urls
page.driver.allow_url("www.mollie.com")
visit spree.root_path
click_link 'iPad'
click_button 'Add To Cart'
Expand Down Expand Up @@ -61,7 +61,7 @@ def emulate_checkout_pay_flow(expected_redirect)
expect(get "/mollie/check_status/#{@order.number}").to redirect_to expected_redirect

# emulate mollie#notify call from external api
post '/mollie/notify', id: Spree::Payment.last.transaction_id, use_route: :spree
post '/mollie/notify', params: { id: Spree::Payment.last.transaction_id }
end

def cancel_order
Expand Down Expand Up @@ -104,7 +104,7 @@ def pay_for_order_with_creditcard
end

specify do
find('#payment_status').should have_content(expected_payment_status)
expect(find('#payment_status')).to have_content(expected_payment_status)
end

it 'can see transaction id' do
Expand Down
11 changes: 8 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
require 'simplecov'
SimpleCov.start

# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
Expand Down Expand Up @@ -27,7 +27,8 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include Rails.application.routes.url_helpers

config.include Devise::TestHelpers, type: :controller

# Infer an example group's spec type from the file location.
config.infer_spec_type_from_file_location!

Expand Down Expand Up @@ -80,6 +81,10 @@

require 'capybara-webkit'
Capybara.javascript_driver = ENV['USE_SELENIUM_FOR_CAPYBARA'] ? :selenium : :webkit
Capybara::Webkit.configure do |config|
config.block_unknown_urls
config.allow_url("www.mollie.com")
end

# Add VCR support.
require 'vcr'
Expand Down
6 changes: 3 additions & 3 deletions spree_mollie.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_mollie'
s.version = '3.1.0.beta'
s.version = '3.2.0.rc3'
s.summary = 'Use the Mollie PSP in your Spree storefront'
s.description = s.summary
s.required_ruby_version = '>= 2.0.0'
Expand All @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.add_dependency 'spree_core', '~> 3.1.0.beta'
s.add_dependency 'spree_core', '~> 3.2.0.rc3'
s.add_dependency 'mollie-ruby', '0.2.0'

s.add_development_dependency 'capybara', '~> 2.4'
Expand All @@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'factory_girl', '~> 4.5'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'rspec-rails', '~> 3.1'
s.add_development_dependency 'sass-rails', '~> 4.0.2'
s.add_development_dependency 'sass-rails', '~> 5.0.6'
s.add_development_dependency 'selenium-webdriver'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'sqlite3'
Expand Down