diff options
author | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-06-20 02:06:57 +0300 |
---|---|---|
committer | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-08-17 15:33:50 +0300 |
commit | bcdc3694919f6cc9777dd982325469fb87468835 (patch) | |
tree | 14d67ec8ed6cd1a0fdb8a4baf8740d97102aca5c /spec/helpers | |
parent | d1da2e8180d92e5f4a8b5ebb36b0f4e4d0618bf8 (diff) |
Truncated user list in award emoji tooltips
* Only the first 10 names are displayed
* Further users are indicated by "and X more."
* String "and X more" is appended to the array THEN join is called
* An oxford comma seperates the last name from "and X more"
* In coffeescript "me" is now always prepended
* Tests included
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 5e4655dfc95..86955329124 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -62,6 +62,22 @@ describe IssuesHelper do it { is_expected.to eq("!1, !2, or !3") } end + describe '#award_user_list' do + let!(:awards) { build_list(:award_emoji, 15) } + + it "returns a comma seperated list of 1-10 users" do + expect(award_user_list(awards.first(10), nil)).to eq(awards.first(10).map { |a| a.user.name }.join(', ')) + end + + it "displays the current user's name as 'me'" do + expect(award_user_list(awards.first(1), awards[0].user)).to eq('me') + end + + it "truncates lists of larger than 10 users" do + expect(award_user_list(awards, nil)).to eq(awards.first(10).map { |a| a.user.name }.join(', ') + ", and 5 more.") + end + end + describe '#award_active_class' do let!(:upvote) { create(:award_emoji) } |