From 1733c88a0743f132fddc62c703a6260204014dfc Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Thu, 22 Oct 2020 14:35:58 -0600 Subject: [PATCH] Ability to Mark Podcasts as Published in Admin Podcasts (#11024) [deploy] * Adds ability to publish/unpublish Podcasts via /admin/podacasts/id/edit - Moves ability to Admin to remove reliability of resource_admin - Adds published to podcast_params in Admin::PodcastsController * Adds a test to check the successful publishing of a podcast in podcasts_spec.rb * Reverts change to podcast.reload in podcasts_spec.rb --- app/controllers/admin/podcasts_controller.rb | 2 +- app/views/admin/podcasts/edit.html.erb | 7 +++++++ spec/requests/admin/podcasts_spec.rb | 8 +++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/podcasts_controller.rb b/app/controllers/admin/podcasts_controller.rb index 8e6223543..cea349fad 100644 --- a/app/controllers/admin/podcasts_controller.rb +++ b/app/controllers/admin/podcasts_controller.rb @@ -65,7 +65,7 @@ module Admin def podcast_params allowed_params = %i[ - title feed_url + title feed_url published ] params.require(:podcast).permit(allowed_params) end diff --git a/app/views/admin/podcasts/edit.html.erb b/app/views/admin/podcasts/edit.html.erb index f8148e949..cc2abf3a8 100644 --- a/app/views/admin/podcasts/edit.html.erb +++ b/app/views/admin/podcasts/edit.html.erb @@ -64,6 +64,13 @@ <%= f.label :feed_url, for: "podcast_feed_url" %> <%= f.text_field :feed_url, class: "form-control" %> +
+ <%= f.check_box "published", class: "crayons-checkbox" %> + +
+
<%= f.submit class: "btn btn-primary" %> <% end %> diff --git a/spec/requests/admin/podcasts_spec.rb b/spec/requests/admin/podcasts_spec.rb index 3e302735d..25359d21c 100644 --- a/spec/requests/admin/podcasts_spec.rb +++ b/spec/requests/admin/podcasts_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe "/admin/podcasts", type: :request do let(:admin) { create(:user, :super_admin) } - let(:podcast) { create(:podcast) } + let(:podcast) { create(:podcast, published: false) } let(:user) { create(:user) } before do @@ -60,12 +60,14 @@ RSpec.describe "/admin/podcasts", type: :request do end describe "Updating" do - it "updates" do + it "updates the podcast" do put admin_podcast_path(podcast), params: { podcast: { title: "hello", - feed_url: "https://pod.example.com/rss.rss" } } + feed_url: "https://pod.example.com/rss.rss", + published: true } } podcast.reload expect(podcast.title).to eq("hello") expect(podcast.feed_url).to eq("https://pod.example.com/rss.rss") + expect(podcast.published).to eq(true) end it "redirects after update" do