From 375c24674cd4b89fd5868062e8e2abb026170e81 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Mon, 4 Nov 2019 20:35:44 +0100 Subject: [PATCH] rename consortium_member to consortium datacite/datacite#863 --- app/controllers/providers_controller.rb | 6 +++--- app/models/provider.rb | 8 ++++---- app/serializers/provider_serializer.rb | 2 +- spec/models/provider_spec.rb | 4 ++-- spec/requests/providers_spec.rb | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 635b354aa..17214c902 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -157,7 +157,7 @@ def show clients = client_count(provider_id: nil) dois = doi_count(provider_id: nil) resource_types = resource_type_count(provider_id: nil) - elsif @provider.member_type == "consortium_member" + elsif @provider.member_type == "consortium" providers = provider_count(consortium_id: params[:id]) clients = client_count(consortium_id: params[:id]) dois = doi_count(consortium_id: params[:id]) @@ -194,7 +194,7 @@ def create providers = provider_count(consortium_id: nil) clients = client_count(provider_id: nil) dois = doi_count(provider_id: nil) - elsif @provider.member_type == "consortium_member" + elsif @provider.member_type == "consortium" providers = provider_count(consortium_id: params[:id]) clients = client_count(consortium_id: params[:id]) dois = doi_count(consortium_id: params[:id]) @@ -228,7 +228,7 @@ def update providers = provider_count(consortium_id: nil) clients = client_count(provider_id: nil) dois = doi_count(provider_id: nil) - elsif @provider.member_type == "consortium_member" + elsif @provider.member_type == "consortium" providers = provider_count(consortium_id: params[:id]) clients = client_count(consortium_id: params[:id]) dois = doi_count(consortium_id: params[:id]) diff --git a/app/models/provider.rb b/app/models/provider.rb index 7f63d3ca7..73ca74639 100644 --- a/app/models/provider.rb +++ b/app/models/provider.rb @@ -436,7 +436,7 @@ def member_type_labels { "ROLE_MEMBER" => "Member Only", "ROLE_ALLOCATOR" => "Direct Member", - "ROLE_CONSORTIUM" => "Consortium Member", + "ROLE_CONSORTIUM" => "Consortium", "ROLE_CONSORTIUM_ORGANIZATION" => "Consortium Organization", "ROLE_CONTRACTUAL_PROVIDER" => "Contractual Member", "ROLE_ADMIN" => "DataCite admin", @@ -459,7 +459,7 @@ def member_types { "ROLE_MEMBER" => "member_only", "ROLE_ALLOCATOR" => "direct_member", - "ROLE_CONSORTIUM" => "consortium_member", + "ROLE_CONSORTIUM" => "consortium", "ROLE_CONSORTIUM_ORGANIZATION" => "consortium_organization", "ROLE_CONTRACTUAL_PROVIDER" => "contractual_member", "ROLE_FOR_PROFIT_PROVIDER" => "for_profit_provider", @@ -524,8 +524,8 @@ def prefix_ids def can_be_in_consortium if consortium_id && member_type != "consortium_organization" errors.add(:consortium_id, "The provider must be of member_type consortium_organization") - elsif consortium_id && consortium.member_type != "consortium_member" - errors.add(:consortium_id, "The consortium must be of member_type consortium_member") + elsif consortium_id && consortium.member_type != "consortium" + errors.add(:consortium_id, "The consortium must be of member_type consortium") end end diff --git a/app/serializers/provider_serializer.rb b/app/serializers/provider_serializer.rb index d4eb38c88..4a7edb614 100644 --- a/app/serializers/provider_serializer.rb +++ b/app/serializers/provider_serializer.rb @@ -10,7 +10,7 @@ class ProviderSerializer has_many :clients, record_type: :clients has_many :prefixes, record_type: :prefixes belongs_to :consortium, record_type: :providers, serializer: ProviderSerializer, if: Proc.new { |provider| provider.consortium_id } - has_many :consortium_organizations, record_type: :providers, serializer: ProviderSerializer, if: Proc.new { |provider| provider.member_type == "consortium_member" } + has_many :consortium_organizations, record_type: :providers, serializer: ProviderSerializer, if: Proc.new { |provider| provider.member_type == "consortium" } attribute :country do |object| object.country_code diff --git a/spec/models/provider_spec.rb b/spec/models/provider_spec.rb index 7de240796..2a6566c06 100644 --- a/spec/models/provider_spec.rb +++ b/spec/models/provider_spec.rb @@ -101,8 +101,8 @@ it "works" do expect(subject.role_name).to eq("ROLE_CONSORTIUM") - expect(subject.member_type).to eq("consortium_member") - expect(subject.member_type_label).to eq("Consortium Member") + expect(subject.member_type).to eq("consortium") + expect(subject.member_type_label).to eq("Consortium") expect(subject.consortium_organizations.length).to eq(3) consortium_organization = subject.consortium_organizations.last expect(consortium_organization.consortium_id).to eq("VIVA") diff --git a/spec/requests/providers_spec.rb b/spec/requests/providers_spec.rb index 0853fa9bd..1e716b92d 100644 --- a/spec/requests/providers_spec.rb +++ b/spec/requests/providers_spec.rb @@ -165,7 +165,7 @@ end context 'create provider member_role consortium_organization' do - let(:consortium) { create(:provider, member_type: "consortium_member") } + let(:consortium) { create(:provider, member_type: "consortium") } let(:params) do { "data" => { "type" => "providers", "attributes" => { @@ -279,7 +279,7 @@ post '/providers', params, headers expect(last_response.status).to eq(422) - expect(json["errors"].first).to eq("source"=>"consortium_id", "title"=>"The consortium must be of member_type consortium_member") + expect(json["errors"].first).to eq("source"=>"consortium_id", "title"=>"The consortium must be of member_type consortium") end end