spree_multi_currency 1.0.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +0 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +21 -3
- data/README.markdown +8 -0
- data/Rakefile +4 -2
- data/app/assets/javascripts/admin/spree_multi_currency.js +0 -0
- data/app/assets/javascripts/store/spree_multi_currency.js +0 -0
- data/app/assets/stylesheets/admin/spree_multi_currency.css +0 -0
- data/app/assets/stylesheets/store/spree_multi_currency.css +0 -0
- data/app/controllers/spree/admin/currencies_controller.rb +3 -1
- data/app/controllers/spree/admin/currency_converters_controller.rb +2 -0
- data/app/controllers/spree/base_controller_decorator.rb +5 -2
- data/app/controllers/spree/currency_controller.rb +7 -2
- data/app/helpers/base_helper_decorator.rb +8 -0
- data/app/helpers/number_helper_decorator.rb +19 -17
- data/app/models/spree/adjustment_decorator.rb +2 -0
- data/app/models/spree/controller_helper_order.rb +11 -0
- data/app/models/spree/currency.rb +82 -38
- data/app/models/spree/currency_converter.rb +2 -0
- data/app/models/spree/line_item_decorator.rb +19 -6
- data/app/models/spree/money_decorator.rb +15 -0
- data/app/models/spree/order_decorator.rb +63 -55
- data/app/models/spree/product_decorator.rb +33 -0
- data/app/models/spree/stock/estimator_decorator.rb +18 -0
- data/app/models/spree/variant_decorator.rb +93 -16
- data/app/overrides/add_currencies_admin_configurations_menu.rb +8 -7
- data/app/overrides/add_currency_selection.rb +15 -0
- data/app/views/spree/admin/currencies/new.html.erb +4 -4
- data/app/views/spree/admin/currency_converters/edit.html.erb +4 -4
- data/app/views/spree/admin/currency_converters/new.html.erb +3 -3
- data/config/routes.rb +2 -0
- data/db/migrate/20101109134351_create_currencies.rb +2 -0
- data/db/migrate/20101109134453_create_currency_converters.rb +2 -0
- data/db/seeds.rb +2 -0
- data/features/step_definitions/product.rb +2 -0
- data/features/support/env.rb +2 -0
- data/features/support/paths.rb +2 -0
- data/lib/generators/spree_multi_currency/install/install_generator.rb +27 -15
- data/lib/spree_multi_currency.rb +13 -9
- data/lib/spree_multi_currency/engine.rb +6 -0
- data/lib/tasks/spree_multi_currency.rake +57 -38
- data/spec/changing_currency_spec.rb +44 -15
- data/spec/controllers/spree/currency_controller_spec.rb +16 -0
- data/spec/features/buy_spec.rb +103 -0
- data/spec/helpers/number_helper_spec.rb +21 -0
- data/spec/models/spree/currency_spec.rb +32 -0
- data/spec/models/spree/variant_spec.rb +32 -0
- data/spec/spec_helper.rb +50 -10
- data/spree_multi_currency.gemspec +2 -4
- metadata +29 -34
- data.tar.gz.sig +0 -3
- data/Versionfile +0 -9
- metadata.gz.sig +0 -1
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe ActionView::Helpers::NumberHelper do
|
6
|
+
context 'number_to_currency' do
|
7
|
+
specify do
|
8
|
+
Spree::Currency.create!(num_code: '840', char_code: 'USD', name: 'usd', locale: 'en')
|
9
|
+
Spree::Currency.create!(num_code: '643', char_code: 'RUB', name: 'rub', locale: 'ru')
|
10
|
+
I18n.locale = 'en'
|
11
|
+
Spree::Currency.current!
|
12
|
+
number_to_currency(100.2).should == '$100.20'
|
13
|
+
number_to_currency(-2.12).should == '-2.12 $'
|
14
|
+
I18n.locale = 'ru'
|
15
|
+
Spree::Currency.current!
|
16
|
+
number_to_currency(10).should == '10.00 руб.'
|
17
|
+
number_to_currency('11').should == '11.00 руб.'
|
18
|
+
number_to_currency(-10.23).should == '-10.23 руб.'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Currency do
|
4
|
+
before :each do
|
5
|
+
@rub = Spree::Currency.create(name: 'rubles', char_code: 'RUB',
|
6
|
+
num_code: 623, locale: 'ru', basic: false)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'set basic' do
|
10
|
+
@rub.basic!
|
11
|
+
@rub.basic.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return locale without spliting' do
|
15
|
+
@rub.locale = 'en,ru'
|
16
|
+
@rub.locale.should == ['en','ru']
|
17
|
+
@rub.locale(false).should == 'en,ru'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should write error message' do
|
21
|
+
ex = Exception.new
|
22
|
+
ex.set_backtrace(['1','2'])
|
23
|
+
mess = " [ Currency ] :#{ex.inspect} \n #{ex.backtrace.join('\n ')}"
|
24
|
+
Rails.logger.should_receive(:error).with(mess)
|
25
|
+
Spree::Currency.error_logger(ex)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'get currency by num code' do
|
29
|
+
Spree::Currency.get(623).should == @rub
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Variant do
|
4
|
+
it 'check variant without basic_price and current_price' do
|
5
|
+
Spree::Config.currency = 'USD'
|
6
|
+
rub = Spree::Currency.create(name: 'rubles', char_code: 'RUB',
|
7
|
+
num_code: 623, locale: 'ru', basic: false)
|
8
|
+
eur = Spree::Currency.create(name: 'euro', char_code: 'EUR',
|
9
|
+
num_code: 678, locale: 'de', basic: false)
|
10
|
+
usd = Spree::Currency.create(name: 'dollars', char_code: 'USD',
|
11
|
+
num_code: 624, locale: 'en', basic: true)
|
12
|
+
|
13
|
+
Spree::CurrencyConverter.create!(nominal: 1.0, value: 1/32.0,
|
14
|
+
currency: rub, date_req: Time.now)
|
15
|
+
|
16
|
+
Spree::CurrencyConverter.create!(nominal: 1.0, value: 1/0.75,
|
17
|
+
currency: eur, date_req: Time.now)
|
18
|
+
|
19
|
+
@product = create(:base_product, name: 'product1')
|
20
|
+
@product.save!
|
21
|
+
|
22
|
+
|
23
|
+
variant = @product.master
|
24
|
+
variant.prices.destroy_all
|
25
|
+
variant.prices.create!(currency: rub.char_code,
|
26
|
+
amount: 100)
|
27
|
+
Spree::Currency.current!(eur)
|
28
|
+
variant.get_price.should == ((100/32.0)*0.75).round(2)
|
29
|
+
Spree::Currency.current!(usd)
|
30
|
+
variant.get_price.should == (100/32.0).round(2)
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,57 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter '/spec/'
|
13
|
+
add_group 'Controllers', 'app/controllers'
|
14
|
+
add_group 'Helpers', 'app/helpers'
|
15
|
+
add_group 'Models', 'app/models'
|
16
|
+
add_group 'Overrides', 'app/overrides'
|
17
|
+
add_group 'Libraries', 'lib'
|
18
|
+
end
|
19
|
+
|
20
|
+
ENV['RAILS_ENV'] = 'test'
|
21
|
+
|
22
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
23
|
+
|
5
24
|
require 'rspec/rails'
|
25
|
+
require 'capybara/rspec'
|
26
|
+
require 'capybara/webkit'
|
27
|
+
require 'ffaker'
|
28
|
+
require 'database_cleaner'
|
6
29
|
|
7
|
-
|
8
|
-
# in ./support/ and its subdirectories.
|
9
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
30
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
10
31
|
|
11
|
-
require 'spree/
|
32
|
+
require 'spree/testing_support/factories'
|
33
|
+
require 'spree/testing_support/controller_requests'
|
34
|
+
require 'spree/testing_support/authorization_helpers'
|
35
|
+
require 'spree/testing_support/url_helpers'
|
36
|
+
|
37
|
+
Dir[File.join(File.dirname(__FILE__), 'factories/*.rb')].each { |f| require f }
|
12
38
|
|
13
39
|
RSpec.configure do |config|
|
14
|
-
config.
|
40
|
+
config.include Capybara::DSL, type: [:request,:feature]
|
41
|
+
config.include Spree::TestingSupport::ControllerRequests
|
42
|
+
config.include FactoryGirl::Syntax::Methods
|
43
|
+
config.include Spree::TestingSupport::UrlHelpers
|
44
|
+
|
45
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :feature
|
46
|
+
|
47
|
+
config.before do
|
48
|
+
DatabaseCleaner.strategy = :truncation
|
49
|
+
DatabaseCleaner.start
|
50
|
+
end
|
51
|
+
|
52
|
+
config.after do
|
53
|
+
DatabaseCleaner.clean
|
54
|
+
end
|
15
55
|
|
16
|
-
|
56
|
+
Capybara.javascript_driver = :webkit
|
17
57
|
end
|
@@ -4,7 +4,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.name = 'spree_multi_currency'
|
7
|
-
s.version = '
|
7
|
+
s.version = '2.0.0'
|
8
8
|
s.summary = 'Add gem summary here'
|
9
9
|
s.required_ruby_version = '>= 1.8.7'
|
10
10
|
s.authors = ["Pronix LLC"]
|
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = "http://nanopodcast-pronix.rhcloud.com/"
|
13
13
|
s.summary = %q{spree_multi_currency}
|
14
14
|
s.description = %q{spree_multi_currency}
|
15
|
-
s.signing_key = '/home/dima/.gem/keys/gem-private_key.pem'
|
16
|
-
s.cert_chain = ['/home/dima/.gem/keys/gem-public_cert.pem']
|
17
15
|
|
18
16
|
# s.rubyforge_project = "spree-multi-currency"
|
19
17
|
|
@@ -23,7 +21,7 @@ Gem::Specification.new do |s|
|
|
23
21
|
|
24
22
|
s.require_path = ['lib']
|
25
23
|
|
26
|
-
s.add_dependency('spree_core', '>=
|
24
|
+
s.add_dependency('spree_core', '>= 2.0.3')
|
27
25
|
s.add_dependency('nokogiri', '>= 1.4.4')
|
28
26
|
s.add_dependency('money', '>= 5.0.0')
|
29
27
|
s.add_dependency('json', '>= 1.5.1')
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_multi_currency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Pronix LLC
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
-
|
13
|
-
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURQakNDQWlhZ0F3SUJB
|
14
|
-
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJGTVJjd0ZRWURWUVFEREE1d2Nt
|
15
|
-
OXUKYVhndWMyVnlkbWxqWlRFVk1CTUdDZ21TSm9tVDhpeGtBUmtXQldkdFlX
|
16
|
-
bHNNUk13RVFZS0NaSW1pWlB5TEdRQgpHUllEWTI5dE1CNFhEVEV6TURNeU16
|
17
|
-
RXhNVGcxTTFvWERURTBNRE15TXpFeE1UZzFNMW93UlRFWE1CVUdBMVVFCkF3
|
18
|
-
d09jSEp2Ym1sNExuTmxjblpwWTJVeEZUQVRCZ29Ka2lhSmsvSXNaQUVaRmdW
|
19
|
-
bmJXRnBiREVUTUJFR0NnbVMKSm9tVDhpeGtBUmtXQTJOdmJUQ0NBU0l3RFFZ
|
20
|
-
SktvWklodmNOQVFFQkJRQURnZ0VQQURDQ0FRb0NnZ0VCQU51awo3U2R5Uzcy
|
21
|
-
ckc4ZDJvaWFMWkhDQnRkQTh2blZSbUhtYzBjQ0NsT3d2V3U3dk1rbGhSWjlz
|
22
|
-
WVNIMlFvR3U5cVNXCnpzVUE2c1JFZ05iSnV5dHFiNjNmdDAvVG1XZVJDUHEx
|
23
|
-
Ulh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mIwZ0NzTzNMVnVmTXNieWZkeVQKLS0tLS1FTkQgQ0VS
|
39
|
-
VElGSUNBVEUtLS0tLQo=
|
40
|
-
date: 2013-03-23 00:00:00.000000000 Z
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
41
13
|
dependencies:
|
42
14
|
- !ruby/object:Gem::Dependency
|
43
15
|
name: spree_core
|
@@ -46,7 +18,7 @@ dependencies:
|
|
46
18
|
requirements:
|
47
19
|
- - ! '>='
|
48
20
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
21
|
+
version: 2.0.3
|
50
22
|
type: :runtime
|
51
23
|
prerelease: false
|
52
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -54,7 +26,7 @@ dependencies:
|
|
54
26
|
requirements:
|
55
27
|
- - ! '>='
|
56
28
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
29
|
+
version: 2.0.3
|
58
30
|
- !ruby/object:Gem::Dependency
|
59
31
|
name: nokogiri
|
60
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,24 +115,36 @@ executables: []
|
|
143
115
|
extensions: []
|
144
116
|
extra_rdoc_files: []
|
145
117
|
files:
|
118
|
+
- .coveralls.yml
|
146
119
|
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- .travis.yml
|
147
122
|
- Gemfile
|
148
123
|
- LICENSE
|
149
124
|
- README.markdown
|
150
125
|
- Rakefile
|
151
|
-
-
|
126
|
+
- app/assets/javascripts/admin/spree_multi_currency.js
|
127
|
+
- app/assets/javascripts/store/spree_multi_currency.js
|
128
|
+
- app/assets/stylesheets/admin/spree_multi_currency.css
|
129
|
+
- app/assets/stylesheets/store/spree_multi_currency.css
|
152
130
|
- app/controllers/spree/admin/currencies_controller.rb
|
153
131
|
- app/controllers/spree/admin/currency_converters_controller.rb
|
154
132
|
- app/controllers/spree/base_controller_decorator.rb
|
155
133
|
- app/controllers/spree/currency_controller.rb
|
134
|
+
- app/helpers/base_helper_decorator.rb
|
156
135
|
- app/helpers/number_helper_decorator.rb
|
157
136
|
- app/models/spree/adjustment_decorator.rb
|
137
|
+
- app/models/spree/controller_helper_order.rb
|
158
138
|
- app/models/spree/currency.rb
|
159
139
|
- app/models/spree/currency_converter.rb
|
160
140
|
- app/models/spree/line_item_decorator.rb
|
141
|
+
- app/models/spree/money_decorator.rb
|
161
142
|
- app/models/spree/order_decorator.rb
|
143
|
+
- app/models/spree/product_decorator.rb
|
144
|
+
- app/models/spree/stock/estimator_decorator.rb
|
162
145
|
- app/models/spree/variant_decorator.rb
|
163
146
|
- app/overrides/add_currencies_admin_configurations_menu.rb
|
147
|
+
- app/overrides/add_currency_selection.rb
|
164
148
|
- app/views/spree/admin/currencies/_form.html.erb
|
165
149
|
- app/views/spree/admin/currencies/edit.html.erb
|
166
150
|
- app/views/spree/admin/currencies/index.html.erb
|
@@ -190,6 +174,11 @@ files:
|
|
190
174
|
- lib/tasks/spree_multi_currency.rake
|
191
175
|
- script/rails
|
192
176
|
- spec/changing_currency_spec.rb
|
177
|
+
- spec/controllers/spree/currency_controller_spec.rb
|
178
|
+
- spec/features/buy_spec.rb
|
179
|
+
- spec/helpers/number_helper_spec.rb
|
180
|
+
- spec/models/spree/currency_spec.rb
|
181
|
+
- spec/models/spree/variant_spec.rb
|
193
182
|
- spec/spec_helper.rb
|
194
183
|
- spree_multi_currency.gemspec
|
195
184
|
homepage: http://nanopodcast-pronix.rhcloud.com/
|
@@ -223,4 +212,10 @@ test_files:
|
|
223
212
|
- features/support/env.rb
|
224
213
|
- features/support/paths.rb
|
225
214
|
- spec/changing_currency_spec.rb
|
215
|
+
- spec/controllers/spree/currency_controller_spec.rb
|
216
|
+
- spec/features/buy_spec.rb
|
217
|
+
- spec/helpers/number_helper_spec.rb
|
218
|
+
- spec/models/spree/currency_spec.rb
|
219
|
+
- spec/models/spree/variant_spec.rb
|
226
220
|
- spec/spec_helper.rb
|
221
|
+
has_rdoc:
|
data.tar.gz.sig
DELETED
data/Versionfile
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# This file is used to designate compatibilty with different versions of Spree
|
2
|
-
# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
|
3
|
-
|
4
|
-
# Examples
|
5
|
-
#
|
6
|
-
"0.50.x" => { :branch => "master" }
|
7
|
-
"0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
|
8
|
-
|
9
|
-
|
metadata.gz.sig
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
[ ��`��>�=�ņ�|gٗ�"���~!�\�^8�G4Yf��{GJ���#����ك:��sx��)ꏱ�����=�s��毮�<��? 0@����*1�\��Z�W�����#0�n�w�$�<)9��d�~�@�$�8�,��*2`ƻ�TǴ��8�Q�0��e�;N��{�W_g�Jn�@�)�0з��6L6*j��j�4���k���k���1����?SP*��1#�g<�zD��
|