Skip to content

Commit

Permalink
rename consortium_member to consortium datacite/datacite#863
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Nov 4, 2019
1 parent dec26c5 commit 375c246
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down
8 changes: 4 additions & 4 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/serializers/provider_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" => {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 375c246

Please sign in to comment.