Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions spec/system/facilitator_submits_workshop_idea_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

require 'rails_helper'

RSpec.describe "Facilitators can submit a workshop idea", type: :system do
describe "Navigate to Workshop Idea page" do
context "When Facilitator is logged in" do
before do
create(:windows_type, :adult)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diti0-dot we used to have to do this bc of a callback dependency, but we've removed that, so your tests should still pass even if you remove these create(:windows_type) statements

create(:windows_type, :children)
create(:windows_type, :combined)

user = create(:user)
create(:facilitator, user: user)
sign_in user

visit new_workshop_idea_path
end

it "shows the new workshop form" do
expect(page).to have_content("New Workshop idea")
end

it "submits the form when clicking Submit" do
fill_in 'workshop_idea_title', with: 'My Amazing Workshop'
select 'ADULT WINDOWS', from: 'workshop_idea_windows_type_id'
# select 'Adult', from:'workshop_idea_age_range'
fill_in 'workshop_idea_objective', with: 'Learn something new'
fill_in 'workshop_idea_description', with: 'This is a test workshop description.'
fill_in 'workshop_idea_materials', with: 'Paper, markers'
fill_in 'workshop_idea_optional_materials', with: 'Scissors, glue'
fill_in 'workshop_idea_setup', with: 'Arrange tables'
fill_in 'workshop_idea_introduction', with: 'Start with a story'
fill_in 'workshop_idea_time_intro', with: 10
fill_in 'workshop_idea_opening_circle', with: 'Welcome and warm up'
fill_in 'workshop_idea_time_opening_circle', with: 5
fill_in 'workshop_idea_demonstration', with: 'Show how it works'
fill_in 'workshop_idea_time_demonstration', with: 15
fill_in 'workshop_idea_warm_up', with: 'Stretching and breathing'
fill_in 'workshop_idea_time_warm_up', with: 5
fill_in 'workshop_idea_creation', with: 'Hands-on creation'
fill_in 'workshop_idea_time_creation', with: 30
fill_in 'workshop_idea_closing', with: 'Reflection and clean up'
fill_in 'workshop_idea_time_closing', with: 10
fill_in 'workshop_idea_notes', with: 'Some notes'
fill_in 'workshop_idea_tips', with: 'Some tips'
attach_file('workshop_primary_media', Rails.root.join('spec/fixtures/some_file.png')) if page.has_field?('workshop_idea_primary_asset_attributes_file')
# Submit
click_button 'Submit'
expect(page).to have_content('Workshop idea was successfully created')
end

it "cancels the form when clicking Cancel" do
fill_in 'workshop_idea_title', with: 'My unsubmitted Workshop'
select 'ADULT WINDOWS', from: 'workshop_idea_windows_type_id'
# select 'Adult', from:'workshop_idea_age_range'
fill_in 'workshop_idea_objective', with: 'Learn nothing new'
fill_in 'workshop_idea_description', with: 'This is a test workshop description.'
fill_in 'workshop_idea_materials', with: 'Paper, markers'
fill_in 'workshop_idea_optional_materials', with: 'Scissors, glue'
fill_in 'workshop_idea_setup', with: 'Arrange tables'
fill_in 'workshop_idea_introduction', with: 'Start with a story'
fill_in 'workshop_idea_time_intro', with: 10
fill_in 'workshop_idea_opening_circle', with: 'Welcome and warm up'
fill_in 'workshop_idea_time_opening_circle', with: 5
fill_in 'workshop_idea_demonstration', with: 'Show how it works'
fill_in 'workshop_idea_time_demonstration', with: 15
fill_in 'workshop_idea_warm_up', with: 'Stretching and breathing'
fill_in 'workshop_idea_time_warm_up', with: 5
fill_in 'workshop_idea_creation', with: 'Hands-on creation'
fill_in 'workshop_idea_time_creation', with: 30
fill_in 'workshop_idea_closing', with: 'Reflection and clean up'
fill_in 'workshop_idea_time_closing', with: 10
fill_in 'workshop_idea_notes', with: 'Some notes'
fill_in 'workshop_idea_tips', with: 'Some tips'
attach_file('workshop_primary_media', Rails.root.join('spec/fixtures/some_file.png')) if page.has_field?('workshop_idea_primary_asset_attributes_file')
# Cancel
click_link 'Cancel'
expect(page).to have_content('Featured Workshops')
expect(page).to have_content('Community News')
end
end
end
end