Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 6, 2020
1 parent e7cb0c5 commit 13839fc
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 43 deletions.
1 change: 1 addition & 0 deletions app/jobs/target_doi_by_id_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def perform(id, options={})
return false if item.blank?

item.set_source_and_target_doi

if item.save
Rails.logger.info "Target doi for #{item.uuid} updated."
else
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ def create_index

self.__elasticsearch__.create_index!(index: index_name) unless self.__elasticsearch__.index_exists?(index: index_name)
self.__elasticsearch__.create_index!(index: alternate_index_name) unless self.__elasticsearch__.index_exists?(index: alternate_index_name)

# index_name is the active index
client = Elasticsearch::Model.client
client.indices.put_alias index: index_name, name: alias_name unless client.indices.exists_alias?(name: alias_name)

"Created indexes #{index_name} (active) and #{alternate_index_name}."
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class Doi < ActiveRecord::Base
has_many :part_of, -> { where target_relation_type_id: "part_of" }, class_name: "Event", primary_key: :doi, foreign_key: :target_doi, dependent: :destroy
has_many :versions, -> { where source_relation_type_id: "versions" }, class_name: "Event", primary_key: :doi, foreign_key: :source_doi, dependent: :destroy
has_many :version_of, -> { where target_relation_type_id: "version_of" }, class_name: "Event", primary_key: :doi, foreign_key: :target_doi, dependent: :destroy

has_many :activities, foreign_key: :auditable_id, dependent: :destroy

delegate :provider, to: :client, allow_nil: true
delegate :consortium_id, to: :provider, allow_nil: true

Expand Down
1 change: 0 additions & 1 deletion app/models/provider.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "countries"

class Provider < ActiveRecord::Base

# include helper module for caching infrequently changing resources
include Cacheable

Expand Down
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
post "/client-api/graphql", to: "graphql#execute"
get "/client-api/graphql", to: "index#method_not_allowed"

root :to => 'index#index'
root to: "index#index"

# authentication
post 'token', :to => 'sessions#create_token'
post "token", to: "sessions#create_token"

# authentication via openid connect in load balancer
post 'oidc-token', :to => 'sessions#create_oidc_token'
post "oidc-token", to: "sessions#create_oidc_token"

# send reset link
post 'reset', :to => 'sessions#reset'
Expand Down
16 changes: 16 additions & 0 deletions spec/jobs/event_registrant_update_by_id_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "rails_helper"

describe EventRegistrantUpdateByIdJob, type: :job do
let(:event) { create(:event) }
subject(:job) { EventRegistrantUpdateByIdJob.perform_later(event.uuid) }

it "queues the job" do
expect { job }.to have_enqueued_job(EventRegistrantUpdateByIdJob)
.on_queue("test_lupo_background")
end

after do
clear_enqueued_jobs
clear_performed_jobs
end
end
16 changes: 0 additions & 16 deletions spec/jobs/event_update_by_id_job.rb

This file was deleted.

16 changes: 16 additions & 0 deletions spec/jobs/index_background_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "rails_helper"

describe IndexBackgroundJob, type: :job do
let(:doi) { create(:doi) }
subject(:job) { IndexBackgroundJob.perform_later(doi) }

it "queues the job" do
expect { job }.to have_enqueued_job(IndexBackgroundJob)
.on_queue("test_lupo_background").at_least(1).times
end

after do
clear_enqueued_jobs
clear_performed_jobs
end
end
6 changes: 3 additions & 3 deletions spec/jobs/index_job_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'rails_helper'
require "rails_helper"

describe IndexJob, type: :job do
let(:doi) { create(:doi) }
subject(:job) { IndexJob.perform_later(doi) }

it 'queues the job' do
it "queues the job" do
expect { job }.to have_enqueued_job(IndexJob)
.on_queue("test_lupo").at_least(1).times
end
Expand All @@ -13,4 +13,4 @@
clear_enqueued_jobs
clear_performed_jobs
end
end
end
16 changes: 16 additions & 0 deletions spec/jobs/target_doi_by_id_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "rails_helper"

describe TargetDoiByIdJob, type: :job do
let(:doi) { create(:doi) }
subject(:job) { TargetDoiByIdJob.perform_later(doi) }

