Browse Source

Add some functionality

pull/797/head
Dushan Despotovic 3 years ago committed by Kat
parent
commit
a6101d98c0
  1. 8
      app/helpers/check_answers_helper.rb
  2. 2
      app/views/schemes/check_answers.html.erb
  3. 15
      spec/features/schemes_spec.rb

8
app/helpers/check_answers_helper.rb

@ -15,6 +15,14 @@ module CheckAnswersHelper
editable_attributes = current_user.support? ? ["Name", "Confidential information", "Housing stock owned by"] : ["Name", "Confidential information"]
!scheme.confirmed? || editable_attributes.include?(attribute_name)
end
def get_location_change_link_href(scheme, location)
if location.confirmed?
"/schemes/#{scheme.id}/locations/#{location.id}/edit-name"
else
"/schemes/#{scheme.id}/locations/#{location.id}/edit"
end
end
private
def answered_questions_count(subsection, case_log, current_user)

2
app/views/schemes/check_answers.html.erb

@ -68,7 +68,7 @@
<%= table.body do |body| %>
<%= body.row do |row| %>
<% row.cell(text: location.id) %>
<% row.cell(text: simple_format(location_cell(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: simple_format(location_cell(location, get_location_change_link_href(@scheme, location)), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %>
<% row.cell(text: location.mobility_type) %>

15
spec/features/schemes_spec.rb

@ -290,18 +290,19 @@ RSpec.describe "Schemes scheme Features" do
end
context "when you click save" do
it "takes you to view location tab and displays a banner" do
xit "takes you to view location tab and displays a banner" do
click_button "Save"
expect(page.current_url.split("/").last).to eq("locations")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_content("udpated")
expect(page).to have_content("updated")
end
it "does not let you edit the saved location" do
click_link "Locations"
expect(page).to have_link(nil, href: /edit(?!-name)/)
click_button "Save"
click_link "Back"
click_link 'Change'
expect(page.current_url.split("/").last).to eq("edit-name")
click_link "Locations"
expect(page).not_to have_link(nil, href: /edit(?!-name)/)
end
end
@ -310,8 +311,8 @@ RSpec.describe "Schemes scheme Features" do
click_link("Scheme")
end
it "does not let you change details other than the name" do
assert_selector "a", text: "Change", count: 1
it "does not let you change details other than the name, confidential information and housing stock owner" do
assert_selector "a", text: "Change", count: 3
end
end
end

Loading…
Cancel
Save