Skip to content

Commit

Permalink
Merge pull request #441 from bobbrodie/fix-get-user
Browse files Browse the repository at this point in the history
Fetch users by accountId instead of username
  • Loading branch information
bobbrodie authored May 13, 2024
2 parents 7f6319d + ed11077 commit 4d2cd0b
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 @@ -15,7 +15,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' => 'admin@example.com'
'id' => '1234567890abcdef01234567',
'self' => 'http://localhost:2990/jira/rest/api/2/user?accountId=1234567890abcdef01234567',
'name' => 'admin',
'emailAddress' => 'admin@example.com',
'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": "admin@example.com",
"avatarUrls": {
Expand Down

0 comments on commit 4d2cd0b

Please sign in to comment.