* 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
52 lines
1.3 KiB
Ruby
52 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "/admin/events", type: :request do
|
|
let(:event) { create(:event, title: "Hey") }
|
|
let(:admin) { create(:user, :super_admin) }
|
|
let(:params) do
|
|
{
|
|
event: {
|
|
title: "Hello, world!",
|
|
description_markdown: "This is an event",
|
|
starts_at: Time.current,
|
|
ends_at: 3660.seconds.from_now,
|
|
category: "Talk"
|
|
}
|
|
}
|
|
end
|
|
|
|
describe "PUT admin/events" do
|
|
before do
|
|
sign_in(admin)
|
|
end
|
|
|
|
it "marks an event as not live now" do
|
|
event.update(live_now: true)
|
|
patch "/admin/events/#{event.id}", params: { event: { live_now: "0" } }
|
|
expect(event.reload.live_now).to eq false
|
|
end
|
|
|
|
it "marks an event as live now" do
|
|
patch "/admin/events/#{event.id}", params: { event: { live_now: "1" } }
|
|
expect(event.reload.live_now).to eq true
|
|
end
|
|
|
|
it "successfully updates the event title" do
|
|
expect do
|
|
patch "/admin/events/#{event.id}", params: params
|
|
end.to change { event.reload.title }.to("Hello, world!")
|
|
end
|
|
end
|
|
|
|
describe "POST /admin/events" do
|
|
let(:post_resource) { post "/admin/events", params: params }
|
|
|
|
before { sign_in admin }
|
|
|
|
it "successfully creates an event" do
|
|
expect do
|
|
post_resource
|
|
end.to change { Event.all.count }.by(1)
|
|
end
|
|
end
|
|
end
|