mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Clean up rating partials
This commit is contained in:
parent
73c5c3c97a
commit
9e10678542
10 changed files with 131 additions and 92 deletions
|
|
@ -3,6 +3,13 @@ require 'spec_helper'
|
|||
describe EventsHelper, type: :helper do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:event) { create(:event, program: conference.program) }
|
||||
let(:my_vote) { 3 }
|
||||
let(:max_rating) { 5 }
|
||||
let(:fraction) { my_vote.to_s + '/' + max_rating.to_s }
|
||||
|
||||
setup do
|
||||
allow(event).to receive(:average_rating) { my_vote }
|
||||
end
|
||||
|
||||
describe '#registered_text' do
|
||||
describe 'returns correct string' do
|
||||
|
|
@ -18,4 +25,35 @@ describe EventsHelper, type: :helper do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#rating_tooltip' do
|
||||
let(:vote_count) { pluralize(event.voters.length, 'vote') }
|
||||
|
||||
it 'includes the average rating' do
|
||||
expect(rating_tooltip(event, max_rating)).to match(fraction)
|
||||
end
|
||||
it 'includes the vote count' do
|
||||
expect(rating_tooltip(event, max_rating)).to match(vote_count)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#rating_fraction' do
|
||||
it 'represents the rating as a fraction of the max' do
|
||||
expect(rating_fraction(my_vote, max_rating)).to match(fraction)
|
||||
end
|
||||
|
||||
describe 'rating_stars' do
|
||||
it 'renders labels for each value of max_rating' do
|
||||
expect(
|
||||
rating_stars(my_vote, max_rating).scan('<label class="rating').size
|
||||
).to eq(max_rating)
|
||||
end
|
||||
|
||||
it 'renders bright labels for each value of vote' do
|
||||
expect(
|
||||
rating_stars(my_vote, max_rating).scan('<label class="rating bright').size
|
||||
).to eq(my_vote)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue