Only show terms acceptance on new investment form
No need to accept the terms when updating the investment.
This commit is contained in:
@@ -84,7 +84,7 @@
|
||||
|
||||
<%= render SDG::RelatedListSelectorComponent.new(f) %>
|
||||
|
||||
<% unless current_user.manager? %>
|
||||
<% unless current_user.manager? || investment.persisted? %>
|
||||
<div>
|
||||
<%= f.check_box :terms_of_service,
|
||||
title: t("form.accept_terms_title"),
|
||||
|
||||
36
spec/components/budgets/investments/form_component_spec.rb
Normal file
36
spec/components/budgets/investments/form_component_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::Investments::FormComponent, type: :component do
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:current_user).and_return(create(:user))
|
||||
allow(request).to receive(:path_parameters).and_return(budget_id: budget.id)
|
||||
end
|
||||
|
||||
describe "accept terms of services field" do
|
||||
it "is shown for new investments" do
|
||||
investment = build(:budget_investment, budget: budget)
|
||||
|
||||
render_inline Budgets::Investments::FormComponent.new(
|
||||
investment,
|
||||
url: budget_investments_path(budget)
|
||||
)
|
||||
|
||||
expect(page).to have_field "I agree to the Privacy Policy and the Terms and conditions of use"
|
||||
end
|
||||
|
||||
it "is not shown for existing investments" do
|
||||
investment = create(:budget_investment, budget: budget)
|
||||
|
||||
render_inline Budgets::Investments::FormComponent.new(
|
||||
investment,
|
||||
url: budget_investment_path(budget, investment)
|
||||
)
|
||||
|
||||
expect(page).not_to have_field "I agree to the Privacy Policy and the Terms and conditions of use"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -633,7 +633,6 @@ describe "Budget Investments" do
|
||||
|
||||
click_link("Edit", match: :first)
|
||||
fill_in "Title", with: "Park improvements"
|
||||
check "budget_investment_terms_of_service"
|
||||
|
||||
click_button "Update Investment"
|
||||
|
||||
@@ -651,7 +650,6 @@ describe "Budget Investments" do
|
||||
visit user_path(daniel, filter: "budget_investments")
|
||||
click_link("Edit", match: :first)
|
||||
fill_in "Title", with: ""
|
||||
check "budget_investment_terms_of_service"
|
||||
|
||||
click_button "Update Investment"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user