diff --git a/app/models/event.rb b/app/models/event.rb index 7d937bb07..3c586ca32 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -578,8 +578,8 @@ def citation_year def date_published(doi) ## TODO: we need to make sure all the dois from other RA are indexed - doi = Doi.where(doi: doi).first - doi[:published] if doi.present? + item = Doi.where(doi: doi_from_url(doi)).first + item[:publication_year] if item.present? end def set_defaults diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index a3476da0e..c82c3e5f3 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -29,5 +29,12 @@ expect(subject.subj["datePublished"]).to eq("2006-06-13T16:14:19Z") expect(subject.obj["datePublished"]).to be_nil end + + let(:doi) { create(:doi) } + + it "date_published from the database" do + published = subject.date_published("https://doi.org/"+doi.doi) + expect(published).to eq(2011) + end end end diff --git a/spec/requests/events_spec.rb b/spec/requests/events_spec.rb index a903f0f82..b1ef4d084 100644 --- a/spec/requests/events_spec.rb +++ b/spec/requests/events_spec.rb @@ -595,7 +595,6 @@ # # let!(:event) { create(:event) } # # let(:uri) { "/events" } - # TODO: need further setup context "check meta unique" do let!(:event) { create_list(:event_for_datacite_related, 5) } let(:uri) { "/events?aggregations=metrics_aggregations" }