-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mccalluc-no-partial-match-ark-doi
- Loading branch information
Showing
12 changed files
with
184 additions
and
37 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 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
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,72 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
describe "Messages" do | ||
let(:user) { FactoryBot.create :user } | ||
let(:work) { FactoryBot.create :draft_work } | ||
let(:partial) { "works/work_activity_messages" } | ||
let(:older) do | ||
WorkActivity.add_work_activity(work.id, "older", user.id, | ||
activity_type: WorkActivity::MESSAGE, created_at: "2021-01-01") | ||
end | ||
let(:newer) do | ||
WorkActivity.add_work_activity(work.id, "newer", user.id, | ||
activity_type: WorkActivity::MESSAGE, created_at: "2022-01-01") | ||
end | ||
|
||
it "handles no messages" do | ||
assign(:work, work) | ||
assign(:messages, []) | ||
render(partial: partial) | ||
expect(rendered).to include("No messages") | ||
end | ||
|
||
it "handles unknown user" do | ||
assign(:work, work) | ||
assign(:messages, [WorkActivity.add_work_activity(work.id, "message!", nil, | ||
activity_type: WorkActivity::MESSAGE)]) | ||
render(partial: partial) | ||
expect(rendered).to include("Unknown user outside the system") | ||
end | ||
|
||
it "handles submission notes" do | ||
work.submission_notes = "submission note!" | ||
assign(:work, work) | ||
assign(:messages, [WorkActivity.add_work_activity(work.id, "message!", user.id, | ||
activity_type: WorkActivity::MESSAGE)]) | ||
render(partial: partial) | ||
expect(rendered).to include("submission note!") | ||
end | ||
|
||
it "handles message" do | ||
assign(:work, work) | ||
assign(:messages, [WorkActivity.add_work_activity(work.id, "message!", user.id, | ||
activity_type: WorkActivity::MESSAGE)]) | ||
render(partial: partial) | ||
expect(rendered).to include("message!") | ||
expect(rendered).to include("(@#{user.uid})") | ||
end | ||
|
||
it "handles notification" do | ||
assign(:work, work) | ||
assign(:messages, [WorkActivity.add_work_activity(work.id, "notification!", user.id, | ||
activity_type: WorkActivity::NOTIFICATION)]) | ||
render(partial: partial) | ||
expect(rendered).to include("notification!") | ||
expect(rendered).to include("(@#{user.uid})") | ||
end | ||
|
||
it "shows newest message first, when array is in the same order" do | ||
assign(:work, work) | ||
assign(:messages, [newer, older]) | ||
render(partial: partial) | ||
expect(rendered).to match(/newer.*older/m) | ||
end | ||
|
||
it "still shows newest message first, when array is in the reverse order" do | ||
assign(:work, work) | ||
assign(:messages, [older, newer]) | ||
render(partial: partial) | ||
expect(rendered).to match(/newer.*older/m) | ||
end | ||
end |
68 changes: 68 additions & 0 deletions
68
spec/views/works/work_activity_provenance.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,68 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
describe "Change History, AKA Provenance" do | ||
let(:user) { FactoryBot.create :user } | ||
let(:work) { FactoryBot.create :draft_work } | ||
let(:partial) { "works/work_activity_provenance" } | ||
let(:older) do | ||
WorkActivity.add_work_activity(work.id, "older", user.id, | ||
activity_type: WorkActivity::SYSTEM, created_at: "2021-01-01") | ||
end | ||
let(:newer) do | ||
WorkActivity.add_work_activity(work.id, "newer", user.id, | ||
activity_type: WorkActivity::SYSTEM, created_at: "2022-01-01") | ||
end | ||
|
||
it "handles no activity" do | ||
assign(:changes, []) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to include("No activity") | ||
end | ||
|
||
it "handles metadata changes" do | ||
assign(:changes, [WorkActivity.add_work_activity(work.id, JSON.dump({ a_field: [{ action: "changed", from: "old", to: "new" }] }), user.id, | ||
activity_type: WorkActivity::CHANGES)]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to include("<del>old</del><ins>new</ins>") | ||
end | ||
|
||
it "handles file changes" do | ||
assign(:changes, [WorkActivity.add_work_activity(work.id, "{}", user.id, | ||
activity_type: WorkActivity::FILE_CHANGES)]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to include("Files updated:") | ||
end | ||
|
||
it "handles prov note" do | ||
assign(:changes, [WorkActivity.add_work_activity(work.id, "note!", user.id, | ||
activity_type: WorkActivity::PROVENANCE_NOTES)]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to include("note!") | ||
end | ||
|
||
it "handles error" do | ||
assign(:changes, [WorkActivity.add_work_activity(work.id, "error!", user.id, | ||
activity_type: WorkActivity::DATACITE_ERROR)]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to include("error!") | ||
end | ||
|
||
it "handles backdated prov note" do | ||
assign(:changes, [older]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to include("January 01, 2021 00:00 (backdated event created") | ||
end | ||
|
||
it "shows oldest change first, when array is in the same order" do | ||
assign(:changes, [older, newer]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to match(/older.*newer/m) | ||
end | ||
|
||
it "still shows oldest change first, when array is in the reverse order" do | ||
assign(:changes, [newer, older]) | ||
render(partial: partial, locals: { can_add_provenance_note: false }) | ||
expect(rendered).to match(/older.*newer/m) | ||
end | ||
end |