Browse Source

update method name

pull/755/head
Kat 3 years ago
parent
commit
e3ed7434c0
  1. 2
      app/models/form/question.rb
  2. 2
      app/models/form/setup/questions/scheme_id.rb
  3. 2
      app/views/form/_select_question.html.erb
  4. 8
      spec/models/form/setup/questions/owning_organisation_id_spec.rb
  5. 8
      spec/models/form/setup/questions/scheme_id_spec.rb

2
app/models/form/question.rb

@ -228,7 +228,7 @@ class Form::Question
resource.hint resource.hint
end end
def answer_selected(case_log, answer) def answer_selected?(case_log, answer)
case_log[id].to_s == answer.id.to_s case_log[id].to_s == answer.id.to_s
end end

2
app/models/form/setup/questions/scheme_id.rb

@ -32,7 +32,7 @@ class Form::Setup::Questions::SchemeId < ::Form::Question
!supported_housing_selected?(case_log) !supported_housing_selected?(case_log)
end end
def answer_selected(case_log, answer) def answer_selected?(case_log, answer)
case_log[id] == answer.name || case_log[id] == answer.resource case_log[id] == answer.name || case_log[id] == answer.resource
end end

2
app/views/form/_select_question.html.erb

@ -12,7 +12,7 @@
data-synonyms="<%= question.answer_option_synonyms(answer.resource) %>" data-synonyms="<%= question.answer_option_synonyms(answer.resource) %>"
data-append="<%= question.answer_option_append(answer.resource) %>" data-append="<%= question.answer_option_append(answer.resource) %>"
data-hint="<%= question.answer_option_hint(answer.resource) %>" data-hint="<%= question.answer_option_hint(answer.resource) %>"
<%= question.answer_selected(@case_log, answer) ? "selected" : "" %> <%= question.answer_selected?(@case_log, answer) ? "selected" : "" %>
<%= answer.id == "" ? "disabled" : "" %>><%= answer.name || answer.resource %></option> <%= answer.id == "" ? "disabled" : "" %>><%= answer.name || answer.resource %></option>
<% end %> <% end %>
<% end %> <% end %>

8
spec/models/form/setup/questions/owning_organisation_id_spec.rb

@ -73,9 +73,9 @@ RSpec.describe Form::Setup::Questions::OwningOrganisationId, type: :model do
answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: nil, resource: value) } answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: nil, resource: value) }
answers.each do |answer| answers.each do |answer|
if answer.resource == "Select an option" if answer.resource == "Select an option"
expect(question.answer_selected(case_log, answer)).to eq(true) expect(question.answer_selected?(case_log, answer)).to eq(true)
else else
expect(question.answer_selected(case_log, answer)).to eq(false) expect(question.answer_selected?(case_log, answer)).to eq(false)
end end
end end
end end
@ -87,9 +87,9 @@ RSpec.describe Form::Setup::Questions::OwningOrganisationId, type: :model do
answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) }
answers.each do |answer| answers.each do |answer|
if answer.id == organisation_1.id if answer.id == organisation_1.id
expect(question.answer_selected(case_log, answer)).to eq(true) expect(question.answer_selected?(case_log, answer)).to eq(true)
else else
expect(question.answer_selected(case_log, answer)).to eq(false) expect(question.answer_selected?(case_log, answer)).to eq(false)
end end
end end
end end

8
spec/models/form/setup/questions/scheme_id_spec.rb

@ -73,9 +73,9 @@ RSpec.describe Form::Setup::Questions::SchemeId, type: :model do
answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) }
answers.each do |answer| answers.each do |answer|
if answer.resource == "Select an option" if answer.resource == "Select an option"
expect(question.answer_selected(case_log, answer)).to eq(true) expect(question.answer_selected?(case_log, answer)).to eq(true)
else else
expect(question.answer_selected(case_log, answer)).to eq(false) expect(question.answer_selected?(case_log, answer)).to eq(false)
end end
end end
end end
@ -87,9 +87,9 @@ RSpec.describe Form::Setup::Questions::SchemeId, type: :model do
answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } answers = question.displayed_answer_options(case_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) }
answers.each do |answer| answers.each do |answer|
if answer.id == scheme.id if answer.id == scheme.id
expect(question.answer_selected(case_log, answer)).to eq(true) expect(question.answer_selected?(case_log, answer)).to eq(true)
else else
expect(question.answer_selected(case_log, answer)).to eq(false) expect(question.answer_selected?(case_log, answer)).to eq(false)
end end
end end
end end

Loading…
Cancel
Save