Skip to content

Commit

Permalink
Merge branch 'main' into issue-286-s3-test
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea committed Aug 15, 2022
2 parents 4dd8d1e + 87ab8bd commit 5486e3f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 2 additions & 3 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Work < ApplicationRecord
transitions from: [:withdrawn, :awaiting_approval], to: :awaiting_approval
end

after_all_transitions :track_state_change
after_all_events :track_state_change
end

class << self
Expand All @@ -45,8 +45,7 @@ def create_skeleton(title, user_id, collection_id, work_type, profile)
end

# Convenience method to create Datasets with the DataCite profile
def create_dataset(title, user_id, collection_id, datacite_resource = nil, ark = nil)
datacite_resource = PULDatacite::Resource.new(title: title) if datacite_resource.nil?
def create_dataset(title, user_id, collection_id, datacite_resource, ark = nil)
work = default_work(title, user_id, collection_id, datacite_resource, ark)
work.draft_doi

Expand Down
4 changes: 4 additions & 0 deletions spec/controllers/works_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,24 @@
post :approve, params: { id: work.id }
expect(response.status).to be 302
expect(response.location).to eq "http://test.host/works/#{work.id}"
expect(work.reload).to be_approved
end

it "handles withdraw" do
sign_in user
post :withdraw, params: { id: work.id }
expect(response.status).to be 302
expect(response.location).to eq "http://test.host/works/#{work.id}"
expect(work.reload).to be_withdrawn
end

it "handles resubmit" do
sign_in user
work.withdraw!(user)
post :resubmit, params: { id: work.id }
expect(response.status).to be 302
expect(response.location).to eq "http://test.host/works/#{work.id}"
expect(work.reload).to be_awaiting_approval
end

it "handles the show page" do
Expand Down
10 changes: 5 additions & 5 deletions spec/models/work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@

describe "#created_by_user" do
context "when the ID is invalid" do
subject(:work) { described_class.create_dataset(title, user_id, collection_id) }
subject(:work) { described_class.create_dataset(title, user_id, collection_id, nil) }
let(:title) { "test title" }
let(:user_id) { user.id }
let(:collection_id) { collection.id }
Expand Down Expand Up @@ -219,11 +219,11 @@

describe "datasets waiting for approval by user type" do
before do
described_class.create_dataset("test title 1", user.id, collection.id)
described_class.create_dataset("test title 2", user.id, collection.id)
described_class.create_dataset("test title 3", pppl_user.id, Collection.plasma_laboratory.id)
described_class.create_dataset("test title 1", user.id, collection.id, nil)
described_class.create_dataset("test title 2", user.id, collection.id, nil)
described_class.create_dataset("test title 3", pppl_user.id, Collection.plasma_laboratory.id, nil)
# Create the dataset for `lib_user`` and @mention `user`
ds = described_class.create_dataset("test title 4", lib_user.id, Collection.library_resources.id)
ds = described_class.create_dataset("test title 4", lib_user.id, Collection.library_resources.id, nil)
WorkActivity.add_system_activity(ds.id, "Tagging @#{user.uid} in this dataset", lib_user.id)
end

Expand Down

0 comments on commit 5486e3f

Please sign in to comment.