* Adds new and edit views for events and removes them from the index view * Fixes formatting issues in /admin/pages/index.html.erb * Refactors /admin/events partial, new, and edit forms * Updates admin_events routes to include all routes except destroy * Refactors Admin::EventsController and adds #new and #edit actions * specs: Adjusts admin_creates_new_event_spec to work with /admin/event changes * Refactors the Admin::EventsController, routes, and events index even further - Adds back placeholder text in Events form - Removes unnecessary code from controller - Reverts changes to routes - Adjusts event_cover_image size on index.html.erb * specs: Adds tests around creating and updating events to events_spec * Adds pagination to Admin::EventsController #index to cap events at 20 per page * Removes .all from Admin::EventsController and adds a line to index.html.erb * Uses crayons classes for _event_form.html.erb
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
require "rails_helper"
|
|
require "date"
|
|
|
|
RSpec.describe "Admin creates new event", type: :system do
|
|
let(:admin) { create(:user, :super_admin) }
|
|
|
|
before do
|
|
sign_in admin
|
|
visit "/admin/events/new"
|
|
end
|
|
|
|
def select_date_and_time(year, month, date, hour, min, field_name)
|
|
select year, from: "event[#{field_name}(1i)]"
|
|
select month, from: "event[#{field_name}(2i)]"
|
|
select date, from: "event[#{field_name}(3i)]"
|
|
select hour, from: "event[#{field_name}(4i)]"
|
|
select min, from: "event[#{field_name}(5i)]"
|
|
end
|
|
|
|
def create_and_publish_event
|
|
fill_in("Title", with: "Workshop Title")
|
|
select_date_and_time(Time.current.year.to_s, "December", "30", "15", "30", "starts_at")
|
|
select_date_and_time(Time.current.year.to_s, "December", "30", "16", "30", "ends_at")
|
|
check("event[published]")
|
|
click_button("Create Event")
|
|
end
|
|
|
|
it "loads /admin/events" do
|
|
expect(page).to have_content("New Event")
|
|
end
|
|
|
|
it "loads published events on /events" do
|
|
create_and_publish_event
|
|
visit "/events"
|
|
|
|
expect(page).to have_content("Workshop Title")
|
|
end
|
|
end
|