diff --git a/app/helpers/suggestions_helper.rb b/app/helpers/suggestions_helper.rb index 9ba97352f..0119bb77f 100644 --- a/app/helpers/suggestions_helper.rb +++ b/app/helpers/suggestions_helper.rb @@ -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", diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index 8d34dc287..4270f1db4 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -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 diff --git a/spec/system/debates_spec.rb b/spec/system/debates_spec.rb index 60ee384dc..bb5e66138 100644 --- a/spec/system/debates_spec.rb +++ b/spec/system/debates_spec.rb @@ -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 diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index 76ee2453e..3975a6999 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -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