diff options
author | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-06-22 01:22:03 +0300 |
---|---|---|
committer | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-08-17 15:33:51 +0300 |
commit | 4fbbb8e76550fcb8103cc1bf5c8536cf598db829 (patch) | |
tree | 9ef1af3d5e16ec428cb9a60353e0675723db24d7 /spec/helpers | |
parent | bcdc3694919f6cc9777dd982325469fb87468835 (diff) |
Truncates 9-10 users with current user in front
* If the current user is not in the list output will have 1-9 users
* If the current user is in the list output will be "me, " + 0-9 users
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 86955329124..c4281f8f591 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -65,16 +65,26 @@ describe IssuesHelper do 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(', ')) + it "returns a comma seperated list of 1-9 users" do + expect(award_user_list(awards.first(9), nil)).to eq(awards.first(9).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.") + it "truncates lists of larger than 9 users" do + expect(award_user_list(awards, nil)).to eq(awards.first(9).map { |a| a.user.name }.join(', ') + ", and 6 more.") + end + + it "displays the current user in front of 0-9 other users" do + expect(award_user_list(awards, awards[0].user)). + to eq("me, " + awards[1..9].map { |a| a.user.name }.join(', ') + ", and 5 more.") + end + + it "displays the current user in front regardless of position in the list" do + expect(award_user_list(awards, awards[12].user)). + to eq("me, " + awards[0..8].map { |a| a.user.name }.join(', ') + ", and 5 more.") end end |