-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
treat title as a single value even though it is multivalue on form
- Loading branch information
Showing
18 changed files
with
145 additions
and
20 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
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
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
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,3 @@ | ||
<% f.object.alt_title.each do |value| %> | ||
<%= f.hidden_field :alt_title, multiple: true, value: value.to_s %> | ||
<% 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 @@ | ||
<%= f.input :title, required: f.object.required?(: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
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
26 changes: 26 additions & 0 deletions
26
spec/views/records/edit_fields/_alt_title.html.erb_spec.rb
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 @@ | ||
RSpec.describe 'records/edit_fields/_title.html.erb', type: :view do | ||
let(:work) { GenericWork.new } | ||
let(:form) { Hyrax::GenericWorkForm.new(work, nil, controller) } | ||
|
||
let(:form_template) do | ||
%( | ||
<%= simple_form_for [main_app, @form] do |f| %> | ||
<%= render "records/edit_fields/alt_title", f: f, key: 'description' %> | ||
<% end %> | ||
) | ||
end | ||
|
||
before do | ||
work.title = ["bbb", "aaa", "ccc"] | ||
work.alt_title = [] | ||
assign(:form, form) | ||
end | ||
|
||
context "when there are 3 titles" do | ||
it 'hides the last 2 after alphabetizing all 3 titles' do | ||
render inline: form_template | ||
expect(rendered).to have_selector('input[type="hidden"][value="bbb"]', visible: false) | ||
expect(rendered).to have_selector('input[type="hidden"][value="ccc"]', visible: false) | ||
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,24 @@ | ||
RSpec.describe 'records/edit_fields/_title.html.erb', type: :view do | ||
let(:work) { GenericWork.new } | ||
let(:form) { Hyrax::GenericWorkForm.new(work, nil, controller) } | ||
|
||
let(:form_template) do | ||
%( | ||
<%= simple_form_for [main_app, @form] do |f| %> | ||
<%= render "records/edit_fields/title", f: f, key: 'description' %> | ||
<% end %> | ||
) | ||
end | ||
|
||
before do | ||
work.title = ["ccc", "bbb", "aaa"] | ||
assign(:form, form) | ||
end | ||
|
||
context "when there are 3 titles" do | ||
it 'displays the first after alphabetizing the list' do | ||
render inline: form_template | ||
expect(rendered).to have_selector('input[class="form-control string required"][value="aaa"]') | ||
end | ||
end | ||
end |