Skip to content

Commit

Permalink
Refactor test (#136)
Browse files Browse the repository at this point in the history
* Fixed lint errors

* Revert "Fixed lint errors"

This reverts commit e7d3c67.

* Added API_URL env in test
  • Loading branch information
ashwinisukale authored Nov 21, 2023
1 parent d6a680c commit 276b7ff
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions spec/models/orcid_affiliation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@
end

describe "#push_item" do
it "push_item with valid data" do
# Mocking a valid item with an ORCID name identifier and ROR affiliation identifier
allow(Maremma).to receive(:post).and_return(OpenStruct.new(status: 201,
body: { "data" => { "id" => "example_id" } }))
before do
allow(ENV).to receive(:[]).with("STAFF_ADMIN_TOKEN").and_return("example_admin_token")
allow(ENV).to receive(:[]).with("ORCID_AFFILIATION_SOURCE_TOKEN").and_return("ORCID_AFFILIATION_SOURCE_TOKEN")
allow(ENV).to receive(:[]).with("LAGOTTINO_URL").and_return("https://fake.lagattino.com")
allow(ENV).to receive(:[]).with("API_URL").and_return("https://fake.api.com")
allow(Rails.logger).to receive(:info)
end

it "push_item with valid data" do
# Mocking a valid item with an ORCID name identifier and ROR affiliation identifier
allow(Maremma).to receive(:post).and_return(OpenStruct.new(status: 201,
body: { "data" => { "id" => "example_id" } }))

item = {
"attributes" => {
Expand Down Expand Up @@ -137,10 +141,6 @@
# Mocking a valid item with an ORCID name identifier and ROR affiliation identifier
allow(Maremma).to receive(:post).and_return(OpenStruct.new(status: 409,
body: { "data" => { "id" => "example_id" } }))
allow(ENV).to receive(:[]).with("STAFF_ADMIN_TOKEN").and_return("example_admin_token")
allow(ENV).to receive(:[]).with("ORCID_AFFILIATION_SOURCE_TOKEN").and_return("ORCID_AFFILIATION_SOURCE_TOKEN")
allow(ENV).to receive(:[]).with("LAGOTTINO_URL").and_return("https://fake.lagattino.com")
allow(Rails.logger).to receive(:info)

item = {
"attributes" => {
Expand Down Expand Up @@ -180,9 +180,6 @@
# Mocking a valid item with an ORCID name identifier and ROR affiliation identifier
allow(Maremma).to receive(:post).and_return(OpenStruct.new(status: 500,
body: { "errors" => "An error occurred during the put request." }))
allow(ENV).to receive(:[]).with("STAFF_ADMIN_TOKEN").and_return("example_admin_token")
allow(ENV).to receive(:[]).with("ORCID_AFFILIATION_SOURCE_TOKEN").and_return("ORCID_AFFILIATION_SOURCE_TOKEN")
allow(ENV).to receive(:[]).with("LAGOTTINO_URL").and_return("https://fake.lagattino.com")
allow(Rails.logger).to receive(:error)

item = {
Expand Down

0 comments on commit 276b7ff

Please sign in to comment.