Only make suggestions for related titles for new records
Avoid show suggestions for :edit and :update actions.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
module SuggestionsHelper
|
||||
def suggest_data(record)
|
||||
return unless record.new_record?
|
||||
|
||||
{
|
||||
js_suggest_result: "js_suggest_result",
|
||||
js_suggest: ".js-suggest",
|
||||
|
||||
@@ -661,6 +661,30 @@ describe "Budget Investments" do
|
||||
expect(page).not_to have_content "You are seeing"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Don't show suggestions" do
|
||||
let(:investment) { create(factory, title: "Title, has search term", budget: budget, author: author) }
|
||||
|
||||
before do
|
||||
login_as(author)
|
||||
visit edit_budget_investment_path(budget, investment)
|
||||
end
|
||||
|
||||
scenario "for edit action" do
|
||||
fill_in "Title", with: "search"
|
||||
|
||||
expect(page).not_to have_content "There is an investment with the term 'search'"
|
||||
end
|
||||
|
||||
scenario "for update action" do
|
||||
fill_in "Title", with: ""
|
||||
|
||||
click_button "Update Investment"
|
||||
fill_in "Title", with: "search"
|
||||
|
||||
expect(page).not_to have_content "There is an investment with the term 'search'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Ballot is not visible" do
|
||||
|
||||
@@ -770,6 +770,31 @@ describe "Debates" do
|
||||
expect(page).not_to have_content "You are seeing"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Don't show suggestions" do
|
||||
let(:user) { create(:user) }
|
||||
let(:debate) { create(:debate, title: "Debate title, has search term", author: user) }
|
||||
|
||||
before do
|
||||
login_as(user)
|
||||
visit edit_debate_path(debate)
|
||||
end
|
||||
|
||||
scenario "for edit action" do
|
||||
fill_in "Debate title", with: "search"
|
||||
|
||||
expect(page).not_to have_content "There is a debate with the term 'search'"
|
||||
end
|
||||
|
||||
scenario "for update action" do
|
||||
fill_in "Debate title", with: ""
|
||||
|
||||
click_button "Save changes"
|
||||
fill_in "Debate title", with: "search"
|
||||
|
||||
expect(page).not_to have_content "There is a debate with the term 'search'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Mark/Unmark a debate as featured", :admin do
|
||||
|
||||
@@ -1440,6 +1440,31 @@ describe "Proposals" do
|
||||
expect(page).not_to have_content "You are seeing"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Don't show suggestions" do
|
||||
let(:user) { create(:user) }
|
||||
let(:proposal) { create(:proposal, title: "Proposal title, has search term", author: user) }
|
||||
|
||||
before do
|
||||
login_as(user)
|
||||
visit edit_proposal_path(proposal)
|
||||
end
|
||||
|
||||
scenario "for edit action" do
|
||||
fill_in "Proposal title", with: "search"
|
||||
|
||||
expect(page).not_to have_content "There is a proposal with the term 'search'"
|
||||
end
|
||||
|
||||
scenario "for update action" do
|
||||
fill_in "Proposal title", with: ""
|
||||
|
||||
click_button "Save changes"
|
||||
fill_in "Proposal title", with: "search"
|
||||
|
||||
expect(page).not_to have_content "There is a proposal with the term 'search'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Summary" do
|
||||
|
||||
Reference in New Issue
Block a user