-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Fenner
committed
Jan 29, 2021
1 parent
6eeab13
commit 0889833
Showing
9 changed files
with
60 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ | |
email { "[email protected]" } | ||
given_name { "Josiah" } | ||
family_name { "Carberry" } | ||
roles { ["voting"] } | ||
role_name { ["voting"] } | ||
|
||
initialize_with { Contact.where(uid: uid).first_or_initialize } | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
"givenName" => "Josiah", | ||
"familyName" => "Carberry", | ||
"email" => "[email protected]", | ||
"roles" => ["voting_contact"] | ||
"roleName" => ["voting"] | ||
}, | ||
"relationships": { | ||
"provider": { | ||
|
@@ -90,7 +90,7 @@ | |
attributes = json.dig("data", "attributes") | ||
expect(attributes["name"]).to eq("Josiah Carberry") | ||
expect(attributes["email"]).to eq("[email protected]") | ||
expect(attributes["roles"]).to eq(["voting_contact"]) | ||
expect(attributes["roleName"]).to eq(["voting"]) | ||
|
||
relationships = json.dig("data", "relationships") | ||
expect(relationships).to eq("provider" => { "data" => { "id" => provider.uid, "type" => "providers" } }) | ||
|
@@ -106,7 +106,7 @@ | |
attributes = json.dig("data", 0, "attributes") | ||
expect(attributes["name"]).to eq("Josiah Carberry") | ||
expect(attributes["email"]).to eq("[email protected]") | ||
expect(attributes["roles"]).to eq(["voting_contact"]) | ||
expect(attributes["roleName"]).to eq(["voting"]) | ||
|
||
relationships = json.dig("data", 0, "relationships") | ||
expect(relationships.dig("provider", "data", "id")).to eq( | ||
|
@@ -172,13 +172,13 @@ | |
end | ||
end | ||
|
||
context "updates roles" do | ||
context "updates role_name" do | ||
let(:params) do | ||
{ | ||
"data" => { | ||
"type" => "contacts", | ||
"attributes" => { | ||
"roles" => ["technical_contact", "service_contact"], | ||
"roleName" => ["technical", "service"], | ||
}, | ||
}, | ||
} | ||
|
@@ -188,33 +188,31 @@ | |
put "/contacts/#{contact.uid}", params, headers | ||
|
||
expect(last_response.status).to eq(200) | ||
expect(json.dig("data", "attributes", "roles")).to eq( | ||
["technical_contact", "service_contact"], | ||
expect(json.dig("data", "attributes", "roleName")).to eq( | ||
["technical", "service"], | ||
) | ||
end | ||
end | ||
|
||
# context "updates roles invalid" do | ||
# let(:params) do | ||
# { | ||
# "data" => { | ||
# "type" => "contacts", | ||
# "attributes" => { | ||
# "roles" => ["technical_contact", "service_contact"], | ||
# }, | ||
# }, | ||
# } | ||
# end | ||
|
||
# it "updates the record" do | ||
# put "/contacts/#{contact.uid}", params, headers | ||
|
||
# expect(last_response.status).to eq(200) | ||
# expect(json.dig("data", "attributes", "roles")).to eq( | ||
# ["technical_contact", "service_contact"], | ||
# ) | ||
# end | ||
# end | ||
context "updates role_name invalid" do | ||
let(:params) do | ||
{ | ||
"data" => { | ||
"type" => "contacts", | ||
"attributes" => { | ||
"roleName" => ["catering"], | ||
}, | ||
}, | ||
} | ||
end | ||
|
||
it "updates the record" do | ||
put "/contacts/#{contact.uid}", params, headers | ||
|
||
expect(last_response.status).to eq(422) | ||
expect(json["errors"]).to eq([{ "source" => "role_name", "title" => "Role name 'catering' is not included in the list of possible role names.", "uid" => contact.uid }]) | ||
end | ||
end | ||
|
||
|
||
context "removes given name and family name" do | ||
|