From 4fbbb8e76550fcb8103cc1bf5c8536cf598db829 Mon Sep 17 00:00:00 2001 From: Jack Davison Date: Tue, 21 Jun 2016 23:22:03 +0100 Subject: 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 --- spec/helpers/issues_helper_spec.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'spec/helpers/issues_helper_spec.rb') 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 -- cgit v1.2.3