diff --git a/app/models/client.rb b/app/models/client.rb index 856781b5d..d5d1ac0f0 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -80,6 +80,7 @@ class Client < ApplicationRecord message: "Client type %s is not included in the list" validates_associated :provider validate :check_id, on: :create + validate :check_prefix, on: :create validate :freeze_symbol, on: :update validate :check_issn, if: :issn? validate :check_certificate, if: :certificate? @@ -97,6 +98,7 @@ class Client < ApplicationRecord before_validation :set_defaults before_create { self.created = Time.zone.now.utc.iso8601 } before_save { self.updated = Time.zone.now.utc.iso8601 } + after_create :assign_prefix after_create_commit :create_reference_repository after_update_commit :update_reference_repository after_destroy_commit :destroy_reference_repository @@ -915,6 +917,47 @@ def check_id end end + def get_prefix + provider_prefix = (provider.present? && provider.provider_prefixes.present?) ? provider.provider_prefixes.select { |_provider_prefix| (_provider_prefix.state == "without-repository") }.first : nil + prefix = Prefix.all.count > 0 ? Prefix.all.select { |_prefix| (_prefix.state == "unassigned") }.first : nil + + provider_prefix || prefix || nil + end + + def check_prefix + if !get_prefix + errors.add( + :base, + "No prefixes available. Unable to create repository.", + ) + end + end + + def assign_prefix + available_prefix = get_prefix + if !available_prefix + errors.add( + :base, + "No prefixes available. Created repository, but a prefix was not assigned. Contact support to get a prefix.", + ) + else + prefix, provider_prefix = nil + available_prefix.class.name == "Prefix" ? prefix = available_prefix : provider_prefix = available_prefix + + if !provider_prefix.present? + provider_prefix = ProviderPrefix.create( + provider_id: provider.symbol, prefix_id: prefix.uid + ) + end + + ClientPrefix.create( + client_id: symbol, + provider_prefix_id: provider_prefix.uid, + prefix_id: provider_prefix.prefix.uid, + ) + end + end + def user_url ENV["VOLPINO_URL"] + "/users?client-id=" + symbol.downcase end diff --git a/db/seeds/development/base.seeds.rb b/db/seeds/development/base.seeds.rb index b50cc1fd5..4a32778aa 100644 --- a/db/seeds/development/base.seeds.rb +++ b/db/seeds/development/base.seeds.rb @@ -12,9 +12,15 @@ if Provider.where(symbol: "ADMIN").blank? FactoryBot.create(:provider, symbol: "ADMIN") end +# Need available prefixes for repository creation. +if Prefix.where(uid: "10.14454").blank? + FactoryBot.create(:prefix, uid: "10.14454") +end provider = Provider.where(symbol: "DATACITE").first || FactoryBot.create(:provider, symbol: "DATACITE") +# No need anymore to call FactoryBot.create to establish provider/client prefix relationships. +# That is done in client creation. client = Client.where(symbol: "DATACITE.TEST").first || FactoryBot.create( @@ -23,14 +29,6 @@ symbol: ENV["MDS_USERNAME"], password_input: ENV["MDS_PASSWORD"], ) -if Prefix.where(uid: "10.14454").blank? - prefix = FactoryBot.create(:prefix, uid: "10.14454") - ### This creates both the client_prefix and the pprovider association - FactoryBot.create( - :client_prefix, - client_id: client.symbol, prefix_id: prefix.uid, - ) -end dois = FactoryBot.create_list(:doi, 10, client: client, state: "findable") FactoryBot.create_list(:event_for_datacite_related, 3, obj_id: dois.first.doi) FactoryBot.create_list(:event_for_datacite_usage, 2, obj_id: dois.first.doi) diff --git a/spec/concerns/authenticable_spec.rb b/spec/concerns/authenticable_spec.rb index ffd12f232..25a193cbe 100644 --- a/spec/concerns/authenticable_spec.rb +++ b/spec/concerns/authenticable_spec.rb @@ -177,10 +177,11 @@ end context "draft doi" do - let(:consortium) do + let!(:consortium) do create(:provider, symbol: "DC", role_name: "ROLE_CONSORTIUM") end - let(:provider) do + + let!(:provider) do create( :provider, symbol: "DATACITE", @@ -188,10 +189,23 @@ role_name: "ROLE_CONSORTIUM_ORGANIZATION", ) end - let(:client) do + let!(:client) do create(:client, provider: provider, symbol: "DATACITE.RPH") end - let(:doi) { create(:doi, client: client) } + let!(:prefix) { create(:prefix, uid: "10.14454") } + let!(:provider_prefix) do + create(:provider_prefix, provider: provider, prefix: prefix) + end + let!(:client_prefix) do + create( + :client_prefix, + client: client, + prefix: prefix, + provider_prefix: provider_prefix + ) + end + + let!(:doi) { create(:doi, client: client) } it "staff_admin" do token = User.generate_token(role_id: "staff_admin") diff --git a/spec/concerns/helpable_spec.rb b/spec/concerns/helpable_spec.rb index b77554491..13d050744 100644 --- a/spec/concerns/helpable_spec.rb +++ b/spec/concerns/helpable_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -describe Doi, vcr: true do +describe Doi, vcr: true, elasticsearch: true do subject { create(:doi) } context "generate_random_provider_symbol" do @@ -286,8 +286,7 @@ create( :client, provider: provider, - symbol: ENV["MDS_USERNAME"], - password: ENV["MDS_PASSWORD"], + password_input: ENV["MDS_PASSWORD"] ) end diff --git a/spec/concerns/indexable_spec.rb b/spec/concerns/indexable_spec.rb index 165c838d7..56960c6b6 100644 --- a/spec/concerns/indexable_spec.rb +++ b/spec/concerns/indexable_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -describe "Indexable", vcr: true do +describe "Indexable", vcr: true, elasticsearch: true do subject { create(:doi) } xit "send_message" do diff --git a/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/_id/when_the_record_does_not_exist/returns_status_code_404.yml b/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/_id/when_the_record_does_not_exist/returns_status_code_404.yml new file mode 100644 index 000000000..74f493fcd --- /dev/null +++ b/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/_id/when_the_record_does_not_exist/returns_status_code_404.yml @@ -0,0 +1,61 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.datacite.org/re3data/10.17616/r3xs37 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Sep 2022 06:23:27 GMT + Content-Type: + - application/json; charset=utf-8 + Connection: + - keep-alive + Status: + - 200 OK + Cache-Control: + - max-age=0, private, must-revalidate + Vary: + - Origin + Referrer-Policy: + - strict-origin-when-cross-origin + X-Permitted-Cross-Domain-Policies: + - none + X-Xss-Protection: + - 1; mode=block + X-Request-Id: + - 750e578f-29fc-4470-a2f6-eded06ff74b9 + X-Download-Options: + - noopen + Etag: + - W/"4779b1c8cb81d39142cef21ab1d60307" + X-Frame-Options: + - SAMEORIGIN + X-Runtime: + - '0.195219' + X-Content-Type-Options: + - nosniff + X-Powered-By: + - Phusion Passenger(R) 6.0.14 + Server: + - nginx/1.18.0 + Phusion Passenger(R) 6.0.14 + body: + encoding: ASCII-8BIT + string: !binary |- + eyJkYXRhIjp7ImlkIjoiMTAuMTc2MTYvUjNYUzM3IiwidHlwZSI6InJlM2RhdGEiLCJhdHRyaWJ1dGVzIjp7InJlM2RhdGFJZCI6InIzZDEwMDAxMDEzNCIsInJlcG9zaXRvcnlOYW1lIjoiUEFOR0FFQSIsInJlcG9zaXRvcnlVcmwiOiJodHRwczovL3d3dy5wYW5nYWVhLmRlLyIsInJlcG9zaXRvcnlDb250YWN0cyI6W3sidGV4dCI6Imh0dHBzOi8vd3d3LnBhbmdhZWEuZGUvY29udGFjdC8ifSx7InRleHQiOiJpbmZvQHBhbmdhZWEuZGUifV0sImRlc2NyaXB0aW9uIjoiUEFOR0FFQSAtIERhdGEgUHVibGlzaGVyIGZvciBFYXJ0aCBcdTAwMjYgRW52aXJvbm1lbnRhbCBTY2llbmNlcyBoYXMgYW4gYWxtb3N0IDMwLXllYXIgaGlzdG9yeSBhcyBhbiBvcGVuLWFjY2VzcyBsaWJyYXJ5IGZvciBhcmNoaXZpbmcsIHB1Ymxpc2hpbmcsIGFuZCBkaXNzZW1pbmF0aW5nIGdlb3JlZmVyZW5jZWQgZGF0YSBmcm9tIHRoZSBFYXJ0aCwgZW52aXJvbm1lbnRhbCwgYW5kIGJpb2RpdmVyc2l0eSBzY2llbmNlcy4gT3JpZ2luYWxseSBldm9sdmluZyBmcm9tIGEgZGF0YWJhc2UgZm9yIHNlZGltZW50IGNvcmVzLCBpdCBpcyBvcGVyYXRlZCBhcyBhIGpvaW50IGZhY2lsaXR5IG9mIHRoZSBBbGZyZWQgV2VnZW5lciBJbnN0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iwgWmVudHJ1bSBmw7xyIE1hcmluZSBVbXdlbHR3aXNzZW5zY2hhZnRlbiIsImxhbmd1YWdlIjoiZGV1In0seyJ0ZXh0IjoiTUFSVU0iLCJsYW5ndWFnZSI6ImRldSJ9XSwicmVzcG9uc2liaWxpdHlUeXBlcyI6W3sidGV4dCI6ImdlbmVyYWwifV0sImlkZW50aWZpZXJzIjpbeyJ0ZXh0IjoiUk9SOjAyZ24xYXI1MyJ9XSwiY29udGFjdHMiOlt7InRleHQiOiJodHRwczovL3d3dy5tYXJ1bS5kZS9lbi9Qcm9mLi1Eci4tZnJhbmstb2xpdmVyLWdsb2Vja25lci5odG1sIn1dfV0sImRhdGFBY2Nlc3NlcyI6W3sidHlwZSI6Im9wZW4iLCJyZXN0cmljdGlvbnMiOltdfV0sImRhdGFVcGxvYWRzIjpbeyJ0eXBlIjoicmVzdHJpY3RlZCIsInJlc3RyaWN0aW9ucyI6W3sidGV4dCI6InJlZ2lzdHJhdGlvbiJ9XX1dLCJkYXRhVXBsb2FkTGljZW5zZXMiOlt7Im5hbWUiOiJEYXRhIFN1Ym1pc3Npb24iLCJ1cmwiOiJodHRwczovL3d3dy5wYW5nYWVhLmRlL3N1Ym1pdC8ifV0sInBpZFN5c3RlbXMiOlt7InRleHQiOiJET0kifV0sImFwaXMiOlt7InVybCI6Imh0dHBzOi8vd3MucGFuZ2FlYS5kZS9vYWkvcHJvdmlkZXIiLCJ0eXBlIjoiT0FJLVBNSCJ9XSwic29mdHdhcmUiOlt7Im5hbWUiOiJvdGhlciJ9XSwic3RhcnREYXRlIjoiMTk5NCIsImVuZERhdGUiOm51bGwsImNyZWF0ZWQiOiIyMDEyLTA3LTE2VDA5OjM5OjE1WiIsInVwZGF0ZWQiOiIyMDIyLTA0LTA0VDA4OjQ4OjMzWiJ9fX0= + http_version: null + recorded_at: Tue, 13 Sep 2022 06:23:27 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/get-dois/returns_all_dois.yml b/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/get-dois/returns_all_dois.yml index abc214536..77b7a6b27 100644 --- a/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/get-dois/returns_all_dois.yml +++ b/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/get-dois/returns_all_dois.yml @@ -62,4 +62,4 @@ http_interactions: string: '{"responseCode":1,"prefix":"10.5438","totalCount":"449","page":0,"pageSize":1000,"handles":["10.5438/0000-00SS","10.5438/0000-01HC","10.5438/0000-03VC","10.5438/0001","10.5438/0002","10.5438/0003","10.5438/0004","10.5438/0005","10.5438/0006","10.5438/0007","10.5438/0007-NW90","10.5438/0010","10.5438/0012","10.5438/022J-CC0M","10.5438/02BH-TGC7","10.5438/045S-EC11","10.5438/08A0-3F64","10.5438/08H0-8MQY","10.5438/09C3-4V7S","10.5438/0DPB-24DR","10.5438/0DW9-MPAF","10.5438/0JGW-B795","10.5438/0MAE-2Y7~","10.5438/0Q0J-AJHF","10.5438/0QCA-V2AP","10.5438/0QS4-A3G0","10.5438/0S9T-VT1H","10.5438/0TK6-KN9=","10.5438/0V73-FK2C","10.5438/0X88-GVGE","10.5438/0XJG-XW5Q","10.5438/13J9-6GQ3","10.5438/15X1-BJ6R","10.5438/18MQ-RPGG","10.5438/1A5Y-7XSB","10.5438/1E3Q-74PQ","10.5438/1FDB-E490","10.5438/1H7N-3CEN","10.5438/1HV8-2GC2","10.5438/1J97-YVHJ","10.5438/1K45-K844","10.5438/1M14-41XZ","10.5438/1M69-A1ZK","10.5438/1MAM-DVC~","10.5438/1NX6-PQ88","10.5438/1PNA-0ZKH","10.5438/1S5T-M2D1","10.5438/1W0P-W0BC","10.5438/1XX7-7765","10.5438/1YAA-K6D1","10.5438/20G9-6WB1","10.5438/2516-KNTQ","10.5438/2629-X1J6","10.5438/26HT-FE7P","10.5438/28A6-4QV*","10.5438/28E3-DP9C","10.5438/2B73-V3YB","10.5438/2B8J-TDXH","10.5438/2G4X-Q6S9","10.5438/2R6Y-9G5Q","10.5438/2WFX-2HZ1","10.5438/2WPE-THS0","10.5438/31V8-C457","10.5438/350C-QNPD","10.5438/3604-7V9$","10.5438/36H3-CQV*","10.5438/36RH-W023","10.5438/382F-TKFV","10.5438/3CN7-V545","10.5438/3DFW-Z4KQ","10.5438/3E7A-6HK7","10.5438/3FYV-2G0V","10.5438/3J8D-X85J","10.5438/3JKB-2QP9","10.5438/3JMF-VP13","10.5438/3MTR-WGS9","10.5438/3Q29-9NWT","10.5438/3TYG-2KW7","10.5438/3X51-RC2B","10.5438/3X7Y-HBP2","10.5438/3YQ5-6N53","10.5438/408J-EAJ4","10.5438/44JK-BESG","10.5438/44VH-95FY","10.5438/455Y-9TR8","10.5438/462Q-X856","10.5438/4BY7-B7ZN","10.5438/4DCW-96B*","10.5438/4HR0-D640","10.5438/4K0Q-PB5A","10.5438/4K3M-NYVG","10.5438/4N30-NJPN","10.5438/4QX3-RP8Y","10.5438/4T5V-0PT8","10.5438/53NZ-N4G7","10.5438/54CN-P40V","10.5438/55E5-T5C0","10.5438/5653-THGW","10.5438/57SK-XD8G","10.5438/59G5-93T4","10.5438/59R2-VEEV","10.5438/5AEG-WEEV","10.5438/5B5R-B9DE","10.5438/5E2Q-NJ95","10.5438/5HZJ-5KDS","10.5438/5K96-CDVP","10.5438/5N3Y-GTDY","10.5438/5PS5-G3V~","10.5438/5SJZ-JT21","10.5438/5SQZ-H72E","10.5438/5TJ1-Z20*","10.5438/5YCZ-R519","10.5438/63PZ-PG99","10.5438/67C9-ZAZB","10.5438/68F9-B337","10.5438/6BRG-2M37","10.5438/6BRW-VEMG","10.5438/6DDP-WW08","10.5438/6GEP-3S5E","10.5438/6GG8-SDG9","10.5438/6T44-7BDJ","10.5438/6WCF-EFW5","10.5438/6XDQ-4DT0","10.5438/75RM-4VE2","10.5438/76M6-STNZ","10.5438/7705-12GY","10.5438/7780-8F8P","10.5438/78P9-FNRN","10.5438/78ZD-REDY","10.5438/7D9J-P0FP","10.5438/7MDQ-CFQJ","10.5438/7MRF-MPDK","10.5438/7RXD-S8A3","10.5438/7SSY-QVBV","10.5438/81P5-2D8H","10.5438/85SN-MX23","10.5438/85Y8-8J2Z","10.5438/879W-C2W7","10.5438/87E5-GKYY","10.5438/8AY6-WA82","10.5438/8E5N-E3Q5","10.5438/8EFW-N085","10.5438/8H16-WPEK","10.5438/8JBJ-M82P","10.5438/8QKH-1R6~","10.5438/8S99-7AWR","10.5438/8SZS-1H0H","10.5438/8TWW-0XC8","10.5438/8W5K-8W4K","10.5438/8YMV-8436","10.5438/9171-4B4F","10.5438/95DP-Q6FX","10.5438/99TJ-JZSN","10.5438/9FE4-8FNT","10.5438/9JWD-TN3A","10.5438/9QSK-2MPH","10.5438/9SNZ-VV1Y","10.5438/9Z99-A1RC","10.5438/9ZAT-8K6K","10.5438/A997-PAB1","10.5438/AB8Z-2599","10.5438/AKXG-KCQ*","10.5438/AN60-YNTY","10.5438/ANGM-ARS8","10.5438/AW9V-A6YS","10.5438/AZ3Q-C1VF","10.5438/B77P-W36R","10.5438/BAKK-ZHJN","10.5438/BBGG-0ZKW","10.5438/BC11-CQW1","10.5438/BC11-CQW6","10.5438/BC11-CQW8","10.5438/BCHH11-DDDDDD","10.5438/BDMN-SCW8","10.5438/BG66-DJN~","10.5438/BJ3H-4S1P","10.5438/BJ5V-MW65","10.5438/BMMQ-YCE9","10.5438/BNC7-JAYB","10.5438/BND2-A57V","10.5438/BNY0-AF15","10.5438/BPZZ-EAY0","10.5438/BRAINLIFE.007","10.5438/BZ8M-MBK5","10.5438/C1ZY-STZQ","10.5438/C3BY-VYZS","10.5438/C61Q-Z2K7","10.5438/C7VR-43SC","10.5438/C81T-HKVP","10.5438/CAB5-TEG0","10.5438/CAPM-3JK5","10.5438/CBS9-YE5~","10.5438/CEVP-HAVW","10.5438/CJT2-T6DZ","10.5438/CMHK-ZH44","10.5438/CRKW-AJ5D","10.5438/CT6S-F4X*","10.5438/D31R-P039","10.5438/D3FQ-BXPA","10.5438/D54Q-GW6Q","10.5438/D6PT-J5Y7","10.5438/D8E2-50Q~","10.5438/D9EQ-9DGA","10.5438/DE51-9GCW","10.5438/DJ3W-83H5","10.5438/DJ5K-XDB0","10.5438/DPJ1-Q3AZ","10.5438/DQCR-N40N","10.5438/E13Q-YPED","10.5438/E2J1-DK5A","10.5438/E5SQ-R8G1","10.5438/E66Y-3X8V","10.5438/EA4H-TX3G","10.5438/EAZK-SSE~","10.5438/ECC1-WA5S","10.5438/ECV0-QFAK","10.5438/ED4H-Y9Q0","10.5438/EJDA-7GW1","10.5438/EKBF-T33Y","10.5438/ESYS-F867","10.5438/ETEB-HG2~","10.5438/EWSV-1821","10.5438/EXAMPLE-FULL","10.5438/F17B-45VZ","10.5438/F1P0-3FK5","10.5438/F2KV-2YK3","10.5438/F36E-H22F","10.5438/FBJ5-3DWP","10.5438/FD06-ABAW","10.5438/FERW-CWHQ","10.5438/FJ3W-0SHD","10.5438/FRC3-XR1E","10.5438/G063-GKT~","10.5438/G39T-WYP1","10.5438/G3ZB-M1GS","10.5438/G59A-FBT2","10.5438/G5QG-A8SA","10.5438/G9G5-CKR7","10.5438/G9QG-M5NJ","10.5438/G9Z6-J964","10.5438/GA8V-FA94","10.5438/GFD7-6QA1","10.5438/GK1Q-HKKR","10.5438/GN8X-06M0","10.5438/GS93-BY4R","10.5438/GWSC-DADG","10.5438/GY4A-STW*","10.5438/GY9W-92W=","10.5438/GYE3-PP2A","10.5438/H0PX-5YTV","10.5438/H0WW-75T7","10.5438/H1JN-QT8$","10.5438/H40K-S4K*","10.5438/H4TY-HS9F","10.5438/H5XP-X178","10.5438/H8DR-4TTX","10.5438/HCE6-GCRP","10.5438/HFEA-PRR5","10.5438/HGHT-610$","10.5438/HGMF-XE8X","10.5438/HHE9-1G5=","10.5438/HN7K-SV5Z","10.5438/HQ54-9A6C","10.5438/J5FD-TF79","10.5438/J7K4-98WC","10.5438/J8BC-4SJW","10.5438/J8C8-C0M0","10.5438/JA0T-9W07","10.5438/JEGK-2DF0","10.5438/JG8P-DVZX","10.5438/JHTN-6890","10.5438/JKW6-K78G","10.5438/JM9F-325F","10.5438/JMED-JCAM","10.5438/JPHX-V7A0","10.5438/JQ7T-HXH8","10.5438/JWX3-KWZ4","10.5438/JZG5-VCQV","10.5438/K3W2-59D0","10.5438/KBG2-ZS5Y","10.5438/KBRV-TZAG","10.5438/KHYZ-6Z8$","10.5438/KTR7-ZJJH","10.5438/KVP3-XY0A","10.5438/KY61-VNBM","10.5438/M5K4-AMKR","10.5438/M68V-4GK6","10.5438/M8TS-BD9~","10.5438/MBW1-0GT1","10.5438/MCMF-B7EH","10.5438/MCNV-GA6N","10.5438/MDS-CLIENT-RUBY-TEST","10.5438/MK56-9XM4","10.5438/MK65-3M12","10.5438/MRR6-MF3Q","10.5438/MSK0-15R2","10.5438/MW0P-H8HQ","10.5438/N39S-B1K9","10.5438/NBXT-KY11","10.5438/NDHK-V0BX","10.5438/NDRJ-BX5K","10.5438/NG46-GVT2","10.5438/NHT3-8M8F","10.5438/NMVM-6WC6","10.5438/NNWW-3NX$","10.5438/NQCF-E0EM","10.5438/NSF1-NVKY","10.5438/NTEN-WEYS","10.5438/NZ7N-4YHF","10.5438/NZEX-EY30","10.5438/P1X8-NPY$","10.5438/P3BH-TBB~","10.5438/P59X-916F","10.5438/PE54-ZJ5T","10.5438/PQXM-76GQ","10.5438/PRF0-NRXQ","10.5438/PRXJ-7PZ6","10.5438/PVBB-BTPB","10.5438/Q019-6VE4","10.5438/Q10P-C66K","10.5438/Q2GH-6EGD","10.5438/Q36Q-82CN","10.5438/Q699-SSGR","10.5438/Q8N8-XRQZ","10.5438/QCFT-GV12","10.5438/QDMX-ECG0","10.5438/QGQ5-PGE7","10.5438/QTHF-2NGC","10.5438/QV34-E1WS","10.5438/QVW6-10XP","10.5438/QW2X-PGCY","10.5438/QYJP-1GFT","10.5438/R2ZV-P5WP","10.5438/R33F-96GH","10.5438/R438-S70*","10.5438/R4RA-8DD~","10.5438/R5AV-PTNH","10.5438/R8XY-8XK=","10.5438/R9M1-77T$","10.5438/RC4N-42YJ","10.5438/RCTN-QJCB","10.5438/RCZV-HJNS","10.5438/RDEE-P7JW","10.5438/RFJ3-C3SM","10.5438/RMT6-W97W","10.5438/RN1Z-DWRB","10.5438/RNNR-X2H~","10.5438/RPZ2-WBY6","10.5438/RQ5Q-PPEP","10.5438/RQY9-0M3B","10.5438/RTQF-7S4J","10.5438/RWAD-EB1A","10.5438/RX2V-V5WT","10.5438/RZQM-SYE2","10.5438/S20C-STGX","10.5438/S2YG-RY5K","10.5438/S7KD-S2C7","10.5438/S8GF-0CK9","10.5438/S9ZJ-ARXG","10.5438/SBTT-S36E","10.5438/SC37-K1J5","10.5438/SD03-1XBE","10.5438/SD2R-YCG9","10.5438/SDQ2-7G1Y","10.5438/SHCG-EA1F","10.5438/SHR4-2BS2","10.5438/SS2R-9CNS","10.5438/SSAF-KFTT","10.5438/SSK4-YEJ9","10.5438/SWBY-VWG~","10.5438/SYW5-VQA5","10.5438/T0AP-D5W7","10.5438/T3NT-4627","10.5438/T4JB-B450","10.5438/T964-M8SM","10.5438/TEPP-YTY6","10.5438/THY1-TC09","10.5438/TK9X-RNY9","10.5438/TNHX-54CG","10.5438/TQ4C-6C0Q","10.5438/TSJR-F9CH","10.5438/TT7V-JP55","10.5438/TW5H-21DH","10.5438/TXD3-C9ZP","10.5438/V0VG-8JJK","10.5438/V1W9-VF4H","10.5438/V2XJ-NFAP","10.5438/V683-K48X","10.5438/VAKZ-08VB","10.5438/VCC2-T9SJ","10.5438/VFJ4-8DQ$","10.5438/VHQF-PWJQ","10.5438/VKG9-X9BZ","10.5438/VQ2T-VR4K","10.5438/VQ3X-QDWT","10.5438/VTBT-NTJ8","10.5438/VZX2-KFRD","10.5438/W029-Y6W~","10.5438/W354-4XQB","10.5438/W4N7-01AT","10.5438/W8QF-4HMG","10.5438/W9H1-WE44","10.5438/WD63-6X8~","10.5438/WDYW-1K1R","10.5438/WMAS-KM0V","10.5438/WQCK-V16M","10.5438/WQX6-2DSQ","10.5438/WTJH-QHX1","10.5438/X0BB-6959","10.5438/X4JQ-EGT5","10.5438/X6WA-82RZ","10.5438/X9EG-VF27","10.5438/XCBJ-G7ZY","10.5438/XCVB-T9EW","10.5438/XDPK-WM3E","10.5438/XF8R-7VZT","10.5438/XGHB-6E1H","10.5438/XQ3J-1CMK","10.5438/XXAJ-N6H9","10.5438/XY47-C7JF","10.5438/XZH2-HG04","10.5438/Y0HC-S62S","10.5438/Y131-YX9D","10.5438/Y4KS-KSBC","10.5438/Y543-2QJX","10.5438/Y5SF-0K1T","10.5438/Y72S-E9JW","10.5438/Y81Q-R21F","10.5438/Y919-5QN4","10.5438/YAA9-F80*","10.5438/YDFF-0DNH","10.5438/YEG5-6R6Z","10.5438/YHCJ-P5HR","10.5438/YX93-ZP3M","10.5438/YYM6-6WVT","10.5438/Z2DD-TKPN","10.5438/Z2GZ-V9MF","10.5438/ZAVG-XM4R","10.5438/ZDTR-AQTT","10.5438/ZE09-RCBA","10.5438/ZF4S-5M37","10.5438/ZFPH-3MXQ","10.5438/ZH1T-Z72K","10.5438/ZMC1-V825","10.5438/ZQGA-EWE7","10.5438/ZR9Y-K3Z5","10.5438/ZSKC-6BC1","10.5438/ZWSF-4Y7Y","10.5438/ZYJN-KXX9"]}' http_version: null recorded_at: Fri, 23 Oct 2020 21:10:13 GMT -recorded_with: VCR 5.1.0 +recorded_with: VCR 5.1.0 \ No newline at end of file diff --git a/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/random_prefix/returns_random_doi_with_prefix.yml b/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/random_prefix/returns_random_doi_with_prefix.yml new file mode 100644 index 000000000..63520803a --- /dev/null +++ b/spec/fixtures/vcr_cassettes/DataciteDoisController/GET_/dois/random_prefix/returns_random_doi_with_prefix.yml @@ -0,0 +1,61 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.datacite.org/re3data/10.17616/r3xs37 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Sep 2022 06:18:25 GMT + Content-Type: + - application/json; charset=utf-8 + Connection: + - keep-alive + Status: + - 200 OK + Cache-Control: + - max-age=0, private, must-revalidate + Vary: + - Origin + Referrer-Policy: + - strict-origin-when-cross-origin + X-Permitted-Cross-Domain-Policies: + - none + X-Xss-Protection: + - 1; mode=block + X-Request-Id: + - 7dd170cd-a4c8-48a3-95bb-a08b389408d6 + X-Download-Options: + - noopen + Etag: + - W/"4779b1c8cb81d39142cef21ab1d60307" + X-Frame-Options: + - SAMEORIGIN + X-Runtime: + - '0.209326' + X-Content-Type-Options: + - nosniff + X-Powered-By: + - Phusion Passenger(R) 6.0.14 + Server: + - nginx/1.18.0 + Phusion Passenger(R) 6.0.14 + body: + encoding: ASCII-8BIT + string: !binary |- + eyJkYXRhIjp7ImlkIjoiMTAuMTc2MTYvUjNYUzM3IiwidHlwZSI6InJlM2RhdGEiLCJhdHRyaWJ1dGVzIjp7InJlM2RhdGFJZCI6InIzZDEwMDAxMDEzNCIsInJlcG9zaXRvcnlOYW1lIjoiUEFOR0FFQSIsInJlcG9zaXRvcnlVcmwiOiJodHRwczovL3d3dy5wYW5nYWVhLmRlLyIsInJlcG9zaXRvcnlDb250YWN0cyI6W3sidGV4dCI6Imh0dHBzOi8vd3d3LnBhbmdhZWEuZGUvY29udGFjdC8ifSx7InRleHQiOiJpbmZvQHBhbmdhZWEuZGUifV0sImRlc2NyaXB0aW9uIjoiUEFOR0FFQSAtIERhdGEgUHVibGlzaGVyIGZvciBFYXJ0aCBcdTAwMjYgRW52aXJvbm1lbnRhbCBTY2llbmNlcyBoYXMgYW4gYWxtb3N0IDMwL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ifV0sImFwaXMiOlt7InVybCI6Imh0dHBzOi8vd3MucGFuZ2FlYS5kZS9vYWkvcHJvdmlkZXIiLCJ0eXBlIjoiT0FJLVBNSCJ9XSwic29mdHdhcmUiOlt7Im5hbWUiOiJvdGhlciJ9XSwic3RhcnREYXRlIjoiMTk5NCIsImVuZERhdGUiOm51bGwsImNyZWF0ZWQiOiIyMDEyLTA3LTE2VDA5OjM5OjE1WiIsInVwZGF0ZWQiOiIyMDIyLTA0LTA0VDA4OjQ4OjMzWiJ9fX0= + http_version: null + recorded_at: Tue, 13 Sep 2022 06:18:25 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/DataciteDoisController/PATCH_/dois/_id/when_the_record_doesn_t_exist_no_creators_publish/returns_error.yml b/spec/fixtures/vcr_cassettes/DataciteDoisController/PATCH_/dois/_id/when_the_record_doesn_t_exist_no_creators_publish/returns_error.yml new file mode 100644 index 000000000..15d3205f9 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/DataciteDoisController/PATCH_/dois/_id/when_the_record_doesn_t_exist_no_creators_publish/returns_error.yml @@ -0,0 +1,61 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.datacite.org/re3data/10.17616/r3xs37 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Sep 2022 06:28:32 GMT + Content-Type: + - application/json; charset=utf-8 + Connection: + - keep-alive + Status: + - 200 OK + Cache-Control: + - max-age=0, private, must-revalidate + Vary: + - Origin + Referrer-Policy: + - strict-origin-when-cross-origin + X-Permitted-Cross-Domain-Policies: + - none + X-Xss-Protection: + - 1; mode=block + X-Request-Id: + - cc5eb2fa-57dc-4d92-a0ad-3d3a15a18b22 + X-Download-Options: + - noopen + Etag: + - W/"4779b1c8cb81d39142cef21ab1d60307" + X-Frame-Options: + - SAMEORIGIN + X-Runtime: + - '0.230303' + X-Content-Type-Options: + - nosniff + X-Powered-By: + - Phusion Passenger(R) 6.0.14 + Server: + - nginx/1.18.0 + Phusion Passenger(R) 6.0.14 + body: + encoding: ASCII-8BIT + string: !binary |- + eyJkYXRhIjp7ImlkIjoiMTAuMTc2MTYvUjNYUzM3IiwidHlwZSI6InJlM2RhdGEiLCJhdHRyaWJ1dGVzIjp7InJlM2RhdGFJZCI6InIzZDEwMDAxMDEzNCIsInJlcG9zaXRvcnlOYW1lIjoiUEFOR0FFQSIsInJlcG9zaXRvcnlVcmwiOiJodHRwczovL3d3dy5wYW5nYWVhLmRlLyIsInJlcG9zaXRvcnlDb250YWN0cyI6W3sidGV4dCI6Imh0dHBzOi8vd3d3LnBhbmdhZWEuZGUvY29udGFjdC8ifSx7InRleHQiOiJpbmZvQHBhbmdhZWEuZGUifV0sImRlc2NyaXB0aW9uIjoiUEFOR0FFQSAtIERhdGEgUHVibGlzaGVyIGZvciBFYXJ0aCBcdTAwMjYgRW52aXJvbm1lbnRhbCBTY2llbmNlcyBoYXMgYW4gYWxtb3N0IDMwLXllYXIgaGlzdG9yeSBhcyBhbiBvcGVuLWFjY2VzcyBsaWJyYXJ5IGZvciBhcmNoaXZpbmcsIHB1Ymxpc2hpbmcsIGFuZCBkaXNzZW1pbmF0aW5nIGdlb3JlZmVyZW5jZWQgZGF0YSBmcm9tIHRoZSBFYXJ0aCwgZW52aXJvbm1lbnRhbCwgYW5kIGJpb2RpdmVyc2l0eSBzY2llbmNlcy4gT3JpZ2luYWxseSBldm9sdmluZyBmcm9tIGEgZGF0YWJhc2UgZm9yIHNlZGltZW50IGNvcmVzLCBpdCBpcyBvcGVyYXRlZCBhcyBhIGpvaW50IGZhY2lsaXR5IG9mIHRoZSBBbGZyZWQgV2VnZW5lciBJbnN0aXR1dGUsIEhlbG1ob2x0eiBDZW50cmUgZm9yIFBvbG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zZW5zY2hhZnRlbiIsImxhbmd1YWdlIjoiZGV1In0seyJ0ZXh0IjoiTUFSVU0iLCJsYW5ndWFnZSI6ImRldSJ9XSwicmVzcG9uc2liaWxpdHlUeXBlcyI6W3sidGV4dCI6ImdlbmVyYWwifV0sImlkZW50aWZpZXJzIjpbeyJ0ZXh0IjoiUk9SOjAyZ24xYXI1MyJ9XSwiY29udGFjdHMiOlt7InRleHQiOiJodHRwczovL3d3dy5tYXJ1bS5kZS9lbi9Qcm9mLi1Eci4tZnJhbmstb2xpdmVyLWdsb2Vja25lci5odG1sIn1dfV0sImRhdGFBY2Nlc3NlcyI6W3sidHlwZSI6Im9wZW4iLCJyZXN0cmljdGlvbnMiOltdfV0sImRhdGFVcGxvYWRzIjpbeyJ0eXBlIjoicmVzdHJpY3RlZCIsInJlc3RyaWN0aW9ucyI6W3sidGV4dCI6InJlZ2lzdHJhdGlvbiJ9XX1dLCJkYXRhVXBsb2FkTGljZW5zZXMiOlt7Im5hbWUiOiJEYXRhIFN1Ym1pc3Npb24iLCJ1cmwiOiJodHRwczovL3d3dy5wYW5nYWVhLmRlL3N1Ym1pdC8ifV0sInBpZFN5c3RlbXMiOlt7InRleHQiOiJET0kifV0sImFwaXMiOlt7InVybCI6Imh0dHBzOi8vd3MucGFuZ2FlYS5kZS9vYWkvcHJvdmlkZXIiLCJ0eXBlIjoiT0FJLVBNSCJ9XSwic29mdHdhcmUiOlt7Im5hbWUiOiJvdGhlciJ9XSwic3RhcnREYXRlIjoiMTk5NCIsImVuZERhdGUiOm51bGwsImNyZWF0ZWQiOiIyMDEyLTA3LTE2VDA5OjM5OjE1WiIsInVwZGF0ZWQiOiIyMDIyLTA0LTA0VDA4OjQ4OjMzWiJ9fX0= + http_version: null + recorded_at: Tue, 13 Sep 2022 06:28:33 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/DatasetType/query_with_parts/returns_all_datasets_with_counts.yml b/spec/fixtures/vcr_cassettes/DatasetType/query_with_parts/returns_all_datasets_with_counts.yml new file mode 100644 index 000000000..d7028f977 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/DatasetType/query_with_parts/returns_all_datasets_with_counts.yml @@ -0,0 +1,99 @@ +--- +http_interactions: +- request: + method: get + uri: https://doi.org/ra/10.14455 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Sun, 11 Sep 2022 21:15:23 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Permissions-Policy: + - interest-cohort=(),browsing-topics=() + Content-Encoding: + - gzip + Cf-Cache-Status: + - DYNAMIC + Report-To: + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=c%2BsdxzBAFF0Bja8R0OAb5fCm21rUsXhcO2NY0ME4qrXdoz7mCXwoJ4dxk4roDxhg3ylfgErQX3yG3UjvqNMCNkrT2mosZUcWm09YBPPc%2BPJcE0w6bAx3AOE%3D"}],"group":"cf-nel","max_age":604800}' + Nel: + - '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Server: + - cloudflare + Cf-Ray: + - 74936b1dac5e78dc-EWR + Alt-Svc: + - h3=":443"; ma=86400, h3-29=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA4vmUlCoBmIFBSUXf08lKwUlQwM9QxMTU1MlHYhwkCNI1Lkov7i4KDVNCShYyxULAIHc92Y3AAAA + http_version: null + recorded_at: Sun, 11 Sep 2022 21:15:23 GMT +- request: + method: get + uri: https://doi.org/ra/10.14454 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 16 Sep 2022 19:25:16 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Permissions-Policy: + - interest-cohort=(),browsing-topics=() + Content-Encoding: + - gzip + Cf-Cache-Status: + - DYNAMIC + Report-To: + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=BR7GB4AudG%2BT2w9Zv%2FzJ%2FCWTnSWmMqwRl49%2FQT1BUSc3fx0qZ%2BLiefxVTIpnxet0CmHGcsdXzf44qmp%2F4QXKzbAtJROg2lAymJ8CG0af1iH2QWyyBHGeKjM%3D"}],"group":"cf-nel","max_age":604800}' + Nel: + - '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Server: + - cloudflare + Cf-Ray: + - 74bbfcb33dc08c7e-EWR + Alt-Svc: + - h3=":443"; ma=86400, h3-29=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA4vmUlCoBmIFBSUXf08lKwUlQwM9QxMTUxMlHYhwkCNI1CWxJNE5syRVCShYyxULAOwjuKo3AAAA + http_version: null + recorded_at: Fri, 16 Sep 2022 19:25:16 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/fixtures/vcr_cassettes/Doi/parts/has_parts.yml b/spec/fixtures/vcr_cassettes/Doi/parts/has_parts.yml new file mode 100644 index 000000000..901f6ebba --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Doi/parts/has_parts.yml @@ -0,0 +1,99 @@ +--- +http_interactions: +- request: + method: get + uri: https://doi.org/ra/10.14455 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Mon, 12 Sep 2022 01:01:43 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Permissions-Policy: + - interest-cohort=(),browsing-topics=() + Content-Encoding: + - gzip + Cf-Cache-Status: + - DYNAMIC + Report-To: + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=AYX59N0%2B9f%2B1pTRPk7MkWba6LKc44DyNRwNryWO%2FoSOSlOul5Th4JkDgPdWjfI5sKlbYxrcQ69S7QxGsc2w7l3%2Fj2P5l460E%2BA358mNwEpDzyrPLGZpQWZ8%3D"}],"group":"cf-nel","max_age":604800}' + Nel: + - '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Server: + - cloudflare + Cf-Ray: + - 7494b6a8ee8d0cd9-EWR + Alt-Svc: + - h3=":443"; ma=86400, h3-29=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA4vmUlCoBmIFBSUXf08lKwUlQwM9QxMTU1MlHYhwkCNI1Lkov7i4KDVNCShYyxULAIHc92Y3AAAA + http_version: null + recorded_at: Mon, 12 Sep 2022 01:01:43 GMT +- request: + method: get + uri: https://doi.org/ra/10.14454 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Mozilla/5.0 (compatible; Maremma/4.9.8; mailto:info@datacite.org) + Accept: + - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5 + Accept-Encoding: + - gzip,deflate + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 16 Sep 2022 20:34:02 GMT + Content-Type: + - application/json;charset=UTF-8 + Connection: + - keep-alive + Permissions-Policy: + - interest-cohort=(),browsing-topics=() + Content-Encoding: + - gzip + Cf-Cache-Status: + - DYNAMIC + Report-To: + - '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=nFjgqJM18rDad1%2BFALSPyDhnUcQ80x9pXaREWJqvkKomv47NzSUucNdSQW1%2B5WBwawX4FUfpKsX2L9waNpRM1AgrEYMMftIvGyt5uPQqHGko3huauzFwbQw%3D"}],"group":"cf-nel","max_age":604800}' + Nel: + - '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Server: + - cloudflare + Cf-Ray: + - 74bc616fcc518c72-EWR + Alt-Svc: + - h3=":443"; ma=86400, h3-29=":443"; ma=86400 + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAA4vmUlCoBmIFBSUXf08lKwUlQwM9QxMTUxMlHYhwkCNI1CWxJNE5syRVCShYyxULAOwjuKo3AAAA + http_version: null + recorded_at: Fri, 16 Sep 2022 20:34:02 GMT +recorded_with: VCR 5.1.0 diff --git a/spec/graphql/types/member_type_spec.rb b/spec/graphql/types/member_type_spec.rb index 36c9b8a6f..27a005816 100644 --- a/spec/graphql/types/member_type_spec.rb +++ b/spec/graphql/types/member_type_spec.rb @@ -150,7 +150,6 @@ let(:provider) { create(:provider, symbol: "TESTC") } let!(:client) { create(:client, provider: provider, software: "dataverse") } let!(:doi) { create(:doi, client: client, aasm_state: "findable") } - let(:prefix) { create(:prefix) } let!(:provider_prefixes) do create_list(:provider_prefix, 3, provider: provider) end @@ -239,12 +238,14 @@ expect(repository1.fetch("name")).to eq(client.name) expect(repository1.fetch("software")).to eq(["dataverse"]) - expect(response.dig("data", "member", "prefixes", "totalCount")).to eq(3) + expect(response.dig("data", "member", "prefixes", "totalCount")).to eq(4) + # Remember when writing tests that the creation of a client will assign a prefix to that provider/client. + # Then when we assign 3 more prefixes ot the provider, the count will be 4 total. expect(response.dig("data", "member", "prefixes", "years")).to eq( - [{ "count" => 3, "id" => current_year }], + [{ "count" => 4, "id" => current_year }], ) expect(response.dig("data", "member", "prefixes", "nodes").length).to eq( - 3, + 4, ) prefix1 = response.dig("data", "member", "prefixes", "nodes", 0) expect(prefix1.fetch("name")).to eq(@provider_prefixes.first.prefix_id) diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index e293aef55..2df9b62a0 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -117,6 +117,7 @@ ReferenceRepository.import(force: true) VCR.use_cassette("ReferenceRepositoryType/re3Data/set_of_10_re3_repositories") do + create(:prefix, uid: "10.17616") create(:reference_repository, re3doi: "10.17616/R3BW5R") create(:reference_repository, re3doi: "10.17616/r3vg6n") create(:reference_repository, re3doi: "10.17616/r37m1j") @@ -475,6 +476,7 @@ before :all do ReferenceRepository.import(force: true) VCR.use_cassette("ReferenceRepositoryType/re3Data/R3XS37") do + create(:prefix) @client = create(:client) @ref_repo = create(:reference_repository, client_id: @client.uid, re3doi: "10.17616/R3XS37") sleep 2 @@ -541,6 +543,7 @@ before :all do VCR.use_cassette("ReferenceRepositoryType/related_works_citations", allow_playback_repeats: true) do + create_list(:prefix, 2) @provider = create(:provider) @client = create(:client, provider: @provider) @client2 = create(:client, provider: @provider) @@ -620,6 +623,7 @@ end describe "find repository with prefixes" do + let!(:prefix) { create(:prefix) } let(:provider) { create(:provider, symbol: "TESTC") } let(:client) do create( @@ -628,8 +632,6 @@ ) end let!(:doi) { create(:doi, client: client, aasm_state: "findable") } - let(:prefix) { create(:prefix) } - let!(:client_prefixes) { create_list(:client_prefix, 3, client: client) } before do Provider.import(force: true) @@ -637,6 +639,8 @@ Doi.import(force: true) Prefix.import(force: true) ClientPrefix.import(force: true) + ReferenceRepository.import(force: true) + Event.import(force: true) sleep 3 end @@ -678,15 +682,17 @@ expect( response.dig("data", "repository", "prefixes", "totalCount"), - ).to eq(3) + ).to eq(1) + # Remember when writing tests that the creation of a client will assign a prefix to that provider/client. + # There is only 1 prefix in this test. expect(response.dig("data", "repository", "prefixes", "years")).to eq( - [{ "count" => 3, "id" => @current_year }], + [{ "count" => 1, "id" => @current_year }], ) expect( response.dig("data", "repository", "prefixes", "nodes").length, - ).to eq(3) + ).to eq(1) prefix1 = response.dig("data", "repository", "prefixes", "nodes", 0) - expect(prefix1.fetch("name")).to eq(client_prefixes.first.prefix_id) + expect(prefix1.fetch("name")).to eq(client.prefix_ids.first) end end end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 1e18ec947..ef2e19a21 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -3,11 +3,11 @@ require "rails_helper" require "cancan/matchers" -describe User, type: :model do +describe User, type: :model, elasticsearch: true do let(:token) { User.generate_token } let(:user) { User.new(token) } - let(:consortium) { create(:provider, role_name: "ROLE_CONSORTIUM") } - let(:provider) do + let!(:consortium) { create(:provider, role_name: "ROLE_CONSORTIUM") } + let!(:provider) do create( :provider, consortium: consortium, role_name: "ROLE_CONSORTIUM_ORGANIZATION", @@ -15,14 +15,14 @@ end let(:contact) { create(:contact, provider: provider) } let(:consortium_contact) { create(:contact, provider: consortium) } - let(:client) { create(:client, provider: provider) } - let(:prefix) { create(:prefix, uid: "10.14454") } + let!(:prefix) { create(:prefix, uid: "10.14454") } + let!(:client) { create(:client, provider: provider) } + let!(:provider_prefix) do + create(:provider_prefix, provider: provider, prefix: prefix) + end let!(:client_prefix) do create(:client_prefix, client: client, prefix: prefix) end - let(:provider_prefix) do - create(:provider_prefix, provider: provider, prefix: prefix) - end let(:doi) { create(:doi, client: client) } let(:media) { create(:media, doi: doi) } let(:xml) { file_fixture("datacite.xml").read } diff --git a/spec/models/client_prefix_spec.rb b/spec/models/client_prefix_spec.rb index 76157e25f..2002fbcf0 100644 --- a/spec/models/client_prefix_spec.rb +++ b/spec/models/client_prefix_spec.rb @@ -2,30 +2,32 @@ require "rails_helper" -describe ClientPrefix, type: :model do - let(:provider) { create(:provider) } - let(:client) { create(:client, provider: provider) } - let(:prefix) { create(:prefix, uid: "10.5083") } - let(:provider_prefix) do - create(:provider_prefix, prefix: prefix, provider: provider) - end - subject do - create( - :client_prefix, - client: client, prefix: prefix, provider_prefix: provider_prefix, - ) - end +describe ClientPrefix, type: :model, elasticsearch: true do + context "Prefix assigned from the pool on repository creation" do + let(:provider) { create(:provider) } + let(:client) { create(:client, provider: provider) } + let(:prefix) { client.prefixes.first } + let(:provider_prefix) do + create(:provider_prefix, prefix: prefix, provider: provider) + end + subject do + create( + :client_prefix, + client: client, prefix: prefix, provider_prefix: provider_prefix, + ) + end - describe "Validations" do - it { should validate_presence_of(:client) } - it { should validate_presence_of(:prefix) } - it { should validate_presence_of(:provider_prefix) } - end + describe "Validations" do + it { should validate_presence_of(:client) } + it { should validate_presence_of(:prefix) } + it { should validate_presence_of(:provider_prefix) } + end - describe "methods" do - it "is valid" do - expect(subject.client.name).to eq("My data center") - expect(subject.prefix.uid).to eq("10.5083") + describe "methods" do + it "is valid" do + expect(subject.client.name).to eq("My data center") + expect(subject.prefix.uid).to eq(prefix.uid) + end end end end diff --git a/spec/models/client_spec.rb b/spec/models/client_spec.rb index 3bc4ea790..6713c4f1a 100644 --- a/spec/models/client_spec.rb +++ b/spec/models/client_spec.rb @@ -3,8 +3,8 @@ 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) } @@ -65,37 +65,32 @@ params = client.to_jsonapi expect(params.dig("id")).to eq(client.symbol.downcase) expect(params.dig("attributes", "symbol")).to eq(client.symbol) - expect(params.dig("attributes", "system-email")).to eq( + expect(params.dig("attributes", "system_email")).to eq( client.system_email, ) - expect(params.dig("attributes", "provider-id")).to eq(client.provider_id) - expect(params.dig("attributes", "is-active")).to be true + expect(params.dig("attributes", "provider_id")).to eq(client.provider_id) + expect(params.dig("attributes", "is_active")).to be true end end describe "Client transfer" do - let!(:prefixes) { create_list(:prefix, 3) } - let!(:prefix) { prefixes.first } - - ### Order is important in creating prefixes relations - let!(:provider_prefix) do - create(:provider_prefix, provider: provider, prefix: prefix) + let!(:prefixes) do + create_list(:prefix, 10).each_with_index do |prefix, i| + prefix.uid = "10." + (7000 + i).to_s + prefix.save + end end + let!(:prefix) { client.prefixes.first } + let!(:provider_prefix_more) do create(:provider_prefix, provider: provider, prefix: prefixes.last) end - let!(:client_prefix) do - create( - :client_prefix, - client: client, prefix: prefix, provider_prefix_id: provider_prefix.uid, - ) - end - let(:new_provider) do + let!(:new_provider) do create(:provider, symbol: "QUECHUA", member_type: "direct_member") end - let(:provider_target_id) { new_provider.symbol } - let(:bad_provider_target_id) { "SALS" } + let!(:provider_target_id) { new_provider.symbol } + let!(:bad_provider_target_id) { "SALS" } context "to direct_member" do it "works" do @@ -173,22 +168,19 @@ end describe "Client prefixes transfer" do - let!(:prefixes) { create_list(:prefix, 3) } - let!(:prefix) { prefixes.first } - ### Order is important in creating prefixes relations - let!(:provider_prefix) do - create(:provider_prefix, provider: provider, prefix: prefix) + let!(:prefixes) do + create_list(:prefix, 10).each_with_index do |prefix, i| + prefix.uid = "10." + (7000 + i).to_s + prefix.save + end end + let!(:prefix) { client.prefixes.first } + let!(:provider_prefix_more) do create(:provider_prefix, provider: provider, prefix: prefixes.last) end - let!(:client_prefix) do - create( - :client_prefix, - client: client, prefix: prefix, provider_prefix_id: provider_prefix.uid, - ) - end - let(:new_provider) { create(:provider, symbol: "QUECHUA") } + + let!(:new_provider) { create(:provider, symbol: "QUECHUA") } it "works" do client.transfer_prefixes(provider_target_id: new_provider.symbol) diff --git a/spec/models/prefix_spec.rb b/spec/models/prefix_spec.rb index 665e47848..e3123d5f3 100644 --- a/spec/models/prefix_spec.rb +++ b/spec/models/prefix_spec.rb @@ -13,8 +13,8 @@ describe "methods" do it "prefixes all" do collection = Prefix.all - expect(collection.length).to eq(prefixes.length) - single = collection.first + expect(collection.length).to eq(prefixes.length + @prefix_pool.length) + single = collection[@prefix_pool.length] expect(single.uid).to eq(prefix.uid) # meta = providers[:meta] # expect(meta["resource-types"]).not_to be_empty @@ -25,7 +25,7 @@ it "prefixes with where year" do collection = Prefix.where("YEAR(prefixes.created_at) = ?", prefix.created_at) - single = collection.first + single = collection[@prefix_pool.length] expect(single.created_at.year).to eq(prefix.created_at.year) expect(single.uid).to eq(prefix.uid) end diff --git a/spec/models/provider_prefix_spec.rb b/spec/models/provider_prefix_spec.rb index 254ac399b..f708ee089 100644 --- a/spec/models/provider_prefix_spec.rb +++ b/spec/models/provider_prefix_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" describe ProviderPrefix, type: :model do - let(:prefix) { create(:prefix, uid: "10.5083") } + let(:prefix) { create(:prefix, uid: "10.6000") } let(:provider) { create(:provider) } subject { create(:provider_prefix, prefix: prefix, provider: provider) } @@ -15,7 +15,7 @@ describe "methods" do it "is valid" do expect(subject.provider.name).to eq("My provider") - expect(subject.prefix.uid).to eq("10.5083") + expect(subject.prefix.uid).to eq("10.6000") end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 7bd81d84f..e22f9865f 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,6 +2,7 @@ ENV["RAILS_ENV"] = "test" ENV["TEST_CLUSTER_NODES"] = "1" +ENV["PREFIX_POOL_SIZE"] = "20" # set up Code Climate require "simplecov" @@ -73,6 +74,15 @@ DataCatalog.fetch_and_cache_all(pages: 3, duration: 30.minutes) end end + + config.before(:each) do |example| + prefix_pool_size = example.metadata[:prefix_pool_size].present? ? example.metadata[:prefix_pool_size] : ENV["PREFIX_POOL_SIZE"].to_i + if prefix_pool_size < 0 + @prefix_pool = [] + else + @prefix_pool = create_list(:prefix, prefix_pool_size) + end + end end VCR.configure do |c| diff --git a/spec/requests/client_prefixes_spec.rb b/spec/requests/client_prefixes_spec.rb index b428d2a72..7227effef 100644 --- a/spec/requests/client_prefixes_spec.rb +++ b/spec/requests/client_prefixes_spec.rb @@ -3,19 +3,11 @@ require "rails_helper" describe "Client Prefixes", type: :request, elasticsearch: true do - let(:prefix) { create(:prefix) } - let(:provider) { create(:provider) } - let(:client) { create(:client, provider: provider) } - let(:provider_prefix) do - create(:provider_prefix, provider: provider, prefix: prefix) - end - let!(:client_prefixes) { create_list(:client_prefix, 5) } - let(:client_prefix) do - create( - :client_prefix, - client: client, prefix: prefix, provider_prefix: provider_prefix, - ) - end + let!(:provider) { create(:provider) } + let!(:client) { create(:client, provider: provider) } + let!(:client_prefix) { client.client_prefixes.first } + let!(:provider_prefix) { client.provider_prefixes.first } + let!(:client_prefixes) { create_list(:client_prefix, 5, client: client) } let(:bearer) { User.generate_token(role_id: "staff_admin") } let(:headers) do { @@ -35,7 +27,7 @@ get "/client-prefixes", nil, headers expect(last_response.status).to eq(200) - expect(json["data"].size).to eq(5) + expect(json["data"].size).to eq(6) end end @@ -83,6 +75,13 @@ describe "POST /client-prefixes" do context "when the request is valid" do + # A valid request depends on having a valid, unassigned provider_prefix. + # A valid provider prefix: created from an available prefix, that has not yet been assigned to a repository. + let!(:prefix) { create(:prefix, uid: "10.7000") } + let!(:provider_prefix) do + create(:provider_prefix, provider: provider, prefix: prefix) + end + let(:valid_attributes) do { "data" => { @@ -126,7 +125,8 @@ end describe "DELETE /client-prefixes/:uid" do - let!(:client_prefix) { create(:client_prefix) } + let!(:provider_prefix) { create(:provider_prefix, provider: provider) } + let!(:client_prefix) { create(:client_prefix, client: client, provider_prefix: provider_prefix) } before do ClientPrefix.import diff --git a/spec/requests/clients_spec.rb b/spec/requests/clients_spec.rb index 71064a997..d500c2649 100644 --- a/spec/requests/clients_spec.rb +++ b/spec/requests/clients_spec.rb @@ -38,6 +38,7 @@ before do Client.import + Provider.import sleep 1 end @@ -107,7 +108,7 @@ end describe "GET /clients/totals" do - let(:client) { create(:client) } + let!(:client) { create(:client, provider: provider) } let!(:datacite_dois) do create_list( :doi, @@ -202,6 +203,69 @@ end end + describe "POST /clients" do + context "when there are available prefixes" do + it "creates a client with a prefix from the pool" do + post "/clients", params, headers + + expect(last_response.status).to eq(201) + attributes = json.dig("data", "attributes") + expect(attributes["name"]).to eq("Imperial College") + expect(attributes["contactEmail"]).to eq("bob@example.com") + expect(attributes["clientType"]).to eq("repository") + relationships = json.dig("data", "relationships") + expect(relationships.dig("provider", "data", "id")).to eq( + provider.uid, + ) + + prefixes = json.dig("data", "relationships", "prefixes", "data") + expect(prefixes.count).to eq(1) + expect(prefixes.first["id"]).to eq(@prefix_pool[1].uid) + end + end + + context "when there are available provider prefixes" do + let!(:prefix) { create(:prefix, uid: "10.14454") } + let!(:provider_prefix) do + create(:provider_prefix, provider: provider, prefix: prefix) + end + + it "creates a client with a provider prefix" do + post "/clients", params, headers + + expect(last_response.status).to eq(201) + attributes = json.dig("data", "attributes") + expect(attributes["name"]).to eq("Imperial College") + expect(attributes["contactEmail"]).to eq("bob@example.com") + expect(attributes["clientType"]).to eq("repository") + relationships = json.dig("data", "relationships") + expect(relationships.dig("provider", "data", "id")).to eq( + provider.uid, + ) + + prefixes = json.dig("data", "relationships", "prefixes", "data") + expect(prefixes.count).to eq(1) + expect(prefixes.first["id"]).to eq("10.14454") + end + end + + context "when there are no available prefixes" do + it "returns error message", prefix_pool_size: 1 do + post "/clients", params, headers + + expect(json["errors"]).to eq( + [ + { + "source" => "base", + "title" => "No prefixes available. Unable to create repository.", + "uid" => params["data"]["attributes"]["symbol"].downcase + }, + ], + ) + end + end + end + describe "PUT /clients/:id" do context "when the record exists" do let(:params) do @@ -267,7 +331,7 @@ end context "transfer repository" do - let(:new_provider) do + let!(:new_provider) do create(:provider, symbol: "QUECHUA", password_input: "12345") end let!(:prefixes) { create_list(:prefix, 3) } @@ -313,7 +377,7 @@ ).to eq("quechua") expect( json.dig("data", "relationships", "prefixes", "data").first.dig("id"), - ).to eq(prefix.uid) + ).to eq(client.prefixes.first.uid) get "/providers/#{provider.symbol}" @@ -324,16 +388,22 @@ json.dig("data", "relationships", "prefixes", "data").first.dig("id"), ).to eq(prefixes.last.uid) + Provider.import + Client.import + sleep 2 + get "/providers/#{new_provider.symbol}" expect( json.dig("data", "relationships", "prefixes", "data").first.dig("id"), - ).to eq(prefix.uid) + ).to eq(new_provider.prefixes.first.uid) get "/prefixes/#{prefix.uid}" expect( json.dig("data", "relationships", "clients", "data").first.dig("id"), ).to eq(client.uid) + ProviderPrefix.import + get "provider-prefixes?query=#{prefix.uid}" expect( json.dig("meta", "total"), diff --git a/spec/requests/datacite_dois_spec.rb b/spec/requests/datacite_dois_spec.rb old mode 100644 new mode 100755 index 99e3df699..de19e45c0 --- a/spec/requests/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois_spec.rb @@ -4190,10 +4190,15 @@ end describe "GET /dois/get-dois", vcr: true do - let(:prefix) { create(:prefix, uid: "10.5438") } + let!(:prefix) { create(:prefix, uid: "10.5438") } + let!(:provider_prefix) { create(:provider_prefix, provider: provider, prefix: prefix) } let!(:client_prefix) { create(:client_prefix, prefix: prefix, client: client) } it "returns all dois" do + # 'get /dois/get-dois' uses first prefix assigned to the client. + # The test expects the second prefix, which we defined above. + client.prefixes.first.delete + get "/dois/get-dois", nil, headers expect(last_response.status).to eq(200) diff --git a/spec/requests/media_spec.rb b/spec/requests/media_spec.rb index fe31bcadc..396895b7b 100644 --- a/spec/requests/media_spec.rb +++ b/spec/requests/media_spec.rb @@ -4,9 +4,10 @@ describe MediaController, type: :request, order: :defined, elasticsearch: true do - let(:provider) { create(:provider, symbol: "ADMIN") } - let(:client) { create(:client, provider: provider) } - let(:datacite_doi) { create(:doi, client: client, type: "DataciteDoi") } + let!(:provider) { create(:provider, symbol: "ADMIN") } + let!(:prefix) { create(:prefix, uid: "10.14455") } + let!(:client) { create(:client, provider: provider) } + let!(:datacite_doi) { create(:doi, client: client, type: "DataciteDoi", doi: (prefix.uid + "/" + Faker::Internet.password(8)).downcase) } let!(:medias) { create_list(:media, 5, doi: datacite_doi) } let!(:media) { create(:media, doi: datacite_doi) } let(:bearer) do @@ -153,6 +154,8 @@ describe "PATCH /dois/DOI/media/:id" do context "when the request is valid" do + let(:media_type) { "application/xml" } + let(:valid_attributes) do { "data" => { diff --git a/spec/requests/prefixes_spec.rb b/spec/requests/prefixes_spec.rb index c37a041bf..0cdd8cdeb 100644 --- a/spec/requests/prefixes_spec.rb +++ b/spec/requests/prefixes_spec.rb @@ -21,9 +21,8 @@ it "returns prefixes" do get "/prefixes", nil, headers - expect(last_response.status).to eq(200) - expect(json["data"].size).to eq(10) + expect(json["meta"]["total"]).to eq(@prefix_pool.length + 10) end it "returns prefixes by id" do @@ -37,7 +36,7 @@ get "/prefixes?query=10.508", nil, headers expect(last_response.status).to eq(200) - expect(json["data"].size).to eq(10) + expect(json["meta"]["total"]).to eq(@prefix_pool.length + 10) end end diff --git a/spec/requests/provider_prefixes_spec.rb b/spec/requests/provider_prefixes_spec.rb index 18c81e3d8..db6a9fad5 100644 --- a/spec/requests/provider_prefixes_spec.rb +++ b/spec/requests/provider_prefixes_spec.rb @@ -191,7 +191,7 @@ get "/prefixes?state=unassigned", nil, headers expect(last_response.status).to eq(200) - expect(json.dig("meta", "total")).to eq(0) + expect(json.dig("meta", "total")).to eq(@prefix_pool.length) delete "/provider-prefixes/#{provider_prefix.uid}", nil, headers @@ -203,7 +203,7 @@ get "/prefixes?state=unassigned", nil, headers expect(last_response.status).to eq(200) - expect(json.dig("meta", "total")).to eq(1) + expect(json.dig("meta", "total")).to eq(@prefix_pool.length + 1) end end diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb index 955fc7121..819459f15 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -5,7 +5,7 @@ describe RepositoriesController, type: :request, elasticsearch: true do let(:ids) { clients.map(&:uid).join(",") } let(:consortium) { create(:provider, role_name: "ROLE_CONSORTIUM") } - let(:provider) do + let!(:provider) do create( :provider, consortium: consortium, @@ -97,7 +97,8 @@ "bc7d0274-3472-4a79-b631-e4c7baccc667", ) expect(json.dig("data", "attributes", "software")).to eq(client.software) - expect(json["meta"]).to eq("doiCount" => 0, "prefixCount" => 0) + # Newly created repositories will have 1 prefix. + expect(json["meta"]).to eq("doiCount" => 0, "prefixCount" => 1) end end @@ -145,7 +146,8 @@ describe "GET /repositories/:id meta" do let(:provider) { create(:provider) } let(:client) { create(:client) } - let!(:client_prefix) { create(:client_prefix, client: client) } + # Do not need to create a client_prefix since the prefix is auto-assigned at repository creation. + # let!(:client_prefix) { create(:client_prefix, client: client) } let!(:datacite_dois) do create_list( :doi, @@ -429,18 +431,7 @@ let(:new_provider) do create(:provider, symbol: "QUECHUA", password_input: "12345") end - let!(:prefix) { create(:prefix) } - let!(:provider_prefix) do - create(:provider_prefix, provider: provider, prefix: prefix) - end - let!(:client_prefix) do - create( - :client_prefix, - client: client, - prefix: prefix, - provider_prefix_id: provider_prefix.uid, - ) - end + let(:prefix) { client.prefixes.first } let(:doi) { create_list(:doi, 10, client: client) } let(:params) do @@ -477,7 +468,7 @@ expect( json.dig("data", "relationships", "prefixes", "data").first.dig("id"), - ).to eq(prefix.uid) + ).to eq(new_provider.prefixes.first.uid) get "/prefixes/#{prefix.uid}" expect( diff --git a/spec/requests/repository_prefixes_spec.rb b/spec/requests/repository_prefixes_spec.rb index 23808aef9..b58ea0ca6 100644 --- a/spec/requests/repository_prefixes_spec.rb +++ b/spec/requests/repository_prefixes_spec.rb @@ -3,19 +3,8 @@ require "rails_helper" describe RepositoryPrefixesController, type: :request do - let(:prefix) { create(:prefix) } - let(:provider) { create(:provider) } - let(:client) { create(:client, provider: provider) } - let(:provider_prefix) do - create(:provider_prefix, provider: provider, prefix: prefix) - end - let!(:client_prefixes) { create_list(:client_prefix, 5) } - let(:client_prefix) do - create( - :client_prefix, - client: client, prefix: prefix, provider_prefix: provider_prefix, - ) - end + let!(:provider) { create(:provider) } + let!(:client) { create(:client, provider: provider) } let(:bearer) { User.generate_token(role_id: "staff_admin") } let(:headers) do { @@ -28,6 +17,7 @@ before do Prefix.import ClientPrefix.import + ProviderPrefix.import sleep 2 end @@ -35,12 +25,12 @@ get "/repository-prefixes", nil, headers expect(last_response.status).to eq(200) - expect(json["data"].size).to eq(5) + expect(json["data"].size).to eq(1) end it "returns repository-prefixes by repository-id" do get "/repository-prefixes?repository-id=#{ - client_prefixes.first.client_id + client.client_prefixes.first.client_id }", nil, headers @@ -49,7 +39,7 @@ end it "returns repository-prefixes by prefix-id" do - get "/repository-prefixes?prefix-id=#{client_prefixes.first.prefix_id}", + get "/repository-prefixes?prefix-id=#{client.client_prefixes.first.prefix_id}", nil, headers expect(last_response.status).to eq(200) @@ -60,13 +50,13 @@ get "/repository-prefixes?query=10.508", nil, headers expect(last_response.status).to eq(200) - expect(json["data"].size).to eq(5) + expect(json["data"].size).to eq(1) end it "returns repository-prefixes by repository-id and prefix-id" do get "/repository-prefixes?repository-id=#{ - client_prefixes.first.client_id - }&#{client_prefixes.first.prefix_id}", + client.client_prefixes.first.client_id + }&#{client.client_prefixes.first.prefix_id}", nil, headers expect(last_response.status).to eq(200) @@ -74,7 +64,7 @@ end it "returns prefixes by client-id" do - get "/prefixes?client-id=#{client_prefixes.first.client_id}", + get "/prefixes?client-id=#{client.client_prefixes.first.client_id}", nil, headers expect(last_response.status).to eq(200) @@ -85,11 +75,11 @@ describe "GET /repository-prefixes/:uid" do context "when the record exists" do it "returns the repository-prefix" do - get "/repository-prefixes/#{client_prefix.uid}", + get "/repository-prefixes/#{client.client_prefixes.first.uid}", nil, headers expect(last_response.status).to eq(200) - expect(json.dig("data", "id")).to eq(client_prefix.uid) + expect(json.dig("data", "id")).to eq(client.client_prefixes.first.uid) end end @@ -108,7 +98,7 @@ describe "PATCH /repository-prefixes/:uid" do it "returns method not supported error" do - patch "/repository-prefixes/#{client_prefix.uid}", + patch "/repository-prefixes/#{client.client_prefixes.first.uid}", nil, headers expect(last_response.status).to eq(405) @@ -119,20 +109,13 @@ end describe "DELETE /repository-prefixes/:uid", elasticsearch: true do - let!(:client_prefix) do - create( - :client_prefix, - client: client, prefix: prefix, provider_prefix: provider_prefix, - ) - end - before do ClientPrefix.import sleep 2 end it "deletes a repository-prefix" do - delete "/repository-prefixes/#{client_prefix.uid}", + delete "/repository-prefixes/#{client.client_prefixes.first.uid}", nil, headers expect(last_response.status).to eq(204) @@ -149,6 +132,9 @@ end context "when the request is valid" do + let! (:provider_prefix) { + create(:provider_prefix, provider: provider) + } let(:valid_attributes) do { "data" => { @@ -160,7 +146,7 @@ "provider-prefix": { "data": { "type": "provider-prefix", "id": provider_prefix.uid }, }, - "prefix": { "data": { "type": "prefix", "id": prefix.uid } }, + "prefix": { "data": { "type": "prefix", "id": provider_prefix.prefix.uid } }, }, }, }