Merge master
This commit is contained in:
commit
0b9b100bf3
11 changed files with 58 additions and 40 deletions
|
|
@ -249,7 +249,7 @@ GEM
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
jquery-ui-rails (4.2.1)
|
jquery-ui-rails (4.2.1)
|
||||||
railties (>= 3.2.16)
|
railties (>= 3.2.16)
|
||||||
json (2.2.0)
|
json (2.3.0)
|
||||||
json-schema (2.8.1)
|
json-schema (2.8.1)
|
||||||
addressable (>= 2.4)
|
addressable (>= 2.4)
|
||||||
jsonapi-renderer (0.2.2)
|
jsonapi-renderer (0.2.2)
|
||||||
|
|
@ -302,7 +302,7 @@ GEM
|
||||||
nenv (0.3.0)
|
nenv (0.3.0)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nio4r (2.5.2)
|
nio4r (2.5.2)
|
||||||
nokogiri (1.10.5)
|
nokogiri (1.10.8)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
notiffany (0.1.1)
|
notiffany (0.1.1)
|
||||||
nenv (~> 0.1)
|
nenv (~> 0.1)
|
||||||
|
|
@ -372,7 +372,7 @@ GEM
|
||||||
method_source (~> 0.8.1)
|
method_source (~> 0.8.1)
|
||||||
slop (~> 3.4)
|
slop (~> 3.4)
|
||||||
public_suffix (3.1.1)
|
public_suffix (3.1.1)
|
||||||
puma (3.12.2)
|
puma (3.12.4)
|
||||||
rack (2.0.8)
|
rack (2.0.8)
|
||||||
rack-openid (1.3.1)
|
rack-openid (1.3.1)
|
||||||
rack (>= 1.1.0)
|
rack (>= 1.1.0)
|
||||||
|
|
@ -547,7 +547,7 @@ GEM
|
||||||
actionpack (>= 4.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.4.1)
|
sqlite3 (1.4.2)
|
||||||
stripe (5.14.0)
|
stripe (5.14.0)
|
||||||
stripe-ruby-mock (3.0.1)
|
stripe-ruby-mock (3.0.1)
|
||||||
dante (>= 0.2.0)
|
dante (>= 0.2.0)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ class Vote < ApplicationRecord
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :event
|
belongs_to :event
|
||||||
|
|
||||||
|
validates :user_id, uniqueness: { scope: :event_id }
|
||||||
|
|
||||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||||
|
|
||||||
delegate :name, to: :user
|
delegate :name, to: :user
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ describe Admin::RolesController do
|
||||||
user: { email: 'user1@osem.io' },
|
user: { email: 'user1@osem.io' },
|
||||||
id: 'organizer' }
|
id: 'organizer' }
|
||||||
|
|
||||||
expect(user1.roles).to eq [organizer_role, cfp_role]
|
expect(user1.roles).to contain_exactly(cfp_role, organizer_role)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ describe Admin::RolesController do
|
||||||
user: { email: 'user1@osem.io' },
|
user: { email: 'user1@osem.io' },
|
||||||
id: 'organizer' }
|
id: 'organizer' }
|
||||||
|
|
||||||
expect(user1.roles).to eq [organizer_role, cfp_role]
|
expect(user1.roles).to contain_exactly(cfp_role, organizer_role)
|
||||||
|
|
||||||
post :toggle_user, params: { conference_id: conference.short_title,
|
post :toggle_user, params: { conference_id: conference.short_title,
|
||||||
user: { email: 'user1@osem.io', state: 'false' },
|
user: { email: 'user1@osem.io', state: 'false' },
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ describe Admin::VersionsController do
|
||||||
|
|
||||||
it 'reverts all changes for update actions' do
|
it 'reverts all changes for update actions' do
|
||||||
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
||||||
get :revert_object, params: { id: PaperTrail::Version.last.id }
|
get :revert_object, params: { id: conference.versions.last.id }
|
||||||
conference.reload
|
conference.reload
|
||||||
expect(conference.short_title).to eq 'exampletitle'
|
expect(conference.short_title).to eq 'exampletitle'
|
||||||
expect(conference.description).to eq 'Example Description'
|
expect(conference.description).to eq 'Example Description'
|
||||||
|
|
@ -32,18 +32,19 @@ describe Admin::VersionsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'reverting deletion of object creates it again' do
|
it 'reverting deletion of object creates it again' do
|
||||||
conference.program.event_types.first.destroy
|
event_type = conference.program.event_types.first
|
||||||
|
event_type.destroy
|
||||||
event_types_count = conference.program.event_types.count
|
event_types_count = conference.program.event_types.count
|
||||||
get :revert_object, params: { id: PaperTrail::Version.last.id }
|
get :revert_object, params: { id: event_type.versions.last.id }
|
||||||
conference.reload
|
conference.reload
|
||||||
expect(PaperTrail::Version.last.event).to eq 'create'
|
expect(event_type.versions.last.event).to eq 'create'
|
||||||
expect(conference.program.event_types.count).to eq(event_types_count + 1)
|
expect(conference.program.event_types.count).to eq(event_types_count + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'reverting creation of object deletes it ' do
|
it 'reverting creation of object deletes it ' do
|
||||||
create(:lodging, conference: conference)
|
lodging = create(:lodging, conference: conference)
|
||||||
get :revert_object, params: { id: PaperTrail::Version.last.id }
|
get :revert_object, params: { id: lodging.versions.last.id }
|
||||||
expect(PaperTrail::Version.last.event).to eq 'destroy'
|
expect(lodging.versions.last.event).to eq 'destroy'
|
||||||
expect(Lodging.count).to eq 0
|
expect(Lodging.count).to eq 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ describe Admin::VersionsController do
|
||||||
|
|
||||||
it 'reverts specified change for update actions' do
|
it 'reverts specified change for update actions' do
|
||||||
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
||||||
get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'short_title' }
|
get :revert_attribute, params: { id: conference.versions.last.id, attribute: 'short_title' }
|
||||||
conference.reload
|
conference.reload
|
||||||
expect(conference.short_title).to eq 'exampletitle'
|
expect(conference.short_title).to eq 'exampletitle'
|
||||||
expect(conference.description).to eq 'Some random text'
|
expect(conference.description).to eq 'Some random text'
|
||||||
|
|
@ -71,22 +72,23 @@ describe Admin::VersionsController do
|
||||||
it 'shows correct flash on trying to revert to the current state' do
|
it 'shows correct flash on trying to revert to the current state' do
|
||||||
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
||||||
conference.update_attributes(short_title: 'exampletitle')
|
conference.update_attributes(short_title: 'exampletitle')
|
||||||
get :revert_attribute, params: { id: PaperTrail::Version.all[-2].id, attribute: 'short_title' }
|
get :revert_attribute, params: { id: conference.versions[-2].id, attribute: 'short_title' }
|
||||||
expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to')
|
expect(flash[:error]).to match('The item is already in the state that you are trying to revert it back to')
|
||||||
expect(conference.short_title).to eq 'exampletitle'
|
expect(conference.short_title).to eq 'exampletitle'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails on trying to revert deleted object' do
|
it 'fails on trying to revert deleted object' do
|
||||||
conference.program.event_types.first.update_attributes(title: 'New Event Title')
|
event_type = conference.program.event_types.first
|
||||||
conference.program.event_types.first.destroy
|
event_type.update_attributes(title: 'New Event Title')
|
||||||
get :revert_attribute, params: { id: PaperTrail::Version.all[-2].id, attribute: 'title' }
|
event_type.destroy
|
||||||
|
get :revert_attribute, params: { id: event_type.versions[-2].id, attribute: 'title' }
|
||||||
conference.reload
|
conference.reload
|
||||||
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
|
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails on trying to revert creation event' do
|
it 'fails on trying to revert creation event' do
|
||||||
create(:lodging, conference: conference)
|
lodging = create(:lodging, conference: conference)
|
||||||
get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'name' }
|
get :revert_attribute, params: { id: lodging.versions.last.id, attribute: 'name' }
|
||||||
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
|
expect(flash[:alert]).to eq 'You are not authorized to access this page.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -94,7 +96,7 @@ describe Admin::VersionsController do
|
||||||
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
||||||
before_conference_title = conference.title
|
before_conference_title = conference.title
|
||||||
# Note: even though title is a valid attribute of conference, it was not updated in the change we are trying to revert
|
# Note: even though title is a valid attribute of conference, it was not updated in the change we are trying to revert
|
||||||
get :revert_attribute, params: { id: PaperTrail::Version.last.id, attribute: 'title' }
|
get :revert_attribute, params: { id: conference.versions.last.id, attribute: 'title' }
|
||||||
conference.reload
|
conference.reload
|
||||||
expect(conference.short_title).to eq 'testtitle'
|
expect(conference.short_title).to eq 'testtitle'
|
||||||
expect(conference.description).to eq 'Some random text'
|
expect(conference.description).to eq 'Some random text'
|
||||||
|
|
@ -116,12 +118,12 @@ describe Admin::VersionsController do
|
||||||
@user = create(:user)
|
@user = create(:user)
|
||||||
|
|
||||||
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
conference.update_attributes(short_title: 'testtitle', description: 'Some random text')
|
||||||
@version_organizer = PaperTrail::Version.last
|
@version_organizer = conference.versions.last
|
||||||
create(:cfp, program: conference.program)
|
cfp = create(:cfp, program: conference.program)
|
||||||
@version_cfp = PaperTrail::Version.last
|
@version_cfp = cfp.versions.last
|
||||||
registration = create(:registration, conference: conference)
|
registration = create(:registration, conference: conference)
|
||||||
registration.update_attributes(attended: true)
|
registration.update_attributes(attended: true)
|
||||||
@version_info_desk = PaperTrail::Version.last
|
@version_info_desk = registration.versions.last
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'when user has role cfp' do
|
it 'when user has role cfp' do
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ describe Api::V1::ConferencesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns correct conferences' do
|
it 'returns correct conferences' do
|
||||||
expect(@json[0]['short_title']).to eq('conf_one')
|
expect(@json.pluck('short_title')).to contain_exactly('conf_one', 'conf_two')
|
||||||
expect(@json[1]['short_title']).to eq('conf_two')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,7 @@ describe Api::V1::EventsController do
|
||||||
json = JSON.parse(response.body)['events']
|
json = JSON.parse(response.body)['events']
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
||||||
expect(json.length).to eq(2)
|
expect(json.pluck('title')).to contain_exactly('Conference Event', 'Example Event')
|
||||||
expect(json[0]['title']).to eq('Example Event')
|
|
||||||
expect(json[1]['title']).to eq('Conference Event')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,7 @@ describe Api::V1::RoomsController do
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
||||||
expect(json.length).to eq(2)
|
expect(json.pluck('name')).to contain_exactly('Conference Room', 'Test Room')
|
||||||
expect(json[0]['name']).to eq('Conference Room')
|
|
||||||
expect(json[1]['name']).to eq('Test Room')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,7 @@ describe Api::V1::SpeakersController do
|
||||||
get :index, params: { format: :json }
|
get :index, params: { format: :json }
|
||||||
json = JSON.parse(response.body)['speakers']
|
json = JSON.parse(response.body)['speakers']
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
expect(json.length).to eq(2)
|
expect(json.pluck('name')).to contain_exactly('Conf_Speaker', 'Speaker')
|
||||||
expect(json[0]['name']).to eq('Speaker')
|
|
||||||
expect(json[1]['name']).to eq('Conf_Speaker')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,7 @@ describe Api::V1::TracksController do
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
||||||
expect(json.length).to eq(2)
|
expect(json.pluck('name')).to contain_exactly('Conference Track', 'Test Track')
|
||||||
expect(json[0]['name']).to eq('Conference Track')
|
|
||||||
expect(json[1]['name']).to eq('Test Track')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ feature Role do
|
||||||
scenario "removes role #{role_name}", feature: true, js: true do
|
scenario "removes role #{role_name}", feature: true, js: true do
|
||||||
click_link('Users', href: admin_conference_role_path(conference.short_title, role_name))
|
click_link('Users', href: admin_conference_role_path(conference.short_title, role_name))
|
||||||
|
|
||||||
bootstrap_switch = first('td').find('.bootstrap-switch-container')
|
bootstrap_switch = find('tr', text: user_with_role.name).find('.bootstrap-switch-container')
|
||||||
bootstrap_switch.click
|
bootstrap_switch.click
|
||||||
|
|
||||||
expect(page).to have_css('.alert', text: "Successfully removed role #{role_name} from user #{user_with_role.email}")
|
expect(page).to have_css('.alert', text: "Successfully removed role #{role_name} from user #{user_with_role.email}")
|
||||||
|
|
|
||||||
23
spec/models/vote_spec.rb
Normal file
23
spec/models/vote_spec.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Vote do
|
||||||
|
let!(:vote) { create(:vote) }
|
||||||
|
|
||||||
|
describe 'validation' do
|
||||||
|
it 'has a valid factory' do
|
||||||
|
expect(build(:vote)).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to(:event_id) }
|
||||||
|
|
||||||
|
# This is testing the relationship instead of using the shoulda-matchers
|
||||||
|
context 'vote with user already exists' do
|
||||||
|
it 'fails when adding vote twice for user and event' do
|
||||||
|
expect { create(:vote, user: vote.user, event: vote.event) }
|
||||||
|
.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: User has already been taken')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue