Merge pull request #275 from mlovic/filter-topic
Allow debates to be filtered by topic
This commit is contained in:
@@ -407,4 +407,34 @@ feature 'Debates' do
|
||||
expect(@most_liked_debate.title).to appear_before(@most_voted_debate.title)
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Debates can be filtered by tags', :js do
|
||||
let!(:debate1) { create(:debate, tag_list: ["Deporte", "Corrupción"]) }
|
||||
let!(:debate2) { create(:debate, tag_list: ["Deporte", "Fiestas populares"]) }
|
||||
let!(:debate3) { create(:debate, tag_list: ["Corrupción", "Fiestas populares"]) }
|
||||
|
||||
scenario 'By default no tag filter is applied' do
|
||||
visit debates_path
|
||||
|
||||
expect(page).to have_content('Filter by topic')
|
||||
expect(page).not_to have_content('with the topic')
|
||||
expect(page).to have_selector('#debates .debate', count: 3)
|
||||
end
|
||||
|
||||
scenario 'Debates are filtered by single tag' do
|
||||
visit debates_path
|
||||
|
||||
select('Deporte', from: 'tag-filter')
|
||||
|
||||
expect(page).not_to have_content('Filter by topic')
|
||||
expect(page).not_to have_select('tag-filter')
|
||||
expect(page).to have_content('with the topic')
|
||||
expect(current_url).to include('tag=Deporte')
|
||||
|
||||
expect(page).to have_selector('#debates .debate', count: 2)
|
||||
expect(page).to_not have_content(debate3.title)
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user