Skip to content

Commit

Permalink
With a 2-3 store
Browse files Browse the repository at this point in the history
  • Loading branch information
Willianvdv committed Aug 19, 2014
1 parent e248c27 commit 6f52f65
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_JOBS: 3
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
source 'https://rubygems.org'

gem 'coveralls', require: false
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable'
gem 'spree', github: 'spree/spree', branch: '2-2-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-3-stable'
gem 'spree', github: 'spree/spree', branch: '2-3-stable'
gem 'sass-rails', github: 'rails/sass-rails'

group :test do
#gem 'pg'
Expand All @@ -12,7 +13,6 @@ group :test do
end

group :development, :test do
gem 'sprockets-rails', :require => 'sprockets/railtie'
gem 'capybara' #, '~> 2.1'
gem 'selenium-webdriver', require: false
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/spree/checkout_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def completion_route
url_for :controller => 'omnikassa',
:action => 'start',
:payment_id => payment.id,
:token => @order.token
:token => @order.guest_token
else
# This is the original completion route
spree.order_path(@order)
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/spree/omnikassa_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ def success
when '00' # Payment is completed
@payment.send("complete!") if payment.state != 'completed'
flash[:success] = t(:payment_success)
order_url(@order, { token: order.token })
order_url(@order, { token: order.guest_token })

when '60' # Payment is pending (omni received this state from the bank)
@payment.pend! if payment.state != 'pending'
flash[:error] = t(:payment_pending)
omnikassa_pending_url(@payment.id, token: @order.token)
omnikassa_pending_url(@payment.id, token: @order.guest_token)

else # All other states are failures
@payment.send("failure!") if payment.state != 'failed'
flash[:error] = t(:payment_failed)
omnikassa_error_url(@payment.id, token: @order.token)
omnikassa_error_url(@payment.id, token: @order.guest_token)
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/models/spree/omnikassa_payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def merchant_id

def uri
# TODO: Fix protocol
"http://#{Spree::Config['site_url']}"
"http://#{Spree::Store.current.url}"
end

def normal_return_url
"#{uri}/omnikassa/success/#{@payment.id}/?token=#{@payment.order.token}"
"#{uri}/omnikassa/success/#{@payment.id}/?token=#{@payment.order.guest_token}"
end

def automatic_response_url
"#{uri}/omnikassa/success/automatic/#{@payment.id}/?token=#{@payment.order.token}"
"#{uri}/omnikassa/success/automatic/#{@payment.id}/?token=#{@payment.order.guest_token}"
end

def transaction_reference_prefix
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/spree/omnikassa_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
Spree::BillingIntegration::Omnikassa.create! name: 'omnikassa'
Spree::Payment.stub(:find).and_return payment
payment.stub(:order).and_return order
order.stub(:token).and_return(token)
order.stub(:guest_token).and_return(token)
end

describe 'GET restart' do
before :each do
payment.send("started_processing!")
payment.send("failure!")
payment.save!
spree_get(:restart, order_id: order.id, token: order.token)
spree_get(:restart, order_id: order.id, token: order.guest_token)
end

describe 'create a new payment' do
Expand Down
7 changes: 3 additions & 4 deletions spec/features/frontend/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
let!(:omnikassa_payment_method) { create(:omnikassa_payment_method, environment: 'test') }

before do
# page.driver.headers = { "Accept-Language" => "en-us" } # We want the dutch omnikassa
Spree::Store.current.url = '127.0.0.1:54979'
Spree::Store.current.save!(validate: false)

reset_spree_preferences do |config|
config.site_url = '127.0.0.1:54979'

config.currency = "EUR"
config.omnikassa_url = 'https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet'
config.omnikassa_merchant_id = '002020000000001'
Expand Down Expand Up @@ -41,7 +40,7 @@
it 'success after omnikassa' do
goto_omnikassa
do_omnikassa_ideal_payment
expect(current_path).to eq('/omnikassa/success/1/')
expect(current_path).to eq('/success/1/')
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
end

config.include FactoryGirl::Syntax::Methods

config.include Spree::TestingSupport::Preferences
config.include Spree::TestingSupport::UrlHelpers
config.include Spree::TestingSupport::ControllerRequests
Expand All @@ -106,9 +107,12 @@

shared_context 'omnikassa' do
before do
store = create :store, url: 'test.host'
Spree::Store.stub(:current).and_return(store)

reset_spree_preferences do |config|
config.site_url = 'test.host'
config.currency = "EUR"
config.currency = 'EUR'

config.omnikassa_merchant_id = '1337'
config.omnikassa_transaction_reference_prefix = 'PREFIX'
config.omnikassa_key_version = '7'
Expand Down
5 changes: 2 additions & 3 deletions spree_omnikassa.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.add_dependency 'spree_core', '~> 2.2'
s.add_dependency 'spree_core', '~> 2.3'

s.add_development_dependency 'capybara', '~> 2.1'
s.add_development_dependency 'database_cleaner'
s.add_development_dependency 'rspec-rails', '~> 2.13'
s.add_development_dependency 'factory_girl', '~> 4.2'
s.add_development_dependency 'factory_girl' #, '~> 4.2'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'launchy'
s.add_development_dependency 'coffee-rails'

end

0 comments on commit 6f52f65

Please sign in to comment.