Skip to content

Commit

Permalink
#409 Fetch users by accountId instead of username
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrodie committed Apr 27, 2024
1 parent 9b09576 commit 2dbb9ca
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/jira/resource/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class User < JIRA::Base
MAX_RESULTS = 1000

def self.singular_path(client, key, prefix = '/')
collection_path(client, prefix) + '?username=' + key
collection_path(client, prefix) + '?accountId=' + key
end

# Cannot retrieve more than 1,000 users through the api, please see: https://jira.atlassian.com/browse/JRASERVER-65089
Expand Down
21 changes: 17 additions & 4 deletions spec/integration/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@
let(:client) { client }
let(:site_url) { site_url }

let(:key) { 'admin' }
let(:key) { '1234567890abcdef01234567' }

let(:expected_attributes) do
{
'self' => 'http://localhost:2990/jira/rest/api/2/user?username=admin',
'name' => key,
'emailAddress' => '[email protected]'
'id' => '1234567890abcdef01234567',
'self' => 'http://localhost:2990/jira/rest/api/2/user?accountId=1234567890abcdef01234567',
'name' => 'admin',
'emailAddress' => '[email protected]',
'avatarUrls' => {
'16x16' => 'http://localhost:2990/jira/secure/useravatar?size=small&avatarId=10122',
'48x48' => 'http://localhost:2990/jira/secure/useravatar?avatarId=10122'
},
'displayName' => 'admin',
'active' => true,
'timeZone' => 'Pacific/Auckland',
'groups' => {
'size' => 3,
'items' => []
},
'expand' => 'groups'
}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/jira/resource/user_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
describe '#myself' do
let(:response) do
instance_double(
'Response', body: get_mock_response('user_username=admin.json')
'Response', body: get_mock_response('user_accountId=1234567890abcdef01234567.json')
)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"self": "http://localhost:2990/jira/rest/api/2/user?username=admin",
"id": "1234567890abcdef01234567",
"self": "http://localhost:2990/jira/rest/api/2/user?accountId=1234567890abcdef01234567",
"name": "admin",
"emailAddress": "[email protected]",
"avatarUrls": {
Expand Down

0 comments on commit 2dbb9ca

Please sign in to comment.