clarion/spec/support/feature_helpers.rb

133 lines
5.3 KiB
Ruby
Raw Normal View History

2018-11-11 00:07:00 +02:00
module FeatureHelpers
def sign_in_as_admin
visit management_root_path
2019-04-28 21:10:54 +03:00
within "section.content" do
fill_in User.human_attribute_name(:email), with: "foo@example.com"
fill_in User.human_attribute_name(:password), with: "123qweASD"
2018-11-11 00:07:00 +02:00
click_on I18n.t(:login)
end
end
def create_new_conference(title = "FooConf #{1.year.from_now.year}",
2019-04-28 21:10:54 +03:00
host_name: "www.example.com",
planned_cfp_end_date: 1.year.from_now,
start_date: 1.year.from_now + 1.day,
end_date: 1.year.from_now + 2.days)
click_on I18n.t("actions.create.button", model: Conference.model_name.human)
2018-11-11 00:07:00 +02:00
fill_in Conference.human_attribute_name(:title), with: title
2019-04-28 21:10:54 +03:00
fill_in Conference.human_attribute_name(:email), with: "foo@example.com"
2018-11-11 00:07:00 +02:00
fill_in Conference.human_attribute_name(:host_name), with: host_name
2019-04-28 21:10:54 +03:00
select planned_cfp_end_date.year.to_s, from: "conference[planned_cfp_end_date(1i)]"
select I18n.t("date.month_names")[planned_cfp_end_date.month], from: "conference[planned_cfp_end_date(2i)]"
select planned_cfp_end_date.day.to_s, from: "conference[planned_cfp_end_date(3i)]"
2018-11-11 00:07:00 +02:00
2019-04-28 21:10:54 +03:00
select start_date.year.to_s, from: "conference[start_date(1i)]"
select I18n.t("date.month_names")[start_date.month], from: "conference[start_date(2i)]"
select start_date.day.to_s, from: "conference[start_date(3i)]"
2018-11-11 00:07:00 +02:00
2019-04-28 21:10:54 +03:00
select end_date.year.to_s, from: "conference[end_date(1i)]"
select I18n.t("date.month_names")[end_date.month], from: "conference[end_date(2i)]"
select end_date.day.to_s, from: "conference[end_date(3i)]"
2018-11-11 00:07:00 +02:00
2019-04-28 21:10:54 +03:00
within ".form-group.conference_description" do
fill_in Conference.human_attribute_name(:description), with: "Lorem"
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
within "#event_types" do
fill_in EventType.human_attribute_name(:description), with: "Lorem"
fill_in EventType.human_attribute_name(:minimum_length), with: "45"
fill_in EventType.human_attribute_name(:maximum_length), with: "45"
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
within "#tracks" do
fill_in Track.human_attribute_name(:description), with: "Lorem"
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
within "#volunteer_teams" do
fill_in VolunteerTeam.human_attribute_name(:description), with: "Lorem"
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
page.find(".btn.btn-primary").click
2018-11-11 00:07:00 +02:00
2019-04-28 21:10:54 +03:00
click_on I18n.t("management.conferences.show.cfp_status")
2018-11-11 00:07:00 +02:00
end
def sign_out
2019-04-28 21:10:54 +03:00
click_on I18n.t("sessions.sign_out")
2018-11-11 00:07:00 +02:00
end
def register_a_new_user(visit_registration_path = true)
if visit_registration_path
2019-04-28 21:10:54 +03:00
click_on I18n.t("sessions.sign_in")
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
fill_in User.human_attribute_name(:email), with: "bar@example.com"
fill_in User.human_attribute_name(:password), with: "123qweASD"
fill_in User.human_attribute_name(:password_confirmation), with: "123qweASD"
2018-11-11 00:07:00 +02:00
2019-04-28 21:10:54 +03:00
within ".form-actions" do
page.find(".btn").click
2018-11-11 00:07:00 +02:00
end
visit(user_confirmation_path + "?confirmation_token=" + User.order(created_at: :desc).first.confirmation_token)
end
def sign_in_as_an_existing_user(visit_sign_in_path = true)
if visit_sign_in_path
2019-04-28 21:10:54 +03:00
click_on I18n.t("sessions.sign_in")
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
within "section.content" do
fill_in User.human_attribute_name(:email), with: "bar@example.com"
fill_in User.human_attribute_name(:password), with: "123qweASD"
2018-11-11 00:07:00 +02:00
click_on I18n.t(:login)
end
end
def submit_an_event_proposition(visit_event_submission_path = true)
if visit_event_submission_path
visit root_path
2019-04-28 21:10:54 +03:00
click_on I18n.t("views.welcome.submit_event", event_type: Conference.first.event_types.first.name.downcase)
2018-11-11 00:07:00 +02:00
end
2019-04-28 21:10:54 +03:00
fill_in Event.human_attribute_name(:title), with: "This is just a sample title of an event"
2018-11-11 00:07:00 +02:00
select Conference.first.tracks.first.name, from: Event.human_attribute_name(:track)
2019-04-28 21:10:54 +03:00
fill_in Event.human_attribute_name(:length), with: "45"
fill_in Event.human_attribute_name(:abstract), with: "Lorem"
fill_in Event.human_attribute_name(:description), with: "Ipsum"
2018-11-11 00:07:00 +02:00
check Event.human_attribute_name(:agreement)
2019-04-28 21:10:54 +03:00
click_on I18n.t("helpers.submit.event.create")
2018-11-11 00:07:00 +02:00
end
def fill_in_personal_profile
2019-04-28 21:10:54 +03:00
attach_file PersonalProfile.human_attribute_name(:picture), Rails.root.join("spec", "support", "picture.jpg")
fill_in PersonalProfile.human_attribute_name(:first_name), with: "Foo"
fill_in PersonalProfile.human_attribute_name(:last_name), with: "Bar"
fill_in PersonalProfile.human_attribute_name(:mobile_phone), with: "+359883123456"
2019-04-28 21:10:54 +03:00
fill_in PersonalProfile.human_attribute_name(:biography), with: "Lorem"
2018-11-11 00:07:00 +02:00
2019-04-28 21:10:54 +03:00
click_on I18n.t("helpers.submit.create", model: PersonalProfile.model_name.human)
2018-11-11 00:07:00 +02:00
end
2019-01-08 00:20:31 +02:00
def fill_in_volunteer_profile
2019-04-28 21:10:54 +03:00
attach_file Volunteer.human_attribute_name(:picture), Rails.root.join("spec", "support", "picture.jpg")
fill_in Volunteer.human_attribute_name(:name), with: "Volunteer Foo"
fill_in Volunteer.human_attribute_name(:email), with: "foo@example.com"
fill_in Volunteer.human_attribute_name(:phone), with: "+359666666"
choose VolunteerTeam.first.name
2019-01-08 00:20:31 +02:00
2019-04-28 21:10:54 +03:00
click_on I18n.t("helpers.submit.volunteer.create")
2019-01-08 00:20:31 +02:00
end
2018-11-11 00:07:00 +02:00
def verify_the_event_is_submitted
sign_in_as_admin
2019-01-08 17:33:19 +02:00
click_on_first_conference_in_management_root
2019-04-28 00:52:31 +03:00
click_on Event.model_name.human(count: 2).capitalize
2019-04-28 21:10:54 +03:00
expect(page).to have_content "This is just a sample title of an event"
2018-11-11 00:07:00 +02:00
end
2019-01-08 17:33:19 +02:00
def click_on_first_conference_in_management_root
2019-04-28 21:10:54 +03:00
click_on I18n.t("actions.view.button", model: Conference.model_name.human), match: :first
2019-01-08 17:33:19 +02:00
end
2018-11-11 00:07:00 +02:00
end