From a784c4b45a65b0509cb33e5e3aa7178f87cc0182 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Tue, 8 Jan 2019 00:20:31 +0200 Subject: [PATCH] Introduce a Volunteering feature spec --- spec/features/volunteership_spec.rb | 18 ++++++++++++++++++ spec/support/feature_helpers.rb | 10 ++++++++++ 2 files changed, 28 insertions(+) create mode 100644 spec/features/volunteership_spec.rb diff --git a/spec/features/volunteership_spec.rb b/spec/features/volunteership_spec.rb new file mode 100644 index 0000000..526e2a2 --- /dev/null +++ b/spec/features/volunteership_spec.rb @@ -0,0 +1,18 @@ +require "rails_helper" + +feature 'Volunteering' do + before do + Rails.application.load_seed + sign_in_as_admin + create_new_conference + sign_out + end + + scenario 'A user applies to be a volunteer for the upcoming conference' do + visit root_path + click_on I18n.t('views.volunteers.apply') + + fill_in_volunteer_profile + expect(page).to have_content I18n.t('views.volunteers.successful_application') + end +end diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index ef37d58..9a4b47b 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -111,6 +111,16 @@ module FeatureHelpers click_on I18n.t('helpers.submit.create', model: PersonalProfile.model_name.human) end + def fill_in_volunteer_profile + attach_file Volunteer.human_attribute_name(:picture), Rails.root.join('spec', 'support', 'picture.jpg') + fill_in Volunteer.human_attribute_name(:name), with: 'Foo' + fill_in Volunteer.human_attribute_name(:email), with: 'foo@example.com' + fill_in Volunteer.human_attribute_name(:phone), with: '+359666666' + check VolunteerTeam.first.name + + click_on I18n.t('helpers.submit.volunteer.create') + end + def verify_the_event_is_submitted sign_in_as_admin click_on I18n.t('actions.view.button', model: Conference.model_name.human), match: :first