diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index b0c7a3a60..ccbee0a93 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -130,4 +130,37 @@ feature 'Debates' do expect(page).to have_content "Let's..." end + describe 'Limiting tags shown' do + let(:all_tags) { + ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] + } + let(:debate) { + create :debate, tag_list: all_tags + } + + scenario 'Index page show up to 5 tags per debate' do + debate + visible_tags = ["Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] + + visit debates_path + + expect(page).to have_selector('.debate', count: 1) + within('.debate') do + visible_tags.each do |tag| + expect(page).to have_content tag + end + expect(page).to have_content '2+' + end + end + + scenario 'Debate#show shows the full tag list' do + visit debate_path(debate) + + within("#debate-#{debate.id}") do + all_tags.each do |tag| + expect(page).to have_content tag + end + end + end + end end