adds multiple filters spec
This commit is contained in:
@@ -2,8 +2,8 @@ module Filterable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
scope :by_author, -> (username) { where(users: { username: username }).includes(:author) }
|
||||
scope :by_official_level, -> (official_level) { where(users: { official_level: official_level }).includes(:author) }
|
||||
scope :by_author, -> (username) { where(users: { username: username }).joins(:author) }
|
||||
scope :by_official_level, -> (official_level) { where(users: { official_level: official_level }).joins(:author) }
|
||||
scope :by_date_range, -> (date_range) { where(created_at: date_range) }
|
||||
end
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ feature 'Debates' do
|
||||
|
||||
visit edit_debate_path(debate)
|
||||
expect(current_path).not_to eq(edit_debate_path(debate))
|
||||
expect(current_path).to eq(proposals_path)
|
||||
expect(current_path).to eq(debates_path)
|
||||
expect(page).to have_content "You do not have permission to carry out the action 'edit' on debate."
|
||||
end
|
||||
|
||||
@@ -264,7 +264,7 @@ feature 'Debates' do
|
||||
visit edit_debate_path(debate)
|
||||
|
||||
expect(current_path).not_to eq(edit_debate_path(debate))
|
||||
expect(current_path).to eq(proposals_path)
|
||||
expect(current_path).to eq(debates_path)
|
||||
expect(page).to have_content 'You do not have permission to'
|
||||
end
|
||||
|
||||
@@ -604,13 +604,35 @@ feature 'Debates' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Search by multiple filters", :js do
|
||||
ana = create :user, username: "Ana06", official_level: 1
|
||||
john = create :user, username: "John", official_level: 1
|
||||
|
||||
debate1 = create(:debate, title: "Get Schwifty", author: ana, created_at: 1.minute.ago)
|
||||
debate2 = create(:debate, title: "Hello Schwifty", author: john, created_at: 1.minute.ago)
|
||||
debate3 = create(:debate, title: "Save the forest")
|
||||
|
||||
visit debates_path
|
||||
|
||||
find("h4.advanced-search-title").click
|
||||
fill_in "Write the text", with: "Schwifty"
|
||||
fill_in "Write the author name", with: "Ana06"
|
||||
select "Public employee", from: "advanced_search_official_level"
|
||||
select "Last 24 hours", from: "advanced_search_date_min"
|
||||
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 1)
|
||||
expect(page).to have_content(debate1.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Maintain advanced search criteria", :js do
|
||||
visit debates_path
|
||||
find("h4.advanced-search-title").click
|
||||
|
||||
### Pending fix when searching for text and another criteria
|
||||
#fill_in "Write the text", with: "Schwifty"
|
||||
###
|
||||
fill_in "Write the text", with: "Schwifty"
|
||||
fill_in "Write the author name", with: "Ana06"
|
||||
select "Public employee", from: "advanced_search_official_level"
|
||||
select "Last 24 hours", from: "advanced_search_date_min"
|
||||
@@ -618,7 +640,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within "#advanced-search" do
|
||||
###expect(page).to have_selector("input[name='search'][value='Schwifty']")
|
||||
expect(page).to have_selector("input[name='search'][value='Schwifty']")
|
||||
expect(page).to have_selector("input[name='advanced_search[author]'][value='Ana06']")
|
||||
expect(page).to have_select('advanced_search[official_level]', selected: 'Public employee')
|
||||
expect(page).to have_select('advanced_search[date_min]', selected: 'Last 24 hours')
|
||||
|
||||
@@ -667,13 +667,36 @@ feature 'Proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Maintain advanced search criteria", :js do
|
||||
scenario "Search by multiple filters", :js do
|
||||
ana = create :user, username: "Ana06", official_level: 1
|
||||
john = create :user, username: "John", official_level: 1
|
||||
|
||||
proposal1 = create(:proposal, title: "Get Schwifty", author: ana, created_at: 1.minute.ago)
|
||||
proposal2 = create(:proposal, title: "Hello Schwifty", author: john, created_at: 1.minute.ago)
|
||||
proposal3 = create(:proposal, title: "Save the forest")
|
||||
|
||||
visit proposals_path
|
||||
|
||||
find("h4.advanced-search-title").click
|
||||
fill_in "Write the text", with: "Schwifty"
|
||||
fill_in "Write the author name", with: "Ana06"
|
||||
select "Public employee", from: "advanced_search_official_level"
|
||||
select "Last 24 hours", from: "advanced_search_date_min"
|
||||
|
||||
click_button "Filter"
|
||||
|
||||
within("#proposals") do
|
||||
expect(page).to have_css('.proposal', count: 1)
|
||||
|
||||
expect(page).to have_content(proposal1.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Maintain advanced search criteria", :js, :focus do
|
||||
visit proposals_path
|
||||
find("h4.advanced-search-title").click
|
||||
|
||||
### Pending fix when searching for text and another criteria
|
||||
#fill_in "Write the text", with: "Schwifty"
|
||||
###
|
||||
fill_in "Write the text", with: "Schwifty"
|
||||
fill_in "Write the author name", with: "Ana06"
|
||||
select "Public employee", from: "advanced_search_official_level"
|
||||
select "Last 24 hours", from: "advanced_search_date_min"
|
||||
@@ -681,7 +704,7 @@ feature 'Proposals' do
|
||||
click_button "Filter"
|
||||
|
||||
within "#advanced-search" do
|
||||
###expect(page).to have_selector("input[name='search'][value='Schwifty']")
|
||||
expect(page).to have_selector("input[name='search'][value='Schwifty']")
|
||||
expect(page).to have_selector("input[name='advanced_search[author]'][value='Ana06']")
|
||||
expect(page).to have_select('advanced_search[official_level]', selected: 'Public employee')
|
||||
expect(page).to have_select('advanced_search[date_min]', selected: 'Last 24 hours')
|
||||
|
||||
Reference in New Issue
Block a user