mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Refactor time and currency symbol getters
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -115,7 +115,6 @@ end
|
||||
|
||||
group :test do
|
||||
gem 'webmock'
|
||||
gem 'capybara-screenshot'
|
||||
# See spec/spec_helper.rb for instructions
|
||||
#gem 'perftools.rb'
|
||||
end
|
||||
|
||||
@@ -190,9 +190,6 @@ GEM
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
capybara-screenshot (1.0.14)
|
||||
capybara (>= 1.0, < 3)
|
||||
launchy
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
chronic (0.10.2)
|
||||
@@ -670,7 +667,6 @@ DEPENDENCIES
|
||||
blockenspiel
|
||||
bugsnag
|
||||
capybara
|
||||
capybara-screenshot
|
||||
coffee-rails (~> 3.2.1)
|
||||
compass-rails
|
||||
css_splitter
|
||||
|
||||
@@ -58,123 +58,263 @@ feature %q{
|
||||
end
|
||||
end
|
||||
|
||||
scenario "creating an order cycle", js: true do
|
||||
page.driver.resize(1280, 2000)
|
||||
context "with specific time" do
|
||||
let(:order_cycle_opening_time) { Time.zone.local(2040, 11, 06, 06, 00, 00) }
|
||||
let(:order_cycle_closing_time) { Time.zone.local(2040, 11, 13, 17, 00, 00) }
|
||||
|
||||
# Given coordinating, supplying and distributing enterprises with some products with variants
|
||||
coordinator = create(:distributor_enterprise, name: 'My coordinator')
|
||||
supplier = create(:supplier_enterprise, name: 'My supplier')
|
||||
product = create(:product, supplier: supplier)
|
||||
v1 = create(:variant, product: product)
|
||||
v2 = create(:variant, product: product)
|
||||
distributor = create(:distributor_enterprise, name: 'My distributor', with_payment_and_shipping: true)
|
||||
scenario "creating an order cycle", js: true do
|
||||
page.driver.resize(1280, 2000)
|
||||
|
||||
# Relationships required for interface to work
|
||||
create(:enterprise_relationship, parent: supplier, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: distributor, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: supplier, child: distributor, permissions_list: [:add_to_order_cycle])
|
||||
# Given coordinating, supplying and distributing enterprises with some products with variants
|
||||
coordinator = create(:distributor_enterprise, name: 'My coordinator')
|
||||
supplier = create(:supplier_enterprise, name: 'My supplier')
|
||||
product = create(:product, supplier: supplier)
|
||||
v1 = create(:variant, product: product)
|
||||
v2 = create(:variant, product: product)
|
||||
distributor = create(:distributor_enterprise, name: 'My distributor', with_payment_and_shipping: true)
|
||||
|
||||
# And some enterprise fees
|
||||
supplier_fee = create(:enterprise_fee, enterprise: supplier, name: 'Supplier fee')
|
||||
coordinator_fee = create(:enterprise_fee, enterprise: coordinator, name: 'Coord fee')
|
||||
distributor_fee = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee')
|
||||
# Relationships required for interface to work
|
||||
create(:enterprise_relationship, parent: supplier, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: distributor, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: supplier, child: distributor, permissions_list: [:add_to_order_cycle])
|
||||
|
||||
# When I go to the new order cycle page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link 'New Order Cycle'
|
||||
# And some enterprise fees
|
||||
supplier_fee = create(:enterprise_fee, enterprise: supplier, name: 'Supplier fee')
|
||||
coordinator_fee = create(:enterprise_fee, enterprise: coordinator, name: 'Coord fee')
|
||||
distributor_fee = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee')
|
||||
|
||||
# Select a coordinator since there are two available
|
||||
select2_select 'My coordinator', from: 'coordinator_id'
|
||||
click_button "Continue >"
|
||||
# When I go to the new order cycle page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link 'New Order Cycle'
|
||||
|
||||
# And I fill in the basic fields
|
||||
fill_in 'order_cycle_name', with: 'Plums & Avos'
|
||||
fill_in 'order_cycle_orders_open_at', with: '2040-11-06 06:00:00'
|
||||
fill_in 'order_cycle_orders_close_at', with: '2040-11-13 17:00:00'
|
||||
# Select a coordinator since there are two available
|
||||
select2_select 'My coordinator', from: 'coordinator_id'
|
||||
click_button "Continue >"
|
||||
|
||||
# And I add a coordinator fee
|
||||
click_button 'Add coordinator fee'
|
||||
select 'Coord fee', from: 'order_cycle_coordinator_fee_0_id'
|
||||
# And I fill in the basic fields
|
||||
fill_in 'order_cycle_name', with: 'Plums & Avos'
|
||||
fill_in 'order_cycle_orders_open_at', with: order_cycle_opening_time
|
||||
fill_in 'order_cycle_orders_close_at', with: order_cycle_closing_time
|
||||
|
||||
# I should not be able to add a blank supplier
|
||||
page.should have_select 'new_supplier_id', selected: ''
|
||||
page.should have_button 'Add supplier', disabled: true
|
||||
# And I add a coordinator fee
|
||||
click_button 'Add coordinator fee'
|
||||
select 'Coord fee', from: 'order_cycle_coordinator_fee_0_id'
|
||||
|
||||
# And I add a supplier and some products
|
||||
select 'My supplier', from: 'new_supplier_id'
|
||||
click_button 'Add supplier'
|
||||
fill_in 'order_cycle_incoming_exchange_0_receival_instructions', with: 'receival instructions'
|
||||
page.find('table.exchanges tr.supplier td.products').click
|
||||
check "order_cycle_incoming_exchange_0_variants_#{v1.id}"
|
||||
check "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
# I should not be able to add a blank supplier
|
||||
page.should have_select 'new_supplier_id', selected: ''
|
||||
page.should have_button 'Add supplier', disabled: true
|
||||
|
||||
# I should not be able to re-add the supplier
|
||||
page.should_not have_select 'new_supplier_id', with_options: ['My supplier']
|
||||
page.should have_button 'Add supplier', disabled: true
|
||||
page.all("td.supplier_name").map(&:text).should == ['My supplier']
|
||||
# And I add a supplier and some products
|
||||
select 'My supplier', from: 'new_supplier_id'
|
||||
click_button 'Add supplier'
|
||||
fill_in 'order_cycle_incoming_exchange_0_receival_instructions', with: 'receival instructions'
|
||||
page.find('table.exchanges tr.supplier td.products').click
|
||||
check "order_cycle_incoming_exchange_0_variants_#{v1.id}"
|
||||
check "order_cycle_incoming_exchange_0_variants_#{v2.id}"
|
||||
|
||||
# And I add a supplier fee
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
select 'My supplier', from: 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_id'
|
||||
select 'Supplier fee', from: 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_fee_id'
|
||||
# I should not be able to re-add the supplier
|
||||
page.should_not have_select 'new_supplier_id', with_options: ['My supplier']
|
||||
page.should have_button 'Add supplier', disabled: true
|
||||
page.all("td.supplier_name").map(&:text).should == ['My supplier']
|
||||
|
||||
# And I add a distributor with the same products
|
||||
select 'My distributor', from: 'new_distributor_id'
|
||||
click_button 'Add distributor'
|
||||
# And I add a supplier fee
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
select 'My supplier', from: 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_id'
|
||||
select 'Supplier fee', from: 'order_cycle_incoming_exchange_0_enterprise_fees_0_enterprise_fee_id'
|
||||
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_time', with: 'pickup time'
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions'
|
||||
# And I add a distributor with the same products
|
||||
select 'My distributor', from: 'new_distributor_id'
|
||||
click_button 'Add distributor'
|
||||
|
||||
page.find('table.exchanges tr.distributor td.products').click
|
||||
check "order_cycle_outgoing_exchange_0_variants_#{v1.id}"
|
||||
check "order_cycle_outgoing_exchange_0_variants_#{v2.id}"
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_time', with: 'pickup time'
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'pickup instructions'
|
||||
|
||||
page.find('table.exchanges tr.distributor td.tags').click
|
||||
within ".exchange-tags" do
|
||||
find(:css, "tags-input .tags input").set "wholesale\n"
|
||||
page.find('table.exchanges tr.distributor td.products').click
|
||||
check "order_cycle_outgoing_exchange_0_variants_#{v1.id}"
|
||||
check "order_cycle_outgoing_exchange_0_variants_#{v2.id}"
|
||||
|
||||
page.find('table.exchanges tr.distributor td.tags').click
|
||||
within ".exchange-tags" do
|
||||
find(:css, "tags-input .tags input").set "wholesale\n"
|
||||
end
|
||||
|
||||
# And I add a distributor fee
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
select 'My distributor', from: 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id'
|
||||
select 'Distributor fee', from: 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id'
|
||||
|
||||
# And I click Create
|
||||
click_button 'Create'
|
||||
|
||||
# Then my order cycle should have been created
|
||||
page.should have_content 'Your order cycle has been created.'
|
||||
|
||||
page.should have_selector 'a', text: 'Plums & Avos'
|
||||
page.should have_selector "input[value='#{order_cycle_opening_time}']"
|
||||
page.should have_selector "input[value='#{order_cycle_closing_time}']"
|
||||
page.should have_content 'My coordinator'
|
||||
|
||||
page.should have_selector 'td.suppliers', text: 'My supplier'
|
||||
page.should have_selector 'td.distributors', text: 'My distributor'
|
||||
|
||||
# And it should have some fees
|
||||
oc = OrderCycle.last
|
||||
oc.exchanges.incoming.first.enterprise_fees.should == [supplier_fee]
|
||||
oc.coordinator_fees.should == [coordinator_fee]
|
||||
oc.exchanges.outgoing.first.enterprise_fees.should == [distributor_fee]
|
||||
|
||||
# And it should have some variants selected
|
||||
oc.exchanges.first.variants.count.should == 2
|
||||
oc.exchanges.last.variants.count.should == 2
|
||||
|
||||
# And my receival and pickup time and instructions should have been saved
|
||||
exchange = oc.exchanges.incoming.first
|
||||
exchange.receival_instructions.should == 'receival instructions'
|
||||
|
||||
exchange = oc.exchanges.outgoing.first
|
||||
exchange.pickup_time.should == 'pickup time'
|
||||
exchange.pickup_instructions.should == 'pickup instructions'
|
||||
exchange.tag_list.should == ['wholesale']
|
||||
end
|
||||
|
||||
# And I add a distributor fee
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
select 'My distributor', from: 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_id'
|
||||
select 'Distributor fee', from: 'order_cycle_outgoing_exchange_0_enterprise_fees_0_enterprise_fee_id'
|
||||
scenario "updating an order cycle", js: true do
|
||||
# Given an order cycle with all the settings
|
||||
oc = create(:order_cycle)
|
||||
initial_variants = oc.variants.sort_by &:id
|
||||
|
||||
# And I click Create
|
||||
click_button 'Create'
|
||||
# And a coordinating, supplying and distributing enterprise with some products with variants
|
||||
coordinator = oc.coordinator
|
||||
supplier = create(:supplier_enterprise, name: 'My supplier')
|
||||
distributor = create(:distributor_enterprise, name: 'My distributor', with_payment_and_shipping: true)
|
||||
product = create(:product, supplier: supplier)
|
||||
v1 = create(:variant, product: product)
|
||||
v2 = create(:variant, product: product)
|
||||
|
||||
# Then my order cycle should have been created
|
||||
page.should have_content 'Your order cycle has been created.'
|
||||
# Relationships required for interface to work
|
||||
create(:enterprise_relationship, parent: supplier, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: distributor, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: supplier, child: distributor, permissions_list: [:add_to_order_cycle])
|
||||
|
||||
page.should have_selector 'a', text: 'Plums & Avos'
|
||||
page.should have_selector "input[value='#{Time.zone.local(2040, 11, 06, 06, 00, 00)}']"
|
||||
page.should have_selector "input[value='#{Time.zone.local(2040, 11, 13, 17, 00, 00)}']"
|
||||
page.should have_content 'My coordinator'
|
||||
# And some enterprise fees
|
||||
supplier_fee1 = create(:enterprise_fee, enterprise: supplier, name: 'Supplier fee 1')
|
||||
supplier_fee2 = create(:enterprise_fee, enterprise: supplier, name: 'Supplier fee 2')
|
||||
coordinator_fee1 = create(:enterprise_fee, enterprise: coordinator, name: 'Coord fee 1')
|
||||
coordinator_fee2 = create(:enterprise_fee, enterprise: coordinator, name: 'Coord fee 2')
|
||||
distributor_fee1 = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee 1')
|
||||
distributor_fee2 = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee 2')
|
||||
|
||||
page.should have_selector 'td.suppliers', text: 'My supplier'
|
||||
page.should have_selector 'td.distributors', text: 'My distributor'
|
||||
# When I go to its edit page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link oc.name
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
# And it should have some fees
|
||||
oc = OrderCycle.last
|
||||
oc.exchanges.incoming.first.enterprise_fees.should == [supplier_fee]
|
||||
oc.coordinator_fees.should == [coordinator_fee]
|
||||
oc.exchanges.outgoing.first.enterprise_fees.should == [distributor_fee]
|
||||
# And I update it
|
||||
fill_in 'order_cycle_name', with: 'Plums & Avos'
|
||||
fill_in 'order_cycle_orders_open_at', with: order_cycle_opening_time
|
||||
fill_in 'order_cycle_orders_close_at', with: order_cycle_closing_time
|
||||
|
||||
# And it should have some variants selected
|
||||
oc.exchanges.first.variants.count.should == 2
|
||||
oc.exchanges.last.variants.count.should == 2
|
||||
# CAN'T CHANGE COORDINATOR ANYMORE
|
||||
# select 'My coordinator', from: 'order_cycle_coordinator_id'
|
||||
|
||||
# And my receival and pickup time and instructions should have been saved
|
||||
exchange = oc.exchanges.incoming.first
|
||||
exchange.receival_instructions.should == 'receival instructions'
|
||||
# And I configure some coordinator fees
|
||||
click_button 'Add coordinator fee'
|
||||
select 'Coord fee 1', from: 'order_cycle_coordinator_fee_0_id'
|
||||
click_button 'Add coordinator fee'
|
||||
click_button 'Add coordinator fee'
|
||||
click_link 'order_cycle_coordinator_fee_2_remove'
|
||||
select 'Coord fee 2', from: 'order_cycle_coordinator_fee_1_id'
|
||||
|
||||
exchange = oc.exchanges.outgoing.first
|
||||
exchange.pickup_time.should == 'pickup time'
|
||||
exchange.pickup_instructions.should == 'pickup instructions'
|
||||
exchange.tag_list.should == ['wholesale']
|
||||
# And I add a supplier and some products
|
||||
select 'My supplier', from: 'new_supplier_id'
|
||||
click_button 'Add supplier'
|
||||
page.all("table.exchanges tr.supplier td.products").each { |e| e.click }
|
||||
|
||||
page.should have_selector "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true
|
||||
page.find("#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true).click # uncheck (with visible:true filter)
|
||||
check "order_cycle_incoming_exchange_2_variants_#{v1.id}"
|
||||
check "order_cycle_incoming_exchange_2_variants_#{v2.id}"
|
||||
|
||||
# And I configure some supplier fees
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
select 'My supplier', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Supplier fee 1', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
click_link 'order_cycle_incoming_exchange_2_enterprise_fees_0_remove'
|
||||
select 'My supplier', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Supplier fee 2', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
|
||||
# And I add a distributor and some products
|
||||
select 'My distributor', from: 'new_distributor_id'
|
||||
click_button 'Add distributor'
|
||||
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_time', with: 'New time 0'
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'New instructions 0'
|
||||
fill_in 'order_cycle_outgoing_exchange_1_pickup_time', with: 'New time 1'
|
||||
fill_in 'order_cycle_outgoing_exchange_1_pickup_instructions', with: 'New instructions 1'
|
||||
fill_in 'order_cycle_outgoing_exchange_2_pickup_time', with: 'New time 2'
|
||||
fill_in 'order_cycle_outgoing_exchange_2_pickup_instructions', with: 'New instructions 2'
|
||||
|
||||
page.find("table.exchanges tr.distributor-#{distributor.id} td.tags").click
|
||||
within ".exchange-tags" do
|
||||
find(:css, "tags-input .tags input").set "wholesale\n"
|
||||
end
|
||||
|
||||
page.all("table.exchanges tr.distributor td.products").each { |e| e.click }
|
||||
|
||||
uncheck "order_cycle_outgoing_exchange_2_variants_#{v1.id}"
|
||||
check "order_cycle_outgoing_exchange_2_variants_#{v2.id}"
|
||||
|
||||
# And I configure some distributor fees
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
select 'My distributor', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Distributor fee 1', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
click_link 'order_cycle_outgoing_exchange_2_enterprise_fees_0_remove'
|
||||
select 'My distributor', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Distributor fee 2', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
|
||||
# And I click Update
|
||||
expect(page).to have_selector "#save-bar"
|
||||
click_button 'Update and Close'
|
||||
|
||||
# Then my order cycle should have been updated
|
||||
page.should have_content 'Your order cycle has been updated.'
|
||||
|
||||
page.should have_selector 'a', text: 'Plums & Avos'
|
||||
|
||||
page.should have_selector "input[value='#{order_cycle_opening_time}']"
|
||||
page.should have_selector "input[value='#{order_cycle_closing_time}']"
|
||||
page.should have_content coordinator.name
|
||||
|
||||
page.should have_selector 'td.suppliers', text: 'My supplier'
|
||||
page.should have_selector 'td.distributors', text: 'My distributor'
|
||||
|
||||
# And my coordinator fees should have been configured
|
||||
OrderCycle.last.coordinator_fee_ids.should match_array [coordinator_fee1.id, coordinator_fee2.id]
|
||||
|
||||
# And my supplier fees should have been configured
|
||||
OrderCycle.last.exchanges.incoming.last.enterprise_fee_ids.should == [supplier_fee2.id]
|
||||
|
||||
# And my distributor fees should have been configured
|
||||
OrderCycle.last.exchanges.outgoing.last.enterprise_fee_ids.should == [distributor_fee2.id]
|
||||
|
||||
# And my tags should have been save
|
||||
OrderCycle.last.exchanges.outgoing.last.tag_list.should == ['wholesale']
|
||||
|
||||
# And it should have some variants selected
|
||||
selected_initial_variants = initial_variants.take initial_variants.size - 1
|
||||
OrderCycle.last.variants.map(&:id).should match_array (selected_initial_variants.map(&:id) + [v1.id, v2.id])
|
||||
|
||||
# And the collection details should have been updated
|
||||
OrderCycle.last.exchanges.where(pickup_time: 'New time 0', pickup_instructions: 'New instructions 0').should be_present
|
||||
OrderCycle.last.exchanges.where(pickup_time: 'New time 1', pickup_instructions: 'New instructions 1').should be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
scenario "editing an order cycle" do
|
||||
# Given an order cycle with all the settings
|
||||
oc = create(:order_cycle)
|
||||
@@ -272,144 +412,6 @@ feature %q{
|
||||
page.should_not have_selector 'table.exchanges tr.supplier'
|
||||
end
|
||||
|
||||
|
||||
scenario "updating an order cycle", js: true do
|
||||
# Given an order cycle with all the settings
|
||||
oc = create(:order_cycle)
|
||||
initial_variants = oc.variants.sort_by &:id
|
||||
|
||||
# And a coordinating, supplying and distributing enterprise with some products with variants
|
||||
coordinator = oc.coordinator
|
||||
supplier = create(:supplier_enterprise, name: 'My supplier')
|
||||
distributor = create(:distributor_enterprise, name: 'My distributor', with_payment_and_shipping: true)
|
||||
product = create(:product, supplier: supplier)
|
||||
v1 = create(:variant, product: product)
|
||||
v2 = create(:variant, product: product)
|
||||
|
||||
# Relationships required for interface to work
|
||||
create(:enterprise_relationship, parent: supplier, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: distributor, child: coordinator, permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: supplier, child: distributor, permissions_list: [:add_to_order_cycle])
|
||||
|
||||
# And some enterprise fees
|
||||
supplier_fee1 = create(:enterprise_fee, enterprise: supplier, name: 'Supplier fee 1')
|
||||
supplier_fee2 = create(:enterprise_fee, enterprise: supplier, name: 'Supplier fee 2')
|
||||
coordinator_fee1 = create(:enterprise_fee, enterprise: coordinator, name: 'Coord fee 1')
|
||||
coordinator_fee2 = create(:enterprise_fee, enterprise: coordinator, name: 'Coord fee 2')
|
||||
distributor_fee1 = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee 1')
|
||||
distributor_fee2 = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee 2')
|
||||
|
||||
# When I go to its edit page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link oc.name
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
# And I update it
|
||||
fill_in 'order_cycle_name', with: 'Plums & Avos'
|
||||
fill_in 'order_cycle_orders_open_at', with: '2040-11-06 06:00:00'
|
||||
fill_in 'order_cycle_orders_close_at', with: '2040-11-13 17:00:00'
|
||||
|
||||
# CAN'T CHANGE COORDINATOR ANYMORE
|
||||
# select 'My coordinator', from: 'order_cycle_coordinator_id'
|
||||
|
||||
# And I configure some coordinator fees
|
||||
click_button 'Add coordinator fee'
|
||||
select 'Coord fee 1', from: 'order_cycle_coordinator_fee_0_id'
|
||||
click_button 'Add coordinator fee'
|
||||
click_button 'Add coordinator fee'
|
||||
click_link 'order_cycle_coordinator_fee_2_remove'
|
||||
select 'Coord fee 2', from: 'order_cycle_coordinator_fee_1_id'
|
||||
|
||||
# And I add a supplier and some products
|
||||
select 'My supplier', from: 'new_supplier_id'
|
||||
click_button 'Add supplier'
|
||||
page.all("table.exchanges tr.supplier td.products").each { |e| e.click }
|
||||
|
||||
page.should have_selector "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true
|
||||
page.find("#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true).click # uncheck (with visible:true filter)
|
||||
check "order_cycle_incoming_exchange_2_variants_#{v1.id}"
|
||||
check "order_cycle_incoming_exchange_2_variants_#{v2.id}"
|
||||
|
||||
# And I configure some supplier fees
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
select 'My supplier', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Supplier fee 1', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
within("tr.supplier-#{supplier.id}") { click_button 'Add fee' }
|
||||
click_link 'order_cycle_incoming_exchange_2_enterprise_fees_0_remove'
|
||||
select 'My supplier', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Supplier fee 2', from: 'order_cycle_incoming_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
|
||||
# And I add a distributor and some products
|
||||
select 'My distributor', from: 'new_distributor_id'
|
||||
click_button 'Add distributor'
|
||||
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_time', with: 'New time 0'
|
||||
fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'New instructions 0'
|
||||
fill_in 'order_cycle_outgoing_exchange_1_pickup_time', with: 'New time 1'
|
||||
fill_in 'order_cycle_outgoing_exchange_1_pickup_instructions', with: 'New instructions 1'
|
||||
fill_in 'order_cycle_outgoing_exchange_2_pickup_time', with: 'New time 2'
|
||||
fill_in 'order_cycle_outgoing_exchange_2_pickup_instructions', with: 'New instructions 2'
|
||||
|
||||
page.find("table.exchanges tr.distributor-#{distributor.id} td.tags").click
|
||||
within ".exchange-tags" do
|
||||
find(:css, "tags-input .tags input").set "wholesale\n"
|
||||
end
|
||||
|
||||
page.all("table.exchanges tr.distributor td.products").each { |e| e.click }
|
||||
|
||||
uncheck "order_cycle_outgoing_exchange_2_variants_#{v1.id}"
|
||||
check "order_cycle_outgoing_exchange_2_variants_#{v2.id}"
|
||||
|
||||
# And I configure some distributor fees
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
select 'My distributor', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Distributor fee 1', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
within("tr.distributor-#{distributor.id}") { click_button 'Add fee' }
|
||||
click_link 'order_cycle_outgoing_exchange_2_enterprise_fees_0_remove'
|
||||
select 'My distributor', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_id'
|
||||
select 'Distributor fee 2', from: 'order_cycle_outgoing_exchange_2_enterprise_fees_0_enterprise_fee_id'
|
||||
|
||||
# And I click Update
|
||||
expect(page).to have_selector "#save-bar"
|
||||
click_button 'Update and Close'
|
||||
|
||||
# Then my order cycle should have been updated
|
||||
page.should have_content 'Your order cycle has been updated.'
|
||||
|
||||
page.should have_selector 'a', text: 'Plums & Avos'
|
||||
|
||||
page.should have_selector "input[value='#{Time.zone.local(2040, 11, 06, 06, 00, 00)}']"
|
||||
page.should have_selector "input[value='#{Time.zone.local(2040, 11, 13, 17, 00, 00)}']"
|
||||
page.should have_content coordinator.name
|
||||
|
||||
page.should have_selector 'td.suppliers', text: 'My supplier'
|
||||
page.should have_selector 'td.distributors', text: 'My distributor'
|
||||
|
||||
# And my coordinator fees should have been configured
|
||||
OrderCycle.last.coordinator_fee_ids.should match_array [coordinator_fee1.id, coordinator_fee2.id]
|
||||
|
||||
# And my supplier fees should have been configured
|
||||
OrderCycle.last.exchanges.incoming.last.enterprise_fee_ids.should == [supplier_fee2.id]
|
||||
|
||||
# And my distributor fees should have been configured
|
||||
OrderCycle.last.exchanges.outgoing.last.enterprise_fee_ids.should == [distributor_fee2.id]
|
||||
|
||||
# And my tags should have been save
|
||||
OrderCycle.last.exchanges.outgoing.last.tag_list.should == ['wholesale']
|
||||
|
||||
# And it should have some variants selected
|
||||
selected_initial_variants = initial_variants.take initial_variants.size - 1
|
||||
OrderCycle.last.variants.map(&:id).should match_array (selected_initial_variants.map(&:id) + [v1.id, v2.id])
|
||||
|
||||
# And the collection details should have been updated
|
||||
OrderCycle.last.exchanges.where(pickup_time: 'New time 0', pickup_instructions: 'New instructions 0').should be_present
|
||||
OrderCycle.last.exchanges.where(pickup_time: 'New time 1', pickup_instructions: 'New instructions 1').should be_present
|
||||
end
|
||||
|
||||
|
||||
scenario "updating many order cycle opening/closing times at once", js: true do
|
||||
# Given three order cycles
|
||||
oc1 = create(:simple_order_cycle)
|
||||
|
||||
@@ -32,10 +32,10 @@ feature "full-page cart", js: true do
|
||||
it "rounds fee calculations correctly" do
|
||||
# $0.86 + 20% = $1.032
|
||||
# Fractional cents should be immediately rounded down and not carried through
|
||||
expect(page).to have_selector '.cart-item-price', text: "#{@currency_symbol}1.03"
|
||||
expect(page).to have_selector '.cart-item-total', text: "#{@currency_symbol}8.24"
|
||||
expect(page).to have_selector '.order-total.item-total', text: "#{@currency_symbol}8.24"
|
||||
expect(page).to have_selector '.order-total.grand-total', text: "#{@currency_symbol}8.24"
|
||||
expect(page).to have_selector '.cart-item-price', text: "#{currency}1.03"
|
||||
expect(page).to have_selector '.cart-item-total', text: "#{currency}8.24"
|
||||
expect(page).to have_selector '.order-total.item-total', text: "#{currency}8.24"
|
||||
expect(page).to have_selector '.order-total.grand-total', text: "#{currency}8.24"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -135,9 +135,9 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do
|
||||
toggle_shipping
|
||||
choose sm2.name
|
||||
|
||||
page.should have_selector 'orderdetails .cart-total', text: "#{@currency_symbol}11.23"
|
||||
page.should have_selector 'orderdetails .shipping', text: "#{@currency_symbol}4.56"
|
||||
page.should have_selector 'orderdetails .total', text: "#{@currency_symbol}15.79"
|
||||
page.should have_selector 'orderdetails .cart-total', text: "#{currency}11.23"
|
||||
page.should have_selector 'orderdetails .shipping', text: "#{currency}4.56"
|
||||
page.should have_selector 'orderdetails .total', text: "#{currency}15.79"
|
||||
|
||||
# Tax should not be displayed in checkout, as the customer's choice of shipping method
|
||||
# affects the tax and we haven't written code to live-update the tax amount when they
|
||||
@@ -269,7 +269,7 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do
|
||||
# + shipping tax ($ 4.56 @ 25% = $0.91)
|
||||
# = $1.93
|
||||
page.should have_content "(includes tax)"
|
||||
page.should have_content "#{@currency_symbol}1.93"
|
||||
page.should have_content "#{currency}1.93"
|
||||
end
|
||||
|
||||
context "with basic details filled" do
|
||||
@@ -331,14 +331,14 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do
|
||||
context "when we are charged a payment method fee (transaction fee)" do
|
||||
it "creates a payment including the transaction fee" do
|
||||
# Selecting the transaction fee, it is displayed
|
||||
expect(page).to have_selector ".transaction-fee td", text: "#{@currency_symbol}0.00"
|
||||
expect(page).to have_selector ".total", text: "#{@currency_symbol}11.23"
|
||||
expect(page).to have_selector ".transaction-fee td", text: "#{currency}0.00"
|
||||
expect(page).to have_selector ".total", text: "#{currency}11.23"
|
||||
|
||||
toggle_payment
|
||||
choose "#{pm2.name} (#{@currency_symbol}5.67)"
|
||||
choose "#{pm2.name} (#{currency}5.67)"
|
||||
|
||||
expect(page).to have_selector ".transaction-fee td", text: "#{@currency_symbol}5.67"
|
||||
expect(page).to have_selector ".total", text: "#{@currency_symbol}16.90"
|
||||
expect(page).to have_selector ".transaction-fee td", text: "#{currency}5.67"
|
||||
expect(page).to have_selector ".total", text: "#{currency}16.90"
|
||||
|
||||
place_order
|
||||
expect(page).to have_content "Your order has been processed successfully"
|
||||
|
||||
@@ -95,23 +95,23 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
# -- Selecting an order cycle
|
||||
visit shop_path
|
||||
select "turtles", from: "order_cycle_id"
|
||||
page.should have_content "#{@currency_symbol}1020.99"
|
||||
page.should have_content "#{currency}1020.99"
|
||||
|
||||
# -- Cart shows correct price
|
||||
fill_in "variants[#{variant.id}]", with: 1
|
||||
show_cart
|
||||
within("li.cart") { page.should have_content "#{@currency_symbol}1020.99" }
|
||||
within("li.cart") { page.should have_content "#{currency}1020.99" }
|
||||
|
||||
# -- Changing order cycle
|
||||
select "frogs", from: "order_cycle_id"
|
||||
page.should have_content "#{@currency_symbol}19.99"
|
||||
page.should have_content "#{currency}19.99"
|
||||
|
||||
# -- Cart should be cleared
|
||||
# ng-animate means that the old product row is likely to be present, so we explicitly
|
||||
# fill in the quantity in the incoming row
|
||||
page.should_not have_selector "tr.product-cart"
|
||||
within('product.ng-enter') { fill_in "variants[#{variant.id}]", with: 1 }
|
||||
within("li.cart") { page.should have_content "#{@currency_symbol}19.99" }
|
||||
within("li.cart") { page.should have_content "#{currency}19.99" }
|
||||
end
|
||||
|
||||
describe "declining to clear the cart" do
|
||||
@@ -164,15 +164,15 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
visit shop_path
|
||||
|
||||
# Page should not have product.price (with or without fee)
|
||||
page.should_not have_price "#{@currency_symbol}10.00"
|
||||
page.should_not have_price "#{@currency_symbol}33.00"
|
||||
page.should_not have_price "#{currency}10.00"
|
||||
page.should_not have_price "#{currency}33.00"
|
||||
|
||||
# Page should have variant prices (with fee)
|
||||
page.should have_price "#{@currency_symbol}43.00"
|
||||
page.should have_price "#{@currency_symbol}53.00"
|
||||
page.should have_price "#{currency}43.00"
|
||||
page.should have_price "#{currency}53.00"
|
||||
|
||||
# Product price should be listed as the lesser of these
|
||||
page.should have_price "#{@currency_symbol}43.00"
|
||||
page.should have_price "#{currency}43.00"
|
||||
end
|
||||
|
||||
it "filters search results properly" do
|
||||
|
||||
@@ -40,8 +40,8 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
|
||||
|
||||
describe "viewing products" do
|
||||
it "shows the overridden price" do
|
||||
page.should_not have_price "#{@currency_symbol}12.22" # $11.11 + 10% fee
|
||||
page.should have_price "#{@currency_symbol}61.11"
|
||||
page.should_not have_price "#{currency}12.22" # $11.11 + 10% fee
|
||||
page.should have_price "#{currency}61.11"
|
||||
end
|
||||
|
||||
it "looks up stock from the override" do
|
||||
@@ -59,9 +59,9 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
|
||||
it "calculates fees correctly" do
|
||||
page.find("#variant-#{v1.id} .graph-button").click
|
||||
page.find(".price_breakdown a").click
|
||||
page.should have_selector 'li.cost div', text: "#{@currency_symbol}55.55"
|
||||
page.should have_selector 'li.packing-fee div', text: "#{@currency_symbol}5.56"
|
||||
page.should have_selector 'li.total div', text: "= #{@currency_symbol}61.11"
|
||||
page.should have_selector 'li.cost div', text: "#{currency}55.55"
|
||||
page.should have_selector 'li.packing-fee div', text: "#{currency}5.56"
|
||||
page.should have_selector 'li.total div', text: "= #{currency}61.11"
|
||||
end
|
||||
|
||||
it "shows the correct prices when products are in the cart" do
|
||||
@@ -69,7 +69,7 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
|
||||
show_cart
|
||||
wait_until_enabled 'li.cart a.button'
|
||||
visit shop_path
|
||||
page.should_not have_price "#{@currency_symbol}12.22"
|
||||
page.should_not have_price "#{currency}12.22"
|
||||
end
|
||||
|
||||
# The two specs below reveal an unrelated issue with fee calculation. See:
|
||||
@@ -79,29 +79,29 @@ feature "shopping with variant overrides defined", js: true, retry: 3 do
|
||||
fill_in "variants[#{v1.id}]", with: "2"
|
||||
show_cart
|
||||
page.should have_selector "#cart-variant-#{v1.id} .quantity", text: '2'
|
||||
page.should have_selector "#cart-variant-#{v1.id} .price", text: "#{@currency_symbol}61.11"
|
||||
page.should have_selector "#cart-variant-#{v1.id} .total-price", text: "#{@currency_symbol}122.22"
|
||||
page.should have_selector "#cart-variant-#{v1.id} .price", text: "#{currency}61.11"
|
||||
page.should have_selector "#cart-variant-#{v1.id} .total-price", text: "#{currency}122.22"
|
||||
end
|
||||
|
||||
it "shows the correct prices in the shopping cart" do
|
||||
fill_in "variants[#{v1.id}]", with: "2"
|
||||
add_to_cart
|
||||
|
||||
page.should have_selector "tr.line-item.variant-#{v1.id} .cart-item-price", text: "#{@currency_symbol}61.11"
|
||||
page.should have_selector "tr.line-item.variant-#{v1.id} .cart-item-price", text: "#{currency}61.11"
|
||||
page.should have_field "order[line_items_attributes][0][quantity]", with: '2'
|
||||
page.should have_selector "tr.line-item.variant-#{v1.id} .cart-item-total", text: "#{@currency_symbol}122.22"
|
||||
page.should have_selector "tr.line-item.variant-#{v1.id} .cart-item-total", text: "#{currency}122.22"
|
||||
|
||||
page.should have_selector "#edit-cart .item-total", text: "#{@currency_symbol}122.22"
|
||||
page.should have_selector "#edit-cart .grand-total", text: "#{@currency_symbol}122.22"
|
||||
page.should have_selector "#edit-cart .item-total", text: "#{currency}122.22"
|
||||
page.should have_selector "#edit-cart .grand-total", text: "#{currency}122.22"
|
||||
end
|
||||
|
||||
it "shows the correct prices in the checkout" do
|
||||
fill_in "variants[#{v1.id}]", with: "2"
|
||||
click_checkout
|
||||
|
||||
page.should have_selector 'form.edit_order .cart-total', text: "#{@currency_symbol}122.22"
|
||||
page.should have_selector 'form.edit_order .shipping', text: "#{@currency_symbol}0.00"
|
||||
page.should have_selector 'form.edit_order .total', text: "#{@currency_symbol}122.22"
|
||||
page.should have_selector 'form.edit_order .cart-total', text: "#{currency}122.22"
|
||||
page.should have_selector 'form.edit_order .shipping', text: "#{currency}0.00"
|
||||
page.should have_selector 'form.edit_order .total', text: "#{currency}122.22"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,12 +34,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -52,7 +52,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
@@ -77,7 +77,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
end
|
||||
end
|
||||
|
||||
context "when minimum billable turnover is #{@currency_symbol}100" do
|
||||
context "when minimum billable turnover is 100" do
|
||||
before { Spree::Config.set(:minimum_billable_turnover, 100) }
|
||||
|
||||
context "when a fixed cost is included" do
|
||||
@@ -88,12 +88,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,12 +102,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -120,12 +120,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -160,12 +160,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -174,12 +174,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -192,7 +192,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
@@ -217,7 +217,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
end
|
||||
end
|
||||
|
||||
context "when minimum billable turnover is #{@currency_symbol}100" do
|
||||
context "when minimum billable turnover is 100" do
|
||||
before { Spree::Config.set(:minimum_billable_turnover, 100) }
|
||||
|
||||
context "when a fixed cost is included" do
|
||||
@@ -228,12 +228,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -242,12 +242,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "#{currency}10 PER MONTH" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -260,12 +260,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -304,12 +304,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -318,12 +318,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -336,7 +336,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
@@ -361,7 +361,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
end
|
||||
end
|
||||
|
||||
context "when minimum billable turnover is #{@currency_symbol}100" do
|
||||
context "when minimum billable turnover is 100" do
|
||||
before { Spree::Config.set(:minimum_billable_turnover, 100) }
|
||||
|
||||
context "when a fixed cost is included" do
|
||||
@@ -372,12 +372,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -386,12 +386,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -404,12 +404,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH, PLUS GST" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH, PLUS GST" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH, PLUS GST" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -444,12 +444,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -458,12 +458,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -476,7 +476,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
@@ -501,7 +501,7 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
end
|
||||
end
|
||||
|
||||
context "when minimum billable turnover is #{@currency_symbol}100" do
|
||||
context "when minimum billable turnover is 100" do
|
||||
before { Spree::Config.set(:minimum_billable_turnover, 100) }
|
||||
|
||||
context "when a fixed cost is included" do
|
||||
@@ -512,12 +512,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 + 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -526,12 +526,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{@currency_symbol}10 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN #{currency}10 PER MONTH" }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -544,12 +544,12 @@ describe Admin::BusinessModelConfigurationHelper do
|
||||
|
||||
context "when the bill is capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 20) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100, CAPPED AT #{@currency_symbol}20 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100, CAPPED AT #{currency}20 PER MONTH" }
|
||||
end
|
||||
|
||||
context "when the bill is not capped" do
|
||||
before { Spree::Config.set(:account_invoices_monthly_cap, 0) }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{@currency_symbol}100 PER MONTH" }
|
||||
it { expect(helper.monthly_bill_description).to eq "FREE TRIAL THEN 5.0% OF SALES ONCE TURNOVER EXCEEDS #{currency}100 PER MONTH" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ module Spree
|
||||
describe ProductsHelper do
|
||||
it "displays variant price differences as absolute, not relative values" do
|
||||
variant = make_variant_stub(10.00, 10.00)
|
||||
helper.variant_price_diff(variant).should == "(#{@currency_symbol}10.00)"
|
||||
helper.variant_price_diff(variant).should == "(#{currency}10.00)"
|
||||
|
||||
variant = make_variant_stub(10.00, 15.55)
|
||||
helper.variant_price_diff(variant).should == "(#{@currency_symbol}15.55)"
|
||||
helper.variant_price_diff(variant).should == "(#{currency}15.55)"
|
||||
|
||||
variant = make_variant_stub(10.00, 5.55)
|
||||
helper.variant_price_diff(variant).should == "(#{@currency_symbol}5.55)"
|
||||
helper.variant_price_diff(variant).should == "(#{currency}5.55)"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -93,13 +93,11 @@ RSpec.configure do |config|
|
||||
# Ensure we start with consistent config settings
|
||||
config.before(:each) { Spree::Config.products_require_tax_category = false }
|
||||
|
||||
# Set currency symbol from config for tests
|
||||
config.before(:all) { @currency_symbol = Spree::Money.currency_symbol }
|
||||
|
||||
# Helpers
|
||||
config.include Rails.application.routes.url_helpers
|
||||
config.include Spree::UrlHelpers
|
||||
config.include Spree::CheckoutHelpers
|
||||
config.include Spree::MoneyHelper
|
||||
config.include Spree::Core::TestingSupport::ControllerRequests, :type => :controller
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.extend Spree::Api::TestingSupport::Setup, :type => :controller
|
||||
|
||||
7
spec/support/spree/money_helper.rb
Normal file
7
spec/support/spree/money_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
module Spree
|
||||
module MoneyHelper
|
||||
def currency
|
||||
Spree::Money.currency_symbol
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user