-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hides search bar when no attributes are searchable * adds tests for search bar display logic * extracts capture_view_locals method to ControllerHelpers * no need for page argument to show_search_bar? method * streamlines show_search_bar? method
- Loading branch information
1 parent
4ecced1
commit b28f125
Showing
6 changed files
with
47 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "rails_helper" | ||
|
||
describe Admin::LineItemsController, type: :controller do | ||
describe "GET index" do | ||
it "hides the search bar" do | ||
line_item = create(:line_item) | ||
|
||
locals = capture_view_locals { get :index } | ||
expect(locals[:show_search_bar]).to be_falsey | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module ControllerHelpers | ||
def capture_view_locals | ||
allow(@controller).to receive(:render) | ||
yield | ||
|
||
locals = nil | ||
expect(@controller).to have_received(:render).at_least(1).times do |*args| | ||
args.each do |arg| | ||
locals ||= arg.try(:fetch, :locals, nil) | ||
end | ||
end | ||
locals | ||
end | ||
end |