Skip to content

Commit

Permalink
fixed #1
Browse files Browse the repository at this point in the history
  • Loading branch information
schmijos committed Jun 2, 2015
1 parent 51864be commit 7cf86c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/spree/base_helper_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def active_for_sale_price product, sale_price
end

def supported_currencies_for_sale_price
supported_currencies || [ _current_currency ]
try(:supported_currencies) || [ _current_currency ]
end

private
Expand Down
26 changes: 26 additions & 0 deletions spec/helpers/base_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'spec_helper'

RSpec.describe Spree::BaseHelper, type: :helper do
describe '#supported_currencies_for_sale_price' do
context '(chaining backwards compatibility)' do
it 'can fallback to hardcoded standard currency' do
expect(helper.supported_currencies_for_sale_price).to eq(['USD'])
end

it 'can fallback to config if present' do
allow(Spree::Config).to receive(:[]).with(:currency).and_return('CHF')
expect(helper.supported_currencies_for_sale_price).to eq(['CHF'])
end

it 'can fallback to current_currency if present (part of newer spree core)' do
allow(helper).to receive(:current_currency).and_return('CHF')
expect(helper.supported_currencies_for_sale_price).to eq(['CHF'])
end

it 'can use spree_multi_currency if present' do
allow(helper).to receive(:supported_currencies).and_return(['CHF'])
expect(helper.supported_currencies_for_sale_price).to eq(['CHF'])
end
end
end
end
2 changes: 1 addition & 1 deletion spree_sale_prices.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_sale_prices'
s.version = '1.0.0'
s.version = '2.4.6'
s.summary = 'Adds sale pricing functionality to Spree Commerce'
s.description = 'Adds sale pricing functionality to Spree Commerce. It enables timed sale planning for different currencies.'
s.required_ruby_version = '>= 1.9.3'
Expand Down

0 comments on commit 7cf86c5

Please sign in to comment.