Sponsor dashboard added, with sponsor component for splash page
This commit is contained in:
parent
643b8b173a
commit
ea119a8158
36 changed files with 549 additions and 12 deletions
|
|
@ -9,5 +9,10 @@ FactoryGirl.define do
|
|||
contact_email 'admin@example.com'
|
||||
start_date Date.today
|
||||
end_date Date.tomorrow
|
||||
factory :conference_with_sponsorship_level do
|
||||
after(:build) do |conference|
|
||||
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
9
spec/factories/organizations.rb
Normal file
9
spec/factories/organizations.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :organization do
|
||||
title 'Example Organization'
|
||||
sequence(:email_id) { |n| "example#{n}@example.com" }
|
||||
website_url 'www.example.com'
|
||||
end
|
||||
end
|
||||
9
spec/factories/sponsorship_levels.rb
Normal file
9
spec/factories/sponsorship_levels.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :sponsorship_level do
|
||||
title 'Platin'
|
||||
description 'Lorem Ipsum'
|
||||
conference
|
||||
end
|
||||
end
|
||||
19
spec/factories/sponsorship_registrations.rb
Normal file
19
spec/factories/sponsorship_registrations.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :sponsorship_registration do
|
||||
name 'Example Person'
|
||||
sequence(:email_id) { |n| "example#{n}@example.com" }
|
||||
contact_no '90000000000'
|
||||
amount_donated '$1,00,000'
|
||||
method_of_donation 'Cheque'
|
||||
conference
|
||||
sponsorship_level
|
||||
organization
|
||||
after(:build) do |sponsorship_registration|
|
||||
sponsorship_registration.sponsorship_level =
|
||||
build(:sponsorship_level,
|
||||
conference: sponsorship_registration.conference)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
FactoryGirl.define do
|
||||
factory :user do
|
||||
email 'example@example.com'
|
||||
sequence(:email) { |n| "example#{n}@example.com" }
|
||||
password 'changeme'
|
||||
password_confirmation 'changeme'
|
||||
confirmed_at Time.now
|
||||
|
|
|
|||
52
spec/features/sponsorship_levels_spec.rb
Normal file
52
spec/features/sponsorship_levels_spec.rb
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
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')
|
||||
|
||||
page.
|
||||
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
|
||||
set('Lorem Ipsum Dolsum')
|
||||
|
||||
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')
|
||||
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
|
||||
value).to eq('Lorem Ipsum Dolsum')
|
||||
|
||||
# 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
|
||||
21
spec/models/organization_spec.rb
Normal file
21
spec/models/organization_spec.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Organization do
|
||||
describe 'validations' do
|
||||
it 'has a valid factory' do
|
||||
expect(build(:organization)).to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid without a title' do
|
||||
should validate_presence_of(:title)
|
||||
end
|
||||
|
||||
it 'is not valid without a email id' do
|
||||
should validate_presence_of(:email_id)
|
||||
end
|
||||
|
||||
it 'is not valid with a duplicate email_id' do
|
||||
should validate_uniqueness_of(:email_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
12
spec/models/sponsorship_level_spec.rb
Normal file
12
spec/models/sponsorship_level_spec.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SponsorshipLevel do
|
||||
describe 'validations' do
|
||||
it 'it has 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
|
||||
41
spec/models/sponsorship_registration_spec.rb
Normal file
41
spec/models/sponsorship_registration_spec.rb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SponsorshipRegistration do
|
||||
describe 'validations' do
|
||||
it 'has a valid factory' do
|
||||
expect(build(:sponsorship_registration)).to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid without a name' do
|
||||
should validate_presence_of(:name)
|
||||
end
|
||||
|
||||
it 'is not valid without a email_id' do
|
||||
should validate_presence_of(:email_id)
|
||||
end
|
||||
|
||||
it 'is not valid without a contact number' do
|
||||
should validate_presence_of(:contact_no)
|
||||
end
|
||||
|
||||
it 'is not valid without a amount donated' do
|
||||
should validate_presence_of(:amount_donated)
|
||||
end
|
||||
|
||||
it 'is not valid without a method of donation' do
|
||||
should validate_presence_of(:method_of_donation)
|
||||
end
|
||||
|
||||
it 'is not valid without a sponsorship level' do
|
||||
should validate_presence_of(:sponsorship_level)
|
||||
end
|
||||
|
||||
it 'is not valid without a organization' do
|
||||
should validate_presence_of(:organization)
|
||||
end
|
||||
|
||||
it 'is not valid without a conference' do
|
||||
should validate_presence_of(:conference)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
require 'spec_helper'
|
||||
describe 'conference/show.html.haml' do
|
||||
it 'renders conference details' do
|
||||
@conference = create(:conference)
|
||||
@sponsorship_registration = create(:sponsorship_registration)
|
||||
@conference = @sponsorship_registration.conference
|
||||
assign :conference, @conference
|
||||
render
|
||||
expect(render).to include("#{@conference.title}")
|
||||
expect(view).to render_template(:partial => "conference/_sponsor")
|
||||
expect(rendered).to include("#{@sponsorship_registration.sponsorship_level.title}")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue