Skip to content

Commit

Permalink
Rubocop errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinisukale committed Dec 6, 2023
1 parent f2eff19 commit 65c3d60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Indexable
end
end

if (instance_of?(DataciteDoi) || instance_of?(OtherDoi) ||instance_of?(Doi))
if instance_of?(DataciteDoi) || instance_of?(OtherDoi) || instance_of?(Doi)
if aasm_state == "findable"
# If following fields are modified or the state has changed (any other state to findable), send import message
if saved_change_to_attribute?("related_identifiers") || saved_change_to_attribute?("creators") || saved_change_to_attribute?("funding_references") || aasm_state_changed?
Expand Down
30 changes: 15 additions & 15 deletions spec/models/doi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,48 @@
end
end

describe 'after_commit' do
let(:doi) { create(:doi, aasm_state: 'findable') }
context 'when aasm_state is findable' do
describe "after_commit" do
let(:doi) { create(:doi, aasm_state: "findable") }
context "when aasm_state is findable" do
before do
allow(doi).to receive(:saved_change_to_attribute?).and_return(false)
allow(doi).to receive(:aasm_state_changed?).and_return(false)
allow(doi).to receive(:send_import_message)
end

it 'sends import message if related_identifiers is modified' do
doi.related_identifiers = ['new_identifier']
it "sends import message if related_identifiers is modified" do
doi.related_identifiers = ["new_identifier"]
doi.save
expect(doi).to have_received(:send_import_message).with(doi.to_jsonapi)
end

it 'sends import message if creators is modified' do
doi.creators = ['new_creator']
it "sends import message if creators is modified" do
doi.creators = ["new_creator"]
doi.save
expect(doi).to have_received(:send_import_message).with(doi.to_jsonapi)
end

it 'sends import message if funding_references is modified' do
doi.funding_references = ['new_reference']
it "sends import message if funding_references is modified" do
doi.funding_references = ["new_reference"]
doi.save
expect(doi).to have_received(:send_import_message).with(doi.to_jsonapi)
end

it 'sends import message if aasm_state is changed' do
doi.aasm_state = 'another_state'
it "sends import message if aasm_state is changed" do
doi.aasm_state = "another_state"
doi.save
expect(doi).to have_received(:send_import_message).with(doi.to_jsonapi)
end

it 'does not send import message if none of the conditions are met' do
it "does not send import message if none of the conditions are met" do
doi.save
expect(doi).not_to have_received(:send_import_message)
end
end

context 'when aasm_state is not findable' do
it 'does not send import message' do
allow(doi).to receive(:aasm_state).and_return('not_findable')
context "when aasm_state is not findable" do
it "does not send import message" do
allow(doi).to receive(:aasm_state).and_return("not_findable")
doi.save
expect(doi).not_to have_received(:send_import_message)
end
Expand Down

0 comments on commit 65c3d60

Please sign in to comment.