<% if @partner.can_accept_referrals? %>
<%= tag.div(id: "typeform", data: { form_url: @partner.form_url }) %>
@@ -37,7 +39,7 @@
<% if user_signed_in? && @partner.referrals.any? %>
-
Name
diff --git a/app/views/referrals/show.html.erb b/app/views/referrals/show.html.erb
index 67313ca..2a70f91 100644
--- a/app/views/referrals/show.html.erb
+++ b/app/views/referrals/show.html.erb
@@ -56,18 +56,18 @@
<%= f.input :notes, placeholder: "Leave a note to explain your decision.", input_html: { class: "rounded mb20" } %>
- <% if @referral.last_state == "accepted" %>
- <%= f.button :submit, "Accepted", class: "btn-wide", disabled: true %>
+ <% if @referral.last_state == "declined" %>
+ <%= f.button :submit, "Declined", class: "btn-wide", disabled: true %>
<% else %>
- <%= f.button :submit, "Accept", class: "confirm btn-wide", data: { disable_with: "Accepting...", confirm: "Are you sure you want to accept this referral?" } %>
+ <%= f.button :submit, "Decline", class: "confirm btn-invert btn-wide", data: { disable_with: "Declining...", confirm: "Are you sure you want to decline this referral?" } %>
<% end %>
- <% if @referral.last_state == "declined" %>
- <%= f.button :submit, "Declined", class: "btn-wide", disabled: true %>
+ <% if @referral.last_state == "accepted" %>
+ <%= f.button :submit, "Accepted", class: "btn-wide", disabled: true %>
<% else %>
- <%= f.button :submit, "Decline", class: "confirm btn-invert btn-wide", data: { disable_with: "Declining...", confirm: "Are you sure you want to decline this referral?" } %>
+ <%= f.button :submit, "Accept", class: "confirm btn-wide", data: { disable_with: "Accepting...", confirm: "Are you sure you want to accept this referral?" } %>
<% end %>
<% end %>
diff --git a/test/factories/referrals.rb b/test/factories/referrals.rb
index 18e761a..f112cda 100644
--- a/test/factories/referrals.rb
+++ b/test/factories/referrals.rb
@@ -1,13 +1,19 @@
FactoryBot.define do
factory :referral do
- original_response {
+ original_response do
{
form_response: {
calculated: { score: 0 },
- definition: { fields: [{ title: 'q1' }, { title: 'q2' }] },
- answers: [{ text: 'a1' }, { text: 'a2' }]
+ definition: {
+ fields: [
+ { title: 'q1' }, { title: 'q2' }, { title: 'q3' }
+ ]
+ },
+ answers: [
+ { text: 'text' }, { boolean: true }, { choice: { label: 'choice' } }
+ ]
}
}
- }
+ end
end
end
diff --git a/test/models/referral_test.rb b/test/models/referral_test.rb
index 6504a35..cfa096b 100644
--- a/test/models/referral_test.rb
+++ b/test/models/referral_test.rb
@@ -60,11 +60,12 @@ class ReferralTest < ActiveSupport::TestCase
end
test '#response_answers found' do
- assert_equal({ 'q1' => 'a1', 'q2' => 'a2' }, @subject.response_answers)
+ answers = { 'q1' => 'text', 'q2' => 'Yes', 'q3' => 'choice' }
+ assert_equal(answers, @subject.response_answers)
end
test '#response_identifier found' do
- assert_equal('a1', @subject.response_identifier)
+ assert_equal('text', @subject.response_identifier)
end
test '#response_identifier not found' do
diff --git a/test/system/referral_review_test.rb b/test/system/referral_review_test.rb
index c1a8474..ca13a08 100644
--- a/test/system/referral_review_test.rb
+++ b/test/system/referral_review_test.rb
@@ -51,7 +51,7 @@ class ReferralReviewTest < ApplicationSystemTestCase
test 'lists answers' do
visit referral_path(@partner, @referral)
sign_in
- %w[q1 a1 q2 a2].each { |t| assert_text(t) }
+ %w[q1 text q2 Yes q3 choice].each { |t| assert_text(t) }
end
test 'not signed in referrals_path' do