fix rubocop issue
This commit is contained in:
parent
e92114a257
commit
e3174fa277
4 changed files with 10 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
|||
class Event < ActiveRecord::Base
|
||||
include ActiveRecord::Transitions
|
||||
|
||||
scope :vote, -> (votable_fields) { votable_fields.each { |field| ratyrate_rateable field.title } }
|
||||
scope :vote, ->(votable_fields) { votable_fields.each { |field| ratyrate_rateable field.title } }
|
||||
|
||||
has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class VotableField < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
validates :title, :votable_type, :stars, presence: true
|
||||
validates :title, uniqueness: {scope: :votable_type, message: 'already exsists for the selected votable type'}
|
||||
validates :title, uniqueness: { scope: :votable_type, message: 'already exsists for the selected votable type' }
|
||||
|
||||
VALID_VOTABLE_TYPES = %w(Event).freeze
|
||||
VALID_VOTABLE_TYPES = %w[Event].freeze
|
||||
# ratyrate does not allow criterias to have spaces in them
|
||||
validate :no_spaces_in_title
|
||||
validate :correct_votable_type
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ namespace :votes do
|
|||
Conference.all.each do |conf|
|
||||
VotableField.create(title: 'Overall', conference_id: conf.id, for_admin: true, stars: conf.program.rating, votable_type: 'Event')
|
||||
Event.all.each do |event|
|
||||
votes = Vote.where(event_id: event.id)
|
||||
break unless votes.present?
|
||||
votes = Vote.where(event_id: event.id)
|
||||
break if votes.blank?
|
||||
avg_votes = votes.pluck(:rating).sum / votes.count
|
||||
votes.each do |vote|
|
||||
Rate.create(dimension: 'Overall', rater_id: vote.user_id, rateable_type: 'Event', stars: vote.rating, rateable_id: event.id )
|
||||
Rate.create(dimension: 'Overall', rater_id: vote.user_id, rateable_type: 'Event', stars: vote.rating, rateable_id: event.id)
|
||||
end
|
||||
RatingCache.create(cacheable_id: event.id, cacheable_type: 'Event', avg: avg_votes, qty: votes.count, dimension: 'Overall')
|
||||
end
|
||||
end
|
||||
end
|
||||
puts 'All done!'
|
||||
puts 'All done!'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,19 +50,19 @@ feature Event do
|
|||
expect(page.has_content?('Overall Votes')).to eq false
|
||||
expect(page.has_content?('Your Votes')).to eq true
|
||||
end
|
||||
|
||||
|
||||
scenario 'for program with blind voting disabled can see overall votes' do
|
||||
conference.program.update(rating_enabled: true, voting_start_date: Date.today, voting_end_date: Date.today + 1, blind_voting: false)
|
||||
|
||||
visit admin_conference_program_event_path(conference.short_title, @event)
|
||||
expect(page.has_content?('Overall Votes')).to eq true
|
||||
expect(page.has_content?('Overall Votes')).to eq true
|
||||
expect(page.has_content?('Your Votes')).to eq true
|
||||
end
|
||||
|
||||
scenario 'rejects a proposal', feature: true, js: true do
|
||||
visit admin_conference_program_events_path(conference.short_title)
|
||||
expect(page.has_content?('Example Proposal')).to be true
|
||||
|
||||
|
||||
click_button 'New'
|
||||
click_link "reject_event_#{@event.id}"
|
||||
expect(flash).to eq('Event rejected!')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue