multi_currencies 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+ Feature: Visiting products and change currency
2
+
3
+ Background:
4
+ Given the following taxonomies exist:
5
+ | name |
6
+ | Brand |
7
+ | Categories |
8
+ Given the custom taxons and custom products exist
9
+
10
+ Scenario: show page
11
+ When I go to the home page
12
+ When change currency to "usd"
13
+ When I click first link from selector "ul.product-listing a"
14
+ Then I should see "$17.99"
15
+ When change currency to "rub"
16
+ When I click first link from selector "ul.product-listing a"
17
+ Then I should see "494.76 руб."
18
+
19
+ Scenario: make order and change currency between each step
20
+ When I go to the home page
21
+ And I click first link from selector "ul.product-listing a"
22
+ And push "add to cart"
23
+ When click checkout
24
+ When I fill in "order_email" with "test@test.com"
25
+ And I press Continue
26
+ And I fill shipping address with correct data
27
+ And I fill billing address with correct data
28
+ And I press Save and Continue
29
+ And I choose "UPS Ground" as shipping method
30
+ And I enter valid credit card details
31
+ Then I should see "630"
32
+ Then show page
@@ -0,0 +1,124 @@
1
+ Given /^the custom taxons and custom products exist$/ do
2
+ Fixtures.reset_cache
3
+ fixtures_folder = File.join(Rails.root.to_s, 'db', 'sample')
4
+ fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
5
+ Fixtures.create_fixtures(fixtures_folder, fixtures)
6
+ =begin
7
+ PaymentMethod.create(
8
+ :name => 'Credit Card',
9
+ :description => 'Bogus payment gateway for development.',
10
+ :environment => 'cucumber',
11
+ :active => true,
12
+ :type => Gateway::Bogus)
13
+ =end
14
+ end
15
+
16
+ Then /^verify products listing for top search result$/ do
17
+ page.all('ul.product-listing li').size.should == 1
18
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
19
+ tmp.delete("")
20
+ tmp.sort!.should == ["Ruby on Rails Ringer T-shirt $17.99"]
21
+ end
22
+
23
+ Then /^verify products listing for Ruby on Rails brand$/ do
24
+ page.all('ul.product-listing li').size.should == 7
25
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
26
+ tmp.delete("")
27
+ array = ["Ruby on Rails Bag $22.99",
28
+ "Ruby on Rails Baseball Jersey $19.99",
29
+ "Ruby on Rails Jr. Spaghetti $19.99",
30
+ "Ruby on Rails Mug $13.99",
31
+ "Ruby on Rails Ringer T-shirt $17.99",
32
+ "Ruby on Rails Stein $16.99",
33
+ "Ruby on Rails Tote $15.99"]
34
+ tmp.sort!.should == array
35
+ end
36
+
37
+ Then /^verify products listing for Ruby brand$/ do
38
+ page.all('ul.product-listing li').size.should == 1
39
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
40
+ tmp.delete("")
41
+ tmp.sort!.should == ["Ruby Baseball Jersey $19.99"]
42
+ end
43
+
44
+ Then /^verify products listing for Apache brand$/ do
45
+ page.all('ul.product-listing li').size.should == 1
46
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
47
+ tmp.delete("")
48
+ tmp.sort!.should == ["Apache Baseball Jersey $19.99"]
49
+ end
50
+
51
+ Then /^verify products listing for Clothing category$/ do
52
+ page.all('ul.product-listing li').size.should == 5
53
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
54
+ tmp.delete("")
55
+ tmp.sort!.should == ["Apache Baseball Jersey $19.99",
56
+ "Ruby Baseball Jersey $19.99",
57
+ "Ruby on Rails Baseball Jersey $19.99",
58
+ "Ruby on Rails Jr. Spaghetti $19.99",
59
+ "Ruby on Rails Ringer T-shirt $17.99"]
60
+ end
61
+
62
+ Then /^verify products listing for Bags category$/ do
63
+ page.all('ul.product-listing li').size.should == 2
64
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
65
+ tmp.delete("")
66
+ tmp.sort!.should == ["Ruby on Rails Bag $22.99", "Ruby on Rails Tote $15.99"]
67
+ end
68
+
69
+ Then /^verify products listing for Mugs category$/ do
70
+ page.all('ul.product-listing li').size.should == 2
71
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
72
+ tmp.delete("")
73
+ tmp.sort!.should == ["Ruby on Rails Mug $13.99", "Ruby on Rails Stein $16.99"]
74
+ end
75
+
76
+ Then /^verify products listing for price range search 15-18$/ do
77
+ page.all('ul.product-listing li').size.should == 3
78
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
79
+ tmp.delete("")
80
+ tmp.sort!.should == ["Ruby on Rails Ringer T-shirt $17.99", "Ruby on Rails Stein $16.99", "Ruby on Rails Tote $15.99"]
81
+ end
82
+
83
+ Then /^verify products listing for price range search 18 and above$/ do
84
+ page.all('ul.product-listing li').size.should == 3
85
+ tmp = page.all('ul.product-listing li a').map(&:text).flatten.compact
86
+ tmp.delete("")
87
+ tmp.sort!.should == ["Ruby on Rails Bag $22.99",
88
+ "Ruby on Rails Baseball Jersey $19.99",
89
+ "Ruby on Rails Jr. Spaghetti $19.99"]
90
+ end
91
+
92
+
93
+ Then /^I should get a "(\d+) ([^"]+)" response$/ do |http_status, message|
94
+ #response.status.should == "#{http_status} #{message}" # webrat
95
+ page.driver.status_code.should == http_status.to_i # capybara
96
+ end
97
+
98
+ When /^change currency to "([^"]*)"$/ do |arg1|
99
+ visit "/currency/#{arg1}"
100
+ end
101
+
102
+ Then /^show page$/ do
103
+ save_and_open_page
104
+ end
105
+
106
+ When /^push "add to cart"$/ do
107
+ page.find(:xpath, "//button").click
108
+ end
109
+
110
+ When /^click checkout$/ do
111
+ page.find(:xpath,"//a[@href='/checkout']").click
112
+ end
113
+
114
+ When /^I press Continue$/ do
115
+ page.find(:xpath,"//input[@value='Continue']").click
116
+ end
117
+
118
+ When /^I press Save and Continue$/ do
119
+ page.find(:xpath,"//input[@value='Save and Continue']").click
120
+ end
121
+
122
+ Then /^sleep$/ do
123
+ sleep 100
124
+ end
@@ -0,0 +1,16 @@
1
+ FEATURES_PATH = File.expand_path('../..', __FILE__)
2
+ # require define path to spree project
3
+ ENV['SPREE_GEM_PATH'] = "/home/dima/project/spree"
4
+ # or define spree as gem in Gemfile
5
+ # and decomment this
6
+ # gemfile = Pathname.new("Gemfile").expand_path
7
+ # lockfile = gemfile.dirname.join('Gemfile.lock')
8
+ # definition = Bundler::Definition.build(gemfile, lockfile, nil)
9
+ # sc=definition.index.search "spree"
10
+ # ENV['SPREE_GEM_PATH'] = sc[0].loaded_from.gsub(/\/[a-z_]*.gemspec$/,'')
11
+
12
+
13
+ # load shared env with features
14
+ puts "#{ENV['SPREE_GEM_PATH']}/features/support/env"
15
+ require File.expand_path("#{ENV['SPREE_GEM_PATH']}/features/support/env", __FILE__)
16
+ Capybara.default_driver = :selenium
@@ -0,0 +1,42 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+ when /the admin home page/
14
+ admin_path
15
+ when /the sign in page/
16
+ new_user_session_path
17
+ when /the sign up page/
18
+ new_user_registration_path
19
+ when /an invalid taxon page/
20
+ "/t/totally_bogus_taxon"
21
+
22
+
23
+ # Add more mappings here.
24
+ # Here is an example that pulls values out of the Regexp:
25
+ #
26
+ # when /^(.*)'s profile page$/i
27
+ # user_profile_path(User.find_by_login($1))
28
+
29
+ else
30
+ begin
31
+ page_name =~ /the (.*) page/
32
+ path_components = $1.split(/\s+/)
33
+ self.send(path_components.push('path').join('_').to_sym)
34
+ rescue Object => e
35
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
36
+ "Now, go and add a mapping in #{__FILE__}"
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ World(NavigationHelpers)
@@ -62,7 +62,7 @@ namespace :multi_currencies do
62
62
  date = Date.strptime(data.xpath('gesmes:Envelope/xmlns:Cube/xmlns:Cube').attr("time").to_s, "%Y-%m-%d")
63
63
  data.xpath('gesmes:Envelope/xmlns:Cube/xmlns:Cube//xmlns:Cube').each do |exchange_rate|
64
64
  char_code = exchange_rate.attribute("currency").value.to_s.strip
65
- value, nimonal = exchange_rate.attribute("rate").value.to_f, 1
65
+ value, nominal = exchange_rate.attribute("rate").value.to_f, 1
66
66
  currency = Currency.find_by_char_code(char_code)
67
67
  currency && CurrencyConverter.add(currency, date, value, nominal)
68
68
  end
@@ -4,11 +4,11 @@ $:.push File.expand_path("../lib", __FILE__)
4
4
  Gem::Specification.new do |s|
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.name = 'multi_currencies'
7
- s.version = '1.0.2'
7
+ s.version = '1.0.3'
8
8
  s.summary = 'Add gem summary here'
9
9
  s.required_ruby_version = '>= 1.8.7'
10
- s.authors = ["Maxim"]
11
- s.email = ["parallel588@gmail.com"]
10
+ s.authors = ["Pronix LLC"]
11
+ s.email = ["parallel588@gmail.com","root@tradefast.ru"]
12
12
  s.homepage = ""
13
13
  s.summary = %q{spree-multi-currency}
14
14
  s.description = %q{spree-multi-currency}
