Merge pull request #119 from ChrisBr/event_workflow_test
Event workflow feature test
This commit is contained in:
commit
5f6ab4f7ee
6 changed files with 78 additions and 20 deletions
|
|
@ -108,32 +108,33 @@
|
||||||
- if event.transition_possible? :accept
|
- if event.transition_possible? :accept
|
||||||
%li= link_to 'Accept event',
|
%li= link_to 'Accept event',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept),
|
update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept),
|
||||||
method: :patch
|
method: :patch, id: "accept_event_#{event.id}"
|
||||||
- if @conference.email_settings.send_on_accepted?
|
- if @conference.email_settings.send_on_accepted?
|
||||||
%li= link_to 'Accept event (without email)',
|
%li= link_to 'Accept event (without email)',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: false),
|
update_state_admin_conference_event_path(@conference.short_title, event, transition: :accept, send_mail: false),
|
||||||
method: :patch, hint: 'Accept this event without sending an automated email.'
|
method: :patch, hint: 'Accept this event without sending an automated email.',
|
||||||
|
id: "accept_event_without_mail_#{event.id}"
|
||||||
- if event.transition_possible? :reject
|
- if event.transition_possible? :reject
|
||||||
%li= link_to 'Reject event',
|
%li= link_to 'Reject event',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject),
|
update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject),
|
||||||
method: :patch, confirm: 'Are you sure?'
|
method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}"
|
||||||
- if @conference.email_settings.send_on_rejected?
|
- if @conference.email_settings.send_on_rejected?
|
||||||
%li= link_to 'Reject event (without email)',
|
%li= link_to 'Reject event (without email)',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: false),
|
update_state_admin_conference_event_path(@conference.short_title, event, transition: :reject, send_mail: false),
|
||||||
method: :patch, confirm: 'Are you sure?'
|
method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}"
|
||||||
- if event.transition_possible? :start_review
|
- if event.transition_possible? :start_review
|
||||||
%li= link_to 'Start review',
|
%li= link_to 'Start review',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, transition: :start_review),
|
update_state_admin_conference_event_path(@conference.short_title, event, transition: :start_review),
|
||||||
method: :patch
|
method: :patch, id: "review_event_#{event.id}"
|
||||||
- if event.transition_possible? :confirm
|
- if event.transition_possible? :confirm
|
||||||
%li= link_to 'Confirm event',
|
%li= link_to 'Confirm event',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, transition: :confirm),
|
update_state_admin_conference_event_path(@conference.short_title, event, transition: :confirm),
|
||||||
method: :patch,
|
method: :patch, id: "confirm_event_#{event.id}",
|
||||||
hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.'
|
hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.'
|
||||||
- if event.transition_possible? :cancel
|
- if event.transition_possible? :cancel
|
||||||
%li= link_to 'Cancel event',
|
%li= link_to 'Cancel event',
|
||||||
update_state_admin_conference_event_path(@conference.short_title, event, :transition => :cancel),
|
update_state_admin_conference_event_path(@conference.short_title, event, :transition => :cancel),
|
||||||
method: :patch,
|
method: :patch, id: "cancel_event_#{event.id}",
|
||||||
hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.'
|
hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.'
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :put }) do |f|
|
= semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :patch }) do |f|
|
||||||
.tabbable
|
.tabbable
|
||||||
%ul.nav.nav-tabs
|
%ul.nav.nav-tabs
|
||||||
%li.active
|
%li.active
|
||||||
|
|
@ -19,4 +19,4 @@
|
||||||
= link_to "Unregister", register_conference_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
|
= link_to "Unregister", register_conference_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
|
||||||
:confirm => "Are you sure you want to unregister?"
|
:confirm => "Are you sure you want to unregister?"
|
||||||
- else
|
- else
|
||||||
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary" }
|
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,10 @@
|
||||||
.pull-right
|
.pull-right
|
||||||
- if event.transition_possible? :confirm
|
- if event.transition_possible? :confirm
|
||||||
= link_to 'Confirm',
|
= link_to 'Confirm',
|
||||||
conference_proposal_confirm_path(@conference.short_title, event, send_mail: false), method: :patch, class: 'btn btn-mini btn-success'
|
conference_proposal_confirm_path(@conference.short_title, event, send_mail: false),
|
||||||
= link_to 'Edit', edit_conference_proposal_path(@conference.short_title, event.id), class: 'btn btn-mini btn-primary'
|
method: :patch, class: 'btn btn-mini btn-success', id: "confirm_proposal_#{event.id}"
|
||||||
|
= link_to 'Edit', edit_conference_proposal_path(@conference.short_title, event.id),
|
||||||
|
class: 'btn btn-mini btn-primary', id: "edit_proposal_#{event.id}"
|
||||||
= link_to 'Withdraw', conference_proposal_path(@conference.short_title, event.id), method: :delete,
|
= link_to 'Withdraw', conference_proposal_path(@conference.short_title, event.id), method: :delete,
|
||||||
confirm: 'Are you sure you want to withdraw this proposal?', class: 'btn btn-mini btn-danger'
|
confirm: 'Are you sure you want to withdraw this proposal?', class: 'btn btn-mini btn-danger',
|
||||||
|
id: "delete_proposal_#{event.id}"
|
||||||
|
|
|
||||||
10
spec/factories/email_settings.rb
Normal file
10
spec/factories/email_settings.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :email_settings do
|
||||||
|
send_on_registration false
|
||||||
|
send_on_accepted false
|
||||||
|
send_on_rejected false
|
||||||
|
send_on_confirmed_without_registration false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,20 +1,26 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature Event do
|
feature Event do
|
||||||
|
|
||||||
# It is necessary to use bang version of let to build roles before user
|
# It is necessary to use bang version of let to build roles before user
|
||||||
let!(:organizer_role) { create(:organizer_role) }
|
let!(:organizer_role) { create(:organizer_role) }
|
||||||
let!(:participant_role) { create(:participant_role) }
|
let!(:participant_role) { create(:participant_role) }
|
||||||
let!(:admin_role) { create(:admin_role) }
|
let!(:admin_role) { create(:admin_role) }
|
||||||
|
|
||||||
shared_examples 'participant' do |user|
|
shared_examples 'proposal workflow' do
|
||||||
scenario 'submitts a new proposal and updates account', feature: true, js: true do
|
scenario 'submitts a proposal, accepts and confirms',
|
||||||
|
feature: true, js: true do
|
||||||
|
|
||||||
|
admin = create(:admin, email: 'admin@example.com')
|
||||||
|
participant = create(:participant, email: 'participant@example.com')
|
||||||
|
|
||||||
expected_count = Event.count + 1
|
expected_count = Event.count + 1
|
||||||
conference = create(:conference)
|
conference = create(:conference)
|
||||||
conference.call_for_papers = create(:call_for_papers)
|
conference.call_for_papers = create(:call_for_papers)
|
||||||
|
conference.email_settings = create(:email_settings)
|
||||||
conference.event_types = [create(:event_type)]
|
conference.event_types = [create(:event_type)]
|
||||||
|
|
||||||
sign_in create(user)
|
# Submit a new proposal as participant
|
||||||
|
sign_in participant
|
||||||
|
|
||||||
visit conference_proposal_index_path(conference.short_title)
|
visit conference_proposal_index_path(conference.short_title)
|
||||||
click_link 'New Proposal'
|
click_link 'New Proposal'
|
||||||
|
|
@ -38,6 +44,7 @@ feature Event do
|
||||||
|
|
||||||
fill_in 'user_person_attributes_first_name', with: 'Example'
|
fill_in 'user_person_attributes_first_name', with: 'Example'
|
||||||
fill_in 'user_person_attributes_last_name', with: 'User'
|
fill_in 'user_person_attributes_last_name', with: 'User'
|
||||||
|
fill_in 'user_person_attributes_biography', with: 'Lorem ipsum biography'
|
||||||
|
|
||||||
click_button 'Update'
|
click_button 'Update'
|
||||||
|
|
||||||
|
|
@ -45,12 +52,43 @@ feature Event do
|
||||||
to eq('You updated your account successfully.')
|
to eq('You updated your account successfully.')
|
||||||
|
|
||||||
expect(Event.count).to eq(expected_count)
|
expect(Event.count).to eq(expected_count)
|
||||||
|
|
||||||
|
event = Event.where(title: 'Example Proposal').first
|
||||||
|
|
||||||
|
visit conference_proposal_index_path(conference.short_title)
|
||||||
|
expect(page.has_content?('Example Proposal')).to be true
|
||||||
|
|
||||||
|
sign_out
|
||||||
|
|
||||||
|
# Accept proposal as admin
|
||||||
|
sign_in admin
|
||||||
|
|
||||||
|
visit admin_conference_events_path(conference.short_title)
|
||||||
|
expect(page.has_content?('Example Proposal')).to be true
|
||||||
|
|
||||||
|
click_link 'New'
|
||||||
|
click_link "accept_event_#{event.id}"
|
||||||
|
|
||||||
|
expect(page.has_content?('Unconfirmed')).to be true
|
||||||
|
sign_out
|
||||||
|
|
||||||
|
# Confirm proposal as participant
|
||||||
|
sign_in participant
|
||||||
|
visit conference_proposal_index_path(conference.short_title)
|
||||||
|
expect(page.has_content?('Example Proposal')).to be true
|
||||||
|
expect(page.has_content?('Accepted (confirmation pending)')).to be true
|
||||||
|
click_link "confirm_proposal_#{event.id}"
|
||||||
|
expect(page.find('#flash_notice').text).
|
||||||
|
to eq('Event was confirmed. Please register to attend the conference.')
|
||||||
|
|
||||||
|
find('#register').click
|
||||||
|
|
||||||
|
expect(page.find('#flash_notice').text).
|
||||||
|
to eq('You are now registered.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'participant' do
|
describe 'proposal' do
|
||||||
it_behaves_like 'participant', :participant
|
it_behaves_like 'proposal workflow'
|
||||||
it_behaves_like 'participant', :organizer
|
|
||||||
it_behaves_like 'participant', :admin
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,10 @@ module LoginMacros
|
||||||
|
|
||||||
expect(page.has_content?('Signed in successfully')).to be true
|
expect(page.has_content?('Signed in successfully')).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_out
|
||||||
|
Capybara.current_session.driver.browser.clear_cookies
|
||||||
|
visit root_path
|
||||||
|
expect(page.has_content?('Sign In')).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue