aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-26 15:08:52 +0100
committerJohan Van Ryseghem2018-03-07 13:19:41 +0100
commit9ab833af378b725c92173e8c1ec05199518ff4c0 (patch)
tree2e0e2eeb6dda9cbd269998091ee0f85a6a6d2aa0
parentf372eda831e91da367007f3e0aef725c6a67c574 (diff)
downloadchouette-core-9ab833af378b725c92173e8c1ec05199518ff4c0.tar.bz2
AutocompleteLinesController: Add basic specs for filters
Simple checks that the filters by `number`, line `name`, and company `name` work. Refs #5889
-rw-r--r--spec/controllers/autocomplete_lines_controller_spec.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/controllers/autocomplete_lines_controller_spec.rb b/spec/controllers/autocomplete_lines_controller_spec.rb
new file mode 100644
index 000000000..a238f35e9
--- /dev/null
+++ b/spec/controllers/autocomplete_lines_controller_spec.rb
@@ -0,0 +1,50 @@
+RSpec.describe AutocompleteLinesController, type: :controller do
+ login_user
+
+ describe "GET #index" do
+ let(:referential) { Referential.first }
+ let(:company) { create(:company, name: 'Standard Rail') }
+ let!(:line) do
+ create(
+ :line,
+ number: '15',
+ name: 'Continent Express',
+ company: company
+ )
+ end
+
+ before(:each) do
+ excluded_company = create(:company, name: 'excluded company')
+ create(
+ :line,
+ number: 'different',
+ name: 'other',
+ company: excluded_company
+ )
+ end
+
+ it "filters by `number`" do
+ get :index,
+ referential_id: referential.id,
+ q: '15'
+
+ expect(assigns(:lines)).to eq([line])
+ end
+
+ it "filters by `name`" do
+ get :index,
+ referential_id: referential.id,
+ q: 'Continent'
+
+ expect(assigns(:lines)).to eq([line])
+ end
+
+ it "filters by company `name`" do
+ get :index,
+ referential_id: referential.id,
+ q: 'standard'
+
+ expect(assigns(:lines)).to eq([line])
+ end
+ end
+end