-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3680 from jacquesporveau/jacquesporveau/stock_mov…
…ements_admin_1 [Admin] Add filter feature for stock movements
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
backend/spec/controllers/spree/admin/stock_movements_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
module Spree | ||
module Admin | ||
describe StockMovementsController, type: :controller do | ||
stub_authorization! | ||
|
||
let!(:stock_location) do | ||
create( | ||
:stock_location_with_items | ||
) | ||
end | ||
|
||
let!(:stock_movement_1) do | ||
create( | ||
:stock_movement, | ||
stock_item: stock_location.stock_items.first | ||
) | ||
end | ||
|
||
let!(:stock_movement_2) do | ||
create( | ||
:stock_movement, | ||
stock_item: stock_location.stock_items.last | ||
) | ||
end | ||
|
||
describe '#index' do | ||
subject { get :index, params: params } | ||
|
||
context 'with no params' do | ||
let(:params) { { stock_location_id: stock_location.id } } | ||
|
||
it 'responds with a successful status code' do | ||
subject | ||
|
||
expect(response).to be_successful | ||
end | ||
|
||
it 'responds with all the stock locations stock movements' do | ||
subject | ||
|
||
expect(assigns[:stock_movements]).to contain_exactly( | ||
stock_movement_1, | ||
stock_movement_2 | ||
) | ||
end | ||
end | ||
|
||
context 'with search parameters' do | ||
let(:params) do | ||
{ | ||
stock_location_id: stock_location.id, | ||
q: { | ||
variant_sku_eq: stock_movement_1.stock_item.variant.sku | ||
} | ||
} | ||
end | ||
|
||
it 'responds with a successful status code' do | ||
subject | ||
|
||
expect(response).to be_successful | ||
end | ||
|
||
it 'responds with the stock movements that match the search criteria' do | ||
subject | ||
|
||
expect(assigns[:stock_movements]).to contain_exactly( | ||
stock_movement_1, | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters