Merge pull request #200 from gopesht/add_sponsorship_levels
Adds sponsorship levels
This commit is contained in:
commit
411deb4c65
13 changed files with 159 additions and 10 deletions
8
spec/factories/sponsorship_levels.rb
Normal file
8
spec/factories/sponsorship_levels.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :sponsorship_level do
|
||||
title 'Platin'
|
||||
conference
|
||||
end
|
||||
end
|
||||
46
spec/features/sponsorship_level_spec.rb
Normal file
46
spec/features/sponsorship_level_spec.rb
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature SponsorshipLevel do
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let!(:organizer_role) { create(:organizer_role) }
|
||||
let!(:participant_role) { create(:participant_role) }
|
||||
let!(:admin_role) { create(:admin_role) }
|
||||
|
||||
shared_examples 'sponsorship levels' do |user|
|
||||
scenario 'adds and updates sponsorship level', feature: true, js: true do
|
||||
conference = create(:conference)
|
||||
sign_in create(user)
|
||||
visit admin_conference_sponsorship_levels_path(
|
||||
conference_id: conference.short_title)
|
||||
# Add sponsorship level
|
||||
click_link 'Add sponsorship_level'
|
||||
expect(page.all('div.nested-fields').count == 1).to be true
|
||||
|
||||
page.
|
||||
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
|
||||
set('Example sponsorship level')
|
||||
|
||||
click_button 'Update Conference'
|
||||
|
||||
# Validations
|
||||
expect(flash).to eq('Sponsorship levels were successfully updated.')
|
||||
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
|
||||
value).to eq('Example sponsorship level')
|
||||
|
||||
# Remove sponsorship level
|
||||
click_link 'Remove sponsorship_level'
|
||||
expect(page.all('div.nested-fields').count == 0).to be true
|
||||
click_button 'Update Conference'
|
||||
expect(flash).to eq('Sponsorship levels were successfully updated.')
|
||||
expect(page.all('div.nested-fields').count == 0).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin' do
|
||||
it_behaves_like 'sponsorship levels', :admin
|
||||
end
|
||||
|
||||
describe 'organizer' do
|
||||
it_behaves_like 'sponsorship levels', :organizer
|
||||
end
|
||||
end
|
||||
14
spec/models/sponsorship_level_spec.rb
Normal file
14
spec/models/sponsorship_level_spec.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SponsorshipLevel do
|
||||
describe 'validations' do
|
||||
|
||||
it 'has a valid factory' do
|
||||
expect(build(:sponsorship_level)).to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid without a title' do
|
||||
should validate_presence_of(:title)
|
||||
end
|
||||
end
|
||||
end
|
||||
10
spec/views/admin/sponsorship_levels/index.html.haml_spec.rb
Normal file
10
spec/views/admin/sponsorship_levels/index.html.haml_spec.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/sponsorship_levels/index' do
|
||||
it 'renders sponsorship levels' do
|
||||
@sponsorship_level = create(:sponsorship_level)
|
||||
assign :conference, @sponsorship_level.conference
|
||||
render
|
||||
expect(rendered).to include('Platin')
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue