require "rails_helper"

describe Videos::ReportPublicationsController do
  let(:admin) { create(:user, :admin) }
  let(:project) { create(:project, account: admin.accounts.first) }

  before do
    sign_in(admin)
  end

  describe "#create" do
    it "sets the video report publication date" do
      video = create(:video, report_published_at: nil, project: project)

      post :create, params: { video_id: video }

      expect(video.reload).to be_report_published
    end
  end

  describe "#destroy" do
    it "unsets the video report publication date" do
      video = create(:video, report_published_at: Time.zone.now, project: project)

      delete :destroy, params: { video_id: video }

      expect(video.reload).not_to be_report_published
    end
  end
end