it "queues the job" do
expect { job }.to have_enqueued_job(TargetDoiByIdJob)
.on_queue("test_lupo_background").at_least(1).times
end

after do
clear_enqueued_jobs
clear_performed_jobs
end
end
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'rails_helper'
require "rails_helper"

describe UpdateStateJob, type: :job do
let(:doi) { create(:doi) }
subject(:job) { UpdateStateJob.perform_later(doi.doi) }

it 'queues the job' do
it "queues the job" do
expect { job }.to have_enqueued_job(UpdateStateJob)
.on_queue("test_lupo_background")
end
Expand All @@ -13,4 +13,4 @@
clear_enqueued_jobs
clear_performed_jobs
end
end
end
6 changes: 3 additions & 3 deletions spec/models/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'rails_helper'
require "rails_helper"

describe Client, type: :model do
let(:provider) { create(:provider) }
let(:client) { create(:client, provider: provider) }
let(:provider) { create(:provider) }
let(:client) { create(:client, provider: provider) }

describe "Validations" do
it { should validate_presence_of(:symbol) }
Expand Down
3 changes: 2 additions & 1 deletion spec/models/doi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@
describe "citations", elasticsearch: true do
let(:client) { create(:client) }
let(:doi) { create(:doi, client: client, aasm_state: "findable") }
let!(:citations) { create_list(:event_for_datacite_crossref, 1, subj_id: "https://doi.org/#{doi.doi}", relation_type_id: "is-referenced-by") }
let(:source_doi) { create(:doi, client: client, aasm_state: "findable") }
let!(:citations) { create_list(:event_for_datacite_crossref, 1, subj_id: "https://doi.org/#{doi.doi}", obj_id: "https://doi.org/#{source_doi.doi}", relation_type_id: "is-referenced-by") }

before do
Doi.import
Expand Down
12 changes: 6 additions & 6 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'
require "rails_helper"

describe Event, :type => :model, vcr: true do
describe Event, type: :model, vcr: true do
before(:each) { allow(Time.zone).to receive(:now).and_return(Time.mktime(2015, 4, 8)) }
context "event" do
subject { create(:event) }
Expand All @@ -16,15 +16,15 @@

context "citation" do
subject { create(:event_for_datacite_related) }

it "has citation_id" do
expect(subject.citation_id).to eq("https://doi.org/10.5061/dryad.47sd5/1-https://doi.org/10.5061/dryad.47sd5e/1")
end

it "has citation_year" do
expect(subject.citation_year).to eq(2015)
end

it "has published_dates" do
expect(subject.subj["datePublished"]).to eq("2006-06-13T16:14:19Z")
expect(subject.obj["datePublished"]).to be_nil
Expand All @@ -33,7 +33,7 @@
let(:doi) { create(:doi) }

it "date_published from the database" do
published = subject.date_published("https://doi.org/"+doi.doi)
published = subject.date_published("https://doi.org/" + doi.doi)
expect(published).to eq("2011")
expect(published).not_to eq(2011)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rails_helper'
require "rails_helper"

describe "dois", type: :request do
let(:admin) { create(:provider, symbol: "ADMIN") }
Expand All @@ -14,7 +14,7 @@
let(:bearer) { Client.generate_token(role_id: "client_admin", uid: client.symbol, provider_id: provider.symbol.downcase, client_id: client.symbol.downcase, password: client.password) }
let(:headers) { { 'HTTP_ACCEPT'=>'application/vnd.api+json', 'HTTP_AUTHORIZATION' => 'Bearer ' + bearer }}

describe 'GET /dois', elasticsearch: true do
describe "GET /dois", elasticsearch: true do
let!(:dois) { create_list(:doi, 3, client: client, aasm_state: "findable") }

before do
Expand All @@ -23,7 +23,7 @@
end

it 'returns dois', vcr: true do
get '/dois', nil, headers
get "/dois", nil, headers

expect(last_response.status).to eq(200)
expect(json['data'].size).to eq(3)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/elasticsearch_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## https://github.com/elastic/elasticsearch-ruby/issues/462
SEARCHABLE_MODELS = [Client, Provider, Doi, Event]
SEARCHABLE_MODELS = [Client, Provider, Doi, Event, Activity]

RSpec.configure do |config|
config.around :all, elasticsearch: true do |example|
Expand Down

0 comments on commit 13839fc

Please sign in to comment.