docbrown/spec/requests/events_spec.rb
Molly Struve b40af82b66
Flaky Spec Fix:Remove let_it_be Test Prof Helper (#9556)
* Flaky Spec Fix:Remove let_it_be Test Prof Helper

* Spec cleanup and fixes
2020-07-29 11:31:01 +02:00

33 lines
871 B
Ruby

require "rails_helper"
RSpec.describe "Events", type: :request do
let(:event) { create(:event, published: true) }
describe "GET events" do
it "returns index page" do
event
get "/events"
expect(response.body).to include("#{community_name} EVENTS")
expect(response.body).to include(event.title)
end
it "does not include unpublished events" do
unpublished_event = create(:event, published: false)
get "/events"
expect(response.body).not_to include(unpublished_event.title)
end
end
describe "GET events#show" do
it "returns event show page" do
get "/events/#{event.slug}"
expect(response.body).to include event.title
end
it "renders not_found" do
expect do
get "/events/NotSlug-#{event.slug}"
end.to raise_error(ActiveRecord::RecordNotFound)
end
end
end