diff --git a/Gemfile b/Gemfile index 32983d2b8e..a38aaa1110 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem 'i18n-js', '~> 3.0.0' gem 'nokogiri', '>= 1.6.7.1' gem 'pg' -gem 'spree', github: 'coopdevs/spree', branch: 'spree-upgrade-step-6' +gem 'spree', github: 'coopdevs/spree', branch: 'fix-odd-even' gem 'spree_i18n', github: 'spree/spree_i18n', branch: '1-3-stable' gem 'spree_auth_devise', github: 'openfoodfoundation/spree_auth_devise', branch: 'spree-upgrade-intermediate' diff --git a/Gemfile.lock b/Gemfile.lock index 6457fd280e..66aaca9410 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,8 +8,8 @@ GIT GIT remote: git://github.com/coopdevs/spree.git - revision: 62f1ae8a9a9e36960ddf0213857dd89f9f052c60 - branch: spree-upgrade-step-6 + revision: 3cd52439c3f78fb4fd6e5d72a4623bc8ff96d32b + branch: fix-odd-even specs: spree (1.3.99) spree_api (= 1.3.99) diff --git a/app/controllers/spree/admin/line_items_controller_decorator.rb b/app/controllers/spree/admin/line_items_controller_decorator.rb index 637fc82a11..7210a6abb1 100644 --- a/app/controllers/spree/admin/line_items_controller_decorator.rb +++ b/app/controllers/spree/admin/line_items_controller_decorator.rb @@ -35,18 +35,6 @@ Spree::Admin::LineItemsController.class_eval do end end - # TODO: simplify this, 3 formats per action is too much: - # we need `js` format for admin/orders/edit (jquery-rails gem) - # we don't know if `html` format is needed - def destroy - @line_item.destroy - - respond_to do |format| - format.html { render_order_form } - format.js { render nothing: true, status: 204 } # No Content - end - end - private def render_order_form diff --git a/spec/controllers/spree/admin/line_items_controller_spec.rb b/spec/controllers/spree/admin/line_items_controller_spec.rb index 0c9a4e4835..b8b6cd2785 100644 --- a/spec/controllers/spree/admin/line_items_controller_spec.rb +++ b/spec/controllers/spree/admin/line_items_controller_spec.rb @@ -85,50 +85,12 @@ describe Spree::Admin::LineItemsController do end end - # Used in admin/orders/bulk_management - context 'when the request is JSON (angular)' do - before { params[:format] = :json } - - it "updates the line item" do - spree_put :update, params - line_item1.reload - expect(line_item1.quantity).to eq 3 - expect(line_item1.final_weight_volume).to eq 3000 - expect(line_item1.price).to eq 3.00 - end - - it "returns an empty JSON response" do - spree_put :update, params - expect(response.body).to eq ' ' - end - - it 'returns a 204 response' do - spree_put :update, params - expect(response.status).to eq 204 - end - - context 'when the line item params are not correct' do - let(:line_item_params) { { price: 'hola' } } - let(:errors) { { 'price' => ['is not a number'] } } - - it 'returns a JSON with the errors' do - spree_put :update, params - expect(JSON.parse(response.body)['errors']).to eq(errors) - end - - it 'returns a 412 response' do - spree_put :update, params - expect(response.status).to eq 412 - end - end - end - context 'when the request is HTML' do before { params[:format] = :html } it 'returns an HTML response with the order form' do spree_put :update, params - expect(response.body).to match /admin_order_form_fields/ + expect(response.body).to match(/admin_order_form_fields/) end end end @@ -148,69 +110,4 @@ describe Spree::Admin::LineItemsController do end end end - - describe '#destroy' do - render_views - - let(:supplier) { create(:supplier_enterprise) } - let(:distributor1) { create(:distributor_enterprise) } - let(:coordinator) { create(:distributor_enterprise) } - let(:order_cycle) { create(:simple_order_cycle, coordinator: coordinator) } - let!(:order1) { FactoryGirl.create(:order, order_cycle: order_cycle, state: 'complete', completed_at: Time.zone.now, distributor: distributor1, billing_address: FactoryGirl.create(:address) ) } - let!(:line_item1) { FactoryGirl.create(:line_item, order: order1, product: FactoryGirl.create(:product, supplier: supplier)) } - let(:params) { { id: line_item1.id, order_id: order1.number } } - - before do - controller.stub spree_current_user: coordinator.owner - end - - # Used in admin/orders/edit - context 'when the request is JS/XHR (jquery-rails gem)' do - it 'destroys the line item' do - expect { - xhr :delete, :destroy, params - }.to change { Spree::LineItem.where(id: line_item1).count }.from(1).to(0) - end - - it 'returns an empty JSON response' do - xhr :delete, :destroy, params - expect(response.body).to eq ' ' - end - - it 'returns a 204 response' do - xhr :delete, :destroy, params - expect(response.status).to eq 204 - end - end - - # Used in admin/orders/bulk_management - context 'when the request is JSON (angular)' do - before { params[:format] = :json } - - it 'destroys the line item' do - expect { - spree_delete :destroy, params - }.to change { Spree::LineItem.where(id: line_item1).count }.from(1).to(0) - end - - it 'returns an empty JSON response' do - spree_delete :destroy, params - expect(response.body).to eq ' ' - end - - it 'returns a 204 response' do - spree_delete :destroy, params - expect(response.status).to eq 204 - end - end - - context 'when the request is HTML' do - before { params.merge(format: :html) } - - it 'returns an HTML response with the order form' do - spree_delete :destroy, params - expect(response.body).to match /admin_order_form_fields/ - end - end - end end