-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from co-cddo/add-summary-step
Add summary step to workflow
- Loading branch information
Showing
13 changed files
with
114 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class SummaryForm < BaseForm | ||
def update_item | ||
item.metadata["summary"] = params.dig(:item, :summary).presence | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<%= form_with(model: @form.item) do |form| %> | ||
<%= render 'shared/form_errors', model: @form %> | ||
|
||
<%= form.govuk_text_field :alternative_title, label: { text: 'Alternative title'} %> | ||
|
||
<div> | ||
<%= form.govuk_submit %> | ||
</div> | ||
<% end %> | ||
<%= form.govuk_text_field( | ||
:alternative_title, | ||
label: { text: 'Alternative title'}, | ||
value: form.object.metadata['alternativeTitle'] | ||
) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= form.govuk_text_area :summary, value: form.object.metadata['summary'] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
<%= form_with(url: items_path, model: @form.item) do |form| %> | ||
<%= render 'shared/form_errors', model: @form %> | ||
|
||
<%= form.govuk_text_field :title %> | ||
|
||
<div> | ||
<%= form.govuk_submit %> | ||
</div> | ||
<% end %> | ||
<%= form.govuk_text_field :title, value: form.object.metadata['title'] %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe SummaryForm, type: :model do | ||
let(:item) { create :item } | ||
let(:summary) { Faker::Lorem.paragraph } | ||
let(:params) do | ||
{ item: { summary: } } | ||
end | ||
let(:summary_form) { described_class.new(item:, params:) } | ||
|
||
describe "#save" do | ||
it "saves the summary to metadata" do | ||
summary_form.save | ||
expect(item.reload.metadata["summary"]).to eq(summary) | ||
end | ||
|
||
context "with blank entry" do | ||
let(:summary) { "" } | ||
|
||
it "saves an empty array to alternative title" do | ||
summary_form.save | ||
expect(item.reload.metadata["summary"]).to be_nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "items workflow", type: :request do | ||
let(:steps) do | ||
{ | ||
title: Faker::Company.name, | ||
alternative_title: Faker::Company.name, | ||
summary: Faker::Lorem.paragraph, | ||
} | ||
end | ||
|
||
it "visits each step in the flow" do | ||
item = nil | ||
steps.each do |step, input| | ||
if step == steps.keys.first | ||
post items_url, params: { item: { step => input } } | ||
item = Item.last | ||
else | ||
patch item_url(item), params: { item: { step => input } } | ||
end | ||
|
||
if step == steps.keys.last | ||
expect(response).to redirect_to(item_url(item)) | ||
else | ||
expect(response).to redirect_to(edit_item_url(item)), "#{step} didn't redirect to next step" | ||
end | ||
|
||
expect(item.reload.metadata[step.to_s.camelize(:lower)]).to include(input), "#{step} in metadata was not: #{input}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters