diff --git a/Guardfile b/Guardfile index 97c5763..dac60e0 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,8 @@ -guard 'rspec', cli: '--color' do +guard 'rspec', cmd: 'bundle exec rspec' do watch('spec/spec_helper.rb') { 'spec' } watch('config/routes.rb') { 'spec/controllers' } watch('app/controllers/application_controller.rb') { 'spec/controllers' } + watch(%r{^app/views/(.+)}) { 'spec/controllers' } watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } diff --git a/app/views/spree/shipstation/export.xml.builder b/app/views/spree/shipstation/export.xml.builder index a1f26c5..945e707 100644 --- a/app/views/spree/shipstation/export.xml.builder +++ b/app/views/spree/shipstation/export.xml.builder @@ -29,16 +29,16 @@ xml.Orders(pages: (@shipments.total_count/50.0).ceil) { Spree::ExportHelper.address(xml, order, :ship) } xml.Items { - shipment.line_items.each do |line| - variant = line.variant + shipment.manifest.each do |item| + variant = item.variant xml.Item { xml.SKU variant.sku xml.Name [variant.product.name, variant.options_text].join(' ') xml.ImageUrl variant.images.first.try(:attachment).try(:url) xml.Weight variant.weight.to_f xml.WeightUnits Spree::Config.shipstation_weight_units - xml.Quantity line.quantity - xml.UnitPrice line.price + xml.Quantity item.quantity + xml.UnitPrice item.line_item.price if variant.option_values.present? xml.Options { diff --git a/solidus_shipstation.gemspec b/solidus_shipstation.gemspec index 9e1a58f..b150e34 100644 --- a/solidus_shipstation.gemspec +++ b/solidus_shipstation.gemspec @@ -19,6 +19,7 @@ Gem::Specification.new do |s| s.add_dependency 'solidus_core', ' >= 1.1', '< 3' s.add_dependency 'solidus_support' + s.add_development_dependency 'pry-byebug' s.add_development_dependency 'capybara', '~> 2.2' s.add_development_dependency 'coffee-rails', '>= 4.1' s.add_development_dependency 'factory_bot' diff --git a/spec/controllers/spree/shipstation_controller_spec.rb b/spec/controllers/spree/shipstation_controller_spec.rb index d49d078..760b677 100644 --- a/spec/controllers/spree/shipstation_controller_spec.rb +++ b/spec/controllers/spree/shipstation_controller_spec.rb @@ -17,8 +17,8 @@ describe '#export' do let(:schema) { 'spec/fixtures/shipstation_xml_schema.xsd' } - let(:order) { create(:order, state: 'complete', completed_at: Time.now.utc) } - let!(:shipments) { create(:shipment, state: 'ready', order: order) } + let(:order) { create(:order_ready_to_ship) } + let!(:shipments) { order.shipments.to_a } let(:params) do { start_date: 1.day.ago.strftime('%m/%d/%Y %H:%M'), @@ -32,7 +32,7 @@ it 'renders successfully', :aggregate_failures do expect(response).to be_successful expect(response).to render_template(:export) - expect(assigns(:shipments)).to match_array([shipments]) + expect(assigns(:shipments)).to match_array(shipments) end it 'generates valid ShipStation formatted xml' do diff --git a/spec/fixtures/shipstation_xml_schema.xsd b/spec/fixtures/shipstation_xml_schema.xsd index ef8fd34..40c6002 100644 --- a/spec/fixtures/shipstation_xml_schema.xsd +++ b/spec/fixtures/shipstation_xml_schema.xsd @@ -1,171 +1,309 @@ + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + + + + + - - - - - - - - - - - - - - - - + - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b17f3ca..25054de 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,14 +14,18 @@ ENV['RAILS_ENV'] = 'test' require File.expand_path('../dummy/config/environment.rb', __FILE__) +# dummy initializers +Spree::Config.shipstation_weight_units = 'grams' require 'rspec/rails' require 'factory_bot' require 'ffaker' require 'database_cleaner' require 'rspec/xsd' +require 'pry-byebug' FactoryBot.find_definitions + # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }