Skip to content

Commit

Permalink
Use the correct parameters for the upload set form
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 10, 2015
1 parent 55686dc commit b66d924
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_update_job
UploadSetUpdateJob.perform_later(current_user.user_key,
params[:id],
params[:title],
edit_form_class.model_attributes(params[:work]),
edit_form_class.model_attributes(params[:upload_set]),
params[:visibility])
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/upload_sets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it "enqueues a upload_set job and redirects to generic_works list with a flash message" do
expect(UploadSetUpdateJob).to receive(:perform_later).with(user.user_key, upload_set.id, { '1' => 'foo' },
{ tag: [] }, 'open').once
post :update, id: upload_set.id, title: { '1' => 'foo' }, visibility: 'open', work: { tag: [""] }
post :update, id: upload_set.id, title: { '1' => 'foo' }, visibility: 'open', upload_set: { tag: [""] }
expect(response).to redirect_to routes.url_helpers.curation_concerns_generic_works_path
expect(flash[:notice]).to include("Your files are being processed")
end
Expand All @@ -25,20 +25,20 @@
let!(:work) { create(:generic_work, user: user, upload_set: upload_set) }

it "they can set public read access" do
post :update, id: upload_set, visibility: "open", work: { tag: [""] }
post :update, id: upload_set, visibility: "open", upload_set: { tag: [""] }
expect(work.reload.read_groups).to eq ['public']
end

it "they can set metadata like title" do
post :update, id: upload_set, work: { tag: ["footag", "bartag"] }, title: { work.id => ["New Title"] }
post :update, id: upload_set, upload_set: { tag: ["footag", "bartag"] }, title: { work.id => ["New Title"] }
work.reload
expect(work.title).to eq ["New Title"]
# TODO: is order important?
expect(work.tag).to include("footag", "bartag")
end

it "they cannot set any tags" do
post :update, id: upload_set, work: { tag: [""] }
post :update, id: upload_set, upload_set: { tag: [""] }
expect(work.reload.tag).to be_empty
end
end
Expand All @@ -48,8 +48,8 @@
let!(:work) { create(:generic_work, title: ['Original Title'], upload_set: upload_set) }

it "they cannot modify the object" do
post :update, id: upload_set, "work" => { "tag" => [""] },
"title" => { work.id => "Title Won't Change" }
post :update, id: upload_set, upload_set: { "tag" => [""] },
title: { work.id => "Title Won't Change" }
work.reload
expect(work.title).to eq ["Original Title"]
end
Expand Down

0 comments on commit b66d924

Please sign in to comment.