Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch users by accountId instead of username #441

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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