Skip to content

Commit

Permalink
tests for unsetting countries etc
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Mar 18, 2024
1 parent 272a4f2 commit 72f3935
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/requests/v0/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,26 @@
expect(user.reload.country_code).to eq('ES')
end

it "unsets user country code" do
j = api_put "users/#{[user.username,user.id].sample}", {
country_code: nil, access_token: token.token
}
expect(j['location']['country_code']).to be_nil
expect(j['location']['country']).to be_nil
expect(response.status).to eq(200)
expect(user.reload.country_code).to be_nil
end

it "leaves country code as is when not explicitly passsed" do
j = api_put "users/#{[user.username,user.id].sample}", {
username: "new_username", access_token: token.token
}
expect(j['location']['country_code']).to eq("GB")
expect(j['location']['country']).to eq("United Kingdom of Great Britain and Northern Ireland")
expect(response.status).to eq(200)
expect(user.reload.country_code).to eq("GB")
end

it "does not update a user with invalid access_token" do
j = api_put "users/#{[user.username,user.id].sample}", {
username: 'bart', access_token: '123'
Expand Down

0 comments on commit 72f3935

Please sign in to comment.