-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass the proper arguments to boostrap_form_tag. Fixes #39
- Loading branch information
Showing
6 changed files
with
53 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<h1><%= t('hydra_editor.choose_type.title') %></h1> | ||
<%= bootstrap_form_tag hydra_editor.new_record_path, :method => :get do |f| %> | ||
<%= bootstrap_select_tag :type, options_for_select(object_type_options) %> | ||
<%= bootstrap_actions do %> | ||
<%= bootstrap_submit_tag 'Next' %> | ||
<% end %> | ||
<%= bootstrap_form_tag url: hydra_editor.new_record_path, method: :get do |f| %> | ||
<label class="control-label" for="type">Select an object type</label> | ||
<%= select_tag :type, options_for_select(object_type_options) %> | ||
<%= f.primary t('hydra_editor.choose_type.next') %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'spec_helper' | ||
|
||
feature 'User creates an object' do | ||
let(:user) { FactoryGirl.create(:user) } | ||
|
||
before do | ||
HydraEditor.models = ['Audio'] | ||
login_as user | ||
# since we're stubbing save, we won't have an id to redirect to. | ||
allow_any_instance_of(RecordsController).to receive(:redirect_after_create).and_return("/404.html") | ||
end | ||
|
||
scenario 'with a TuftsAudio' do | ||
visit '/records/new' | ||
|
||
select "Audio", from: 'Select an object type' | ||
click_button 'Next' | ||
|
||
fill_in '*Title', with: 'My title' | ||
|
||
expect_any_instance_of(Audio).to receive(:attributes=).with({}) # called when initializing a new object | ||
expect_any_instance_of(Audio).to receive(:attributes=).with(title: ["My title"]) | ||
# Avoid the catalog so we don't have to run Solr | ||
expect_any_instance_of(Audio).to receive(:save).and_return(true) | ||
click_button 'Save' | ||
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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
describe "record editing" do | ||
let(:user) { FactoryGirl.create(:user) } | ||
let(:record) { Audio.new(pid: "foo:1", title: "Cool Track") } | ||
# We need a clone to give to the edit view b/c it gets changed by initialize_fields | ||
let(:record_clone) { Audio.new(pid: "foo:1", title: "Cool Track") } | ||
|
||
before do | ||
HydraEditor.models = ['Audio'] | ||
@user = FactoryGirl.create(:user) | ||
@ability = double(Ability) | ||
@ability.stub(:authorize!).and_return(true) | ||
Ability.stub(:new).with(@user).and_return(@ability) | ||
allow_any_instance_of(Ability).to receive(:authorize!).and_return(true) | ||
# Avoid the catalog so we don't have to run Solr | ||
allow_any_instance_of(RecordsController).to receive(:redirect_after_update).and_return("/404.html") | ||
allow_any_instance_of(Audio).to receive(:persisted?).and_return(true) | ||
allow_any_instance_of(Audio).to receive(:new_record?).and_return(false) | ||
allow_any_instance_of(Audio).to receive(:save).and_return(true) | ||
@record = Audio.new(pid: "foo:1", title: "Cool Track") | ||
# We need a clone to give to the edit view b/c it gets changed by initialize_fields | ||
@record_clone = Audio.new(pid: "foo:1", title: "Cool Track") | ||
|
||
# We use the original record for the update view to start clean and apply the form data | ||
ActiveFedora::Base.should_receive(:find).with(@record.pid, cast: true).and_return(@record_clone, @record) | ||
login_as @user | ||
expect(ActiveFedora::Base).to receive(:find).with(record.pid, cast: true).and_return(record_clone, record) | ||
login_as user | ||
end | ||
|
||
after do | ||
Warden.test_reset! | ||
end | ||
it "should be idempotent" do | ||
visit "/records/#{@record.pid}/edit" | ||
visit "/records/#{record.pid}/edit" | ||
click_button 'Save' | ||
@record.title.should == ["Cool Track"] | ||
@record.creator.should == [] | ||
@record.description.should == [] | ||
@record.subject.should == [] | ||
expect(record.title).to eq ["Cool Track"] | ||
expect(record.creator).to eq [] | ||
expect(record.description).to eq [] | ||
expect(record.subject).to eq [] | ||
end | ||
end |