Skip to content

Commit

Permalink
fix failing tests by removing votes from spec/
Browse files Browse the repository at this point in the history
  • Loading branch information
shlok007 committed Apr 7, 2017
1 parent 9ab074c commit 6110406
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 108 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ChangeRatingToBooleanInProgram < ActiveRecord::Migration
def change
change_column :programs, :rating, :boolean, default: false
change_column :programs, :rating, :boolean, default: false
end
end
7 changes: 0 additions & 7 deletions spec/factories/votes.rb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/features/program_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@

click_link 'Edit'

fill_in 'program_rating', with: '4'

click_button 'Update Program'

# Validations
expect(flash).
to eq('The program was successfully updated.')
expect(find('#rating').text).to eq('4')
end
end
end
23 changes: 0 additions & 23 deletions spec/features/versions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
expect(page).to have_text("#{organizer.name} updated social tag, email, googleplus and sponsor email of contact details in conference #{conference.short_title}")
end

scenario 'display changes in program', feature: true, versioning: true, js: true do
visit edit_admin_conference_program_path(conference.short_title)
fill_in 'program_rating', with: '4'
click_button 'Update Program'

visit admin_revision_history_path
expect(page).to have_text("#{organizer.name} updated rating of program in conference #{conference.short_title}")
end

scenario 'display changes in cfp', feature: true, versioning: true, js: true do
cfp = create(:cfp, program: conference.program)
cfp.update_attributes(start_date: (Date.today + 1).strftime('%d/%m/%Y'), end_date: (Date.today + 3).strftime('%d/%m/%Y'))
Expand Down Expand Up @@ -340,20 +331,6 @@
expect(page).to have_text("Someone (probably via the console) re-added #{organizer.name}'s comment on event #{event.title} in conference #{conference.short_title}")
end

scenario 'display changes in vote', feature: true, versioning: true, js: true do
conference.program.rating = 1
create(:event, program: conference.program, title: 'My first event')
event = create(:event, program: conference.program, title: 'My second event')
create(:vote, user: organizer, event: event)
Vote.last.destroy
PaperTrail::Version.last.reify.save

visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) voted on event My second event in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted #{organizer.name}'s vote on event #{event.title} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) re-added #{organizer.name}'s vote on event #{event.title} in conference #{conference.short_title}")
end

scenario 'display changes in campaign', feature: true, versioning: true, js: true do
campaign = create(:campaign, conference: conference, name: 'Test Campaign', utm_campaign: 'campaign')
campaign.update_attributes(utm_source: 'source', utm_medium: 'medium', utm_term: 'term', utm_content: 'content')
Expand Down
64 changes: 0 additions & 64 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,70 +169,6 @@
end
end

describe '#user_rating' do
it 'returns 0 if the event has no votes' do
expect(event.user_rating(user)).to eq 0
end

it 'returns 0 if the event has no votes from that user' do
create(:vote, user: another_user, event: event)
expect(event.user_rating(user)).to eq 0
end

it 'returns the rating if the event has votes from that user' do
create(:vote, user: another_user, event: event, rating: 3)
create(:vote, user: user, event: event, rating: 2)
expect(event.user_rating(user)).to eq 2
end
end

describe '#voted?' do
it 'returns false if the event has no votes' do
expect(event.voted?).to eq false
end

it 'returns false if the event has no votes by that user' do
create(:vote, user: another_user, event: event)
expect(event.voted?(user)).to eq false
end

it 'returns true when the event has votes' do
create(:vote, user: another_user, event: event)
expect(event.voted?).to eq true
end

it 'returns true when the event has votes by that user' do
create(:vote, user: user, event: event)
expect(event.voted?(user)).to eq true
end
end

describe '#average_rating' do
context 'returns 0' do
it 'when there are no votes' do
expect(event.average_rating).to eq 0
end
end

context 'returns the average voting' do
before :each do
another_user = create(:user)
create(:vote, user: user, event: event, rating: 1)
create(:vote, user: another_user, event: event, rating: 3)
end

it 'when there are votes and the average is integer' do
expect(event.average_rating).to eq '2'
end

it 'when there are votes and the average is float' do
new_user = create(:user)
create(:vote, user: new_user, event: event, rating: 3)
expect(event.average_rating).to eq '2.33'
end
end
end

describe '#submitter' do
it 'returns the user that submitted the event' do
submitter = create(:user)
Expand Down
12 changes: 3 additions & 9 deletions spec/models/program_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
expect(build(:program)).to be_valid
end

it 'is valid for rating of 5' do
expect(build(:program, rating: 5)).to be_valid
end

it { is_expected.to validate_numericality_of(:rating).is_greater_than_or_equal_to(0).is_less_than_or_equal_to(10).only_integer }

describe 'voting_start_date_before_end_date' do
it 'is valid, when voting_start_date is the same day as voting_end_date' do
expect(build(:program, voting_start_date: Date.today, voting_end_date: Date.today)).to be_valid
Expand Down Expand Up @@ -113,14 +107,14 @@
end

describe '#rating_enabled?' do
it 'returns true if proposals can be rated (program.rating > 0)' do
program.rating = 3
it 'returns true if proposals can be rated ' do
program.rating = true
expect(program.rating_enabled?).to be true
end

it 'returns false if proposals cannot be rated (program.rating == 0) ' do
program = conference.program
program.rating = 0
program.rating = false
expect(program.rating_enabled?).to be false
end
end
Expand Down
1 change: 0 additions & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
it { is_expected.to have_many(:events_registrations).through(:registrations) }
it { is_expected.to have_many(:ticket_purchases).dependent(:destroy) }
it { is_expected.to have_many(:tickets).through(:ticket_purchases) }
it { is_expected.to have_many(:votes).dependent(:destroy) }
it { is_expected.to have_many(:subscriptions).dependent(:destroy) }
end

Expand Down

0 comments on commit 6110406

Please sign in to comment.