Commit 5629d468 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Finish _participants view spec

parent 38c72291
require 'spec_helper' require 'spec_helper'
require 'nokogiri' require 'nokogiri'
def expect_lazy_load_image(author)
avatar = author.find('img')
expect(avatar[:src]).to eql?('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==')
expect(avatar[:"data-src"]).to exist
end
describe 'shared/issuable/_participants.html.haml' do describe 'shared/issuable/_participants.html.haml' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:participants) { create_list(:user, 10) } let(:participants) { create_list(:user, 100) }
before do before do
allow(view).to receive_messages(project: project, allow(view).to receive_messages(project: project,
participants: participants) participants: participants)
end end
it 'displays' do it 'renders lazy loaded avatars' do
render 'shared/issuable/participants' render 'shared/issuable/participants'
html = Nokogiri::HTML(rendered) html = Nokogiri::HTML(rendered)
authors = html.css('.participants-author') avatars = html.css('.participants-author img')
p authors
p authors.size
visible_authors = authors[0..6]
hidden_authors = authors[7..-1]
visible_authors.each do |author|
expect(author).not_to have_selector('js-participants-hidden')
expect_lazy_load_image(author)
end
hidden_authors.each do |author| avatars.each do |avatar|
expect(author).to have_selector('js-participants-hidden') expect(avatar[:class]).to include('lazy')
expect_lazy_load_image(author) expect(avatar[:src]).to eql('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==')
expect(avatar[:"data-src"]).to match('http://www.gravatar.com/avatar/')
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment