docbrown/spec/requests/resource_admin/podcasts_spec.rb
Josh Puetz 1c566e0ec4
[deploy] Move /internal to `/admin (#9639)
* First draft - all the big changes

* Changing some more references to 'internal'

* Relocate internal request tests to admin

* Relocate internal system tests to admin

* Fix trailing space

* Test fix

* Move queries from internal to admin

* Docs updates

* Rename internal stimuls controllers to admin (plus docs)

* Rename admin layout

* Fix routing after rebase

* Fixes for latest added admin interfaces

* Serviceworker ignore paths
2020-08-07 10:36:26 -04:00

43 lines
1.3 KiB
Ruby

require "rails_helper"
RSpec.describe "ResourceAdmin::Podcasts", type: :request do
let(:super_admin) { create(:user, :super_admin) }
let(:image_file) { Rails.root.join("spec/support/fixtures/images/image1.jpeg") }
before do
sign_in super_admin
end
describe "POST #create" do
let(:valid_attributes) do
{
title: "Developer Tea",
description: "Super Podcast",
feed_url: "http://feeds.feedburner.com/developertea",
slug: "devtea",
published: true,
main_color_hex: "333333",
image: Rack::Test::UploadedFile.new(image_file, "image/jpeg")
}
end
it "creates a podcast" do
expect do
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
end.to change(Podcast, :count).by(1)
end
it "enqueues a job after creating a podcast" do
sidekiq_assert_enqueued_jobs(1, only: Podcasts::GetEpisodesWorker) do
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
end
end
it "doesn't enqueue a job when creating an unpublished podcast" do
valid_attributes[:published] = false
sidekiq_assert_no_enqueued_jobs(only: Podcasts::GetEpisodesWorker) do
post "/resource_admin/podcasts", params: { podcast: valid_attributes }
end
end
end
end