<% @junior_stories.each do |j| %>
diff --git a/spec/controllers/junior_story_controller_spec.rb b/spec/controllers/junior_story_controller_spec.rb
new file mode 100644
index 0000000..1cb67a9
--- /dev/null
+++ b/spec/controllers/junior_story_controller_spec.rb
@@ -0,0 +1,81 @@
+require 'rails_helper'
+
+describe JuniorStoriesController do
+ describe 'GET index' do
+ context 'without filter params' do
+ it 'assigns @junior_stories' do
+ story = build :junior_story
+ story.save
+ get :index
+ expect(assigns(:junior_stories)).to eq([story])
+ end
+
+ it 'renders the index template' do
+ get :index
+ expect(response).to render_template('index')
+ end
+
+ it 'does not render index, but instead responds with csv' do
+ get :index, format: 'csv'
+ expect(response).not_to render_template('index')
+ expect(response.content_type).to include 'application/csv'
+ end
+ end
+
+ context 'with legal filter params' do
+ it 'returns only the filter appropriate junior_story' do
+ female_story = build :junior_story
+ female_story.gender = 'female'
+ female_story.save
+
+ male_story = build :junior_story
+ male_story.gender = 'male'
+ male_story.save
+
+
+ get :index, { 'gender' => 'female' }
+ expect(assigns(:junior_stories)).to eq([female_story])
+ end
+
+ it 'renders the index template' do
+ get :index, { 'gender' => 'female' }
+ get :index
+ expect(response).to render_template('index')
+ end
+
+ it 'does not render index, but instead responds with csv' do
+ get :index, { 'gender' => 'female', 'format' => 'csv' }
+ expect(response).not_to render_template('index')
+ expect(response.content_type).to include 'application/csv'
+ end
+ end
+
+ context 'with illegal filter params' do
+ it 'ignores illegal filter params but respects legal filter params' do
+ female_story = build :junior_story
+ female_story.gender = 'female'
+ female_story.save
+
+ male_story = build :junior_story
+ male_story.gender = 'male'
+ male_story.save
+
+
+ get :index, { 'makes_no_sense' => 'random', 'gender' => 'female' }
+ expect(assigns(:junior_stories)).to eq([female_story])
+ end
+
+ it 'renders the index template' do
+ get :index, { 'makes_no_sense' => 'random' }
+ get :index
+ expect(response).to render_template('index')
+ end
+
+ it 'does not render index, but instead responds with csv' do
+ get :index, { 'makes_no_sense' => 'random', 'format' => 'csv' }
+ expect(response).not_to render_template('index')
+ expect(response.content_type).to include 'application/csv'
+ end
+ end
+ end
+end
diff --git a/spec/controllers/junior_stroy_controller_spec.rb b/spec/controllers/junior_stroy_controller_spec.rb
deleted file mode 100644
index b9c3f84..0000000
--- a/spec/controllers/junior_stroy_controller_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'rails_helper'
-
-describe JuniorStoriesController do
- describe 'GET index' do
- it 'assigns @junior_stories' do
- story = build :junior_story
- story.save
- get :index
- expect(assigns(:junior_stories)).to eq([story])
- end
-
- it 'renders the index template' do
- get :index
- expect(response).to render_template('index')
- end
-
- it 'does not render index, but instead responds with csv' do
- get :index, format: 'csv'
- expect(response).not_to render_template('index')
- expect(response.content_type).to include 'application/csv'
- end
- end
-end