Order award tooltips by their created_at date

This commit is contained in:
Andrew Smith 2016-08-30 00:01:00 +10:00
parent 2db570e92c
commit e71df3cdd2
No known key found for this signature in database
GPG Key ID: 7A0B50F5732BBDBD
3 changed files with 12 additions and 1 deletions

View File

@ -22,6 +22,7 @@ v 8.12.0 (unreleased)
- Fix branch title trailing space on hover (ClemMakesApps)
- Award emoji tooltips containing more than 10 usernames are now truncated !4780 (jlogandavison)
- Fix duplicate "me" in award emoji tooltip !5218 (jlogandavison)
- Order award emoji tooltips in order they were added (EspadaV8)
- Fix spacing and vertical alignment on build status icon on commits page (ClemMakesApps)
- Update merge_requests.md with a simpler way to check out a merge request. !5944
- Fix button missing type (ClemMakesApps)

View File

@ -2,7 +2,7 @@ module Awardable
extend ActiveSupport::Concern
included do
has_many :award_emoji, -> { includes(:user) }, as: :awardable, dependent: :destroy
has_many :award_emoji, -> { includes(:user).order(:id) }, as: :awardable, dependent: :destroy
if self < Participable
# By default we always load award_emoji user association

View File

@ -45,4 +45,14 @@ describe Issue, "Awardable" do
expect { issue.toggle_award_emoji("thumbsdown", award_emoji.user) }.to change { AwardEmoji.count }.by(-1)
end
end
describe 'querying award_emoji on an Awardable' do
let(:issue) { create(:issue) }
it 'sorts in ascending fashion' do
create_list(:award_emoji, 3, awardable: issue)
expect(issue.award_emoji).to eq issue.award_emoji.sort_by(&:id)
end
end
end