@@ -22,10 +22,10 @@ Gem::Specification.new do |s|
22
22
  s.require_path = ['lib']
23
23
 
24
24
 
25
- s.add_dependency('spree_core', '>= 0.30.0')
25
+ s.add_dependency('rails', '>= 3.0.7')
26
+ s.add_dependency('spree_core', '>= 0.50.1')
26
27
  s.add_dependency('nokogiri', '>= 1.4.4')
27
28
  s.add_dependency('money', '>= 3.6.1')
28
29
  s.add_dependency('json', '>= 1.5.1')
29
-
30
30
  s.add_development_dependency("rspec", ">= 2.5.0")
31
31
  end
data/spec/spec_helper.rb CHANGED
@@ -1,31 +1,12 @@
1
1
  # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
2
  # from the project root directory.
3
3
  ENV["RAILS_ENV"] ||= 'test'
4
- require File.expand_path("../../../config/environment", __FILE__)
4
+ require File.expand_path("../test_app/config/environment", __FILE__)
5
5
  require 'rspec/rails'
6
- require 'fabrication'
7
6
 
8
7
  # Requires supporting files with custom matchers and macros, etc,
9
8
  # in ./support/ and its subdirectories.
10
9
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
10
 
12
- RSpec.configure do |config|
13
- # == Mock Framework
14
- #
15
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
16
- #
17
- # config.mock_with :mocha
18
- # config.mock_with :flexmock
19
- # config.mock_with :rr
20
- config.mock_with :rspec
21
-
22
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
23
-
24
- #config.include Devise::TestHelpers, :type => :controller
25
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
26
- # examples within a transaction, comment the following line or assign false
27
- # instead of true.
28
- config.use_transactional_fixtures = true
29
- end
30
-
31
- @configuration ||= AppConfiguration.find_or_create_by_name("Default configuration")
11
+ require 'spree_core/testing_support/factories'
12
+ require 'spree_core/spec/spec_helper'
metadata CHANGED
@@ -1,43 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_currencies
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
- - Maxim
13
+ - Pronix LLC
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-24 00:00:00 +04:00
18
+ date: 2011-05-06 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: spree_core
22
+ name: rails
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 103
29
+ hash: 9
30
30
  segments:
31
+ - 3
31
32
  - 0
32
- - 30
33
- - 0
34
- version: 0.30.0
33
+ - 7
34
+ version: 3.0.7
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: nokogiri
38
+ name: spree_core
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 213
46
+ segments:
47
+ - 0
48
+ - 50
49
+ - 1
50
+ version: 0.50.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: nokogiri
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
59
  - - ">="
@@ -49,11 +65,11 @@ dependencies:
49
65
  - 4
50
66
  version: 1.4.4
51
67
  type: :runtime
52
- version_requirements: *id002
68
+ version_requirements: *id003
53
69
  - !ruby/object:Gem::Dependency
54
70
  name: money
55
71
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ">="
@@ -65,11 +81,11 @@ dependencies:
65
81
  - 1
66
82
  version: 3.6.1
67
83
  type: :runtime
68
- version_requirements: *id003
84
+ version_requirements: *id004
69
85
  - !ruby/object:Gem::Dependency
70
86
  name: json
71
87
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
91
  - - ">="
@@ -81,11 +97,11 @@ dependencies:
81
97
  - 1
82
98
  version: 1.5.1
83
99
  type: :runtime
84
- version_requirements: *id004
100
+ version_requirements: *id005
85
101
  - !ruby/object:Gem::Dependency
86
102
  name: rspec
87
103
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
107
  - - ">="
@@ -97,10 +113,11 @@ dependencies:
97
113
  - 0
98
114
  version: 2.5.0
99
115
  type: :development
100
- version_requirements: *id005
116
+ version_requirements: *id006
101
117
  description: spree-multi-currency
102
118
  email:
103
119
  - parallel588@gmail.com
120
+ - root@tradefast.ru
104
121
  executables: []
105
122
 
106
123
  extensions: []
@@ -109,21 +126,22 @@ extra_rdoc_files: []
109
126
 
110
127
  files:
111
128
  - .gitignore
112
- - Gemfile
113
129
  - LICENSE
114
130
  - README.markdown
115
131
  - Rakefile
132
+ - Versionfile
116
133
  - app/controllers/admin/currencies_controller.rb
117
134
  - app/controllers/admin/currency_converters_controller.rb
118
135
  - app/controllers/currency_controller.rb
119
136
  - app/controllers/spree/base_controller_decorator.rb
120
- - app/decorators/line_item_decorator.rb
121
- - app/decorators/order_decorator.rb
122
- - app/decorators/variant_decorator.rb
123
137
  - app/helpers/admin/currency_converters_helper.rb
124
138
  - app/helpers/number_helper_decorator.rb
139
+ - app/models/adjustment_decorator.rb
125
140
  - app/models/currency.rb
126
141
  - app/models/currency_converter.rb
142
+ - app/models/line_item_decorator.rb
143
+ - app/models/order_decorator.rb
144
+ - app/models/variant_decorator.rb
127
145
  - app/views/admin/currencies/_form.html.erb
128
146
  - app/views/admin/currencies/edit.html.erb
129
147
  - app/views/admin/currencies/index.html.erb
@@ -132,6 +150,7 @@ files:
132
150
  - app/views/admin/currency_converters/edit.html.erb
133
151
  - app/views/admin/currency_converters/index.html.erb
134
152
  - app/views/admin/currency_converters/new.html.erb
153
+ - config/cucumber.yml
135
154
  - config/locales/currency_rub.yml
136
155
  - config/locales/currency_usd.yml
137
156
  - config/locales/en_multi_currency.yml
@@ -139,7 +158,14 @@ files:
139
158
  - config/routes.rb
140
159
  - db/migrate/20101109134351_create_currencies.rb
141
160
  - db/migrate/20101109134453_create_currency_converters.rb
161
+ - db/sample/currencies.yml
162
+ - db/sample/currency_converters.yml
142
163
  - db/seeds.rb
164
+ - features/products.feature
165
+ - features/step_definitions/product.rb
166
+ - features/step_definitions/ror_ringer.jpeg
167
+ - features/support/env.rb
168
+ - features/support/paths.rb
143
169
  - lib/multi_currencies.rb
144
170
  - lib/multi_currencies_hooks.rb
145
171
  - lib/multi_currency.rb
@@ -184,4 +210,9 @@ signing_key:
184
210
  specification_version: 3
185
211
  summary: spree-multi-currency
186
212
  test_files:
213
+ - features/products.feature
214
+ - features/step_definitions/product.rb
215
+ - features/step_definitions/ror_ringer.jpeg
216
+ - features/support/env.rb
217
+ - features/support/paths.rb
187
218
  - spec/spec_helper.rb