require "rails_helper"

describe AcquiredMediaReleasePolicy do
  let(:user) { create(:user, :manager) }
  let(:user_context) { build(:user_context, user: user, account: user.primary_account) }

  subject { described_class }

  permissions :create? do
    it { is_expected.to permit(:create) }
  end

  permissions :show? do
    it { is_expected.to permit(:show) }
  end

  permissions :update? do
    context "for a native release" do
      it { is_expected.not_to permit(user_context, build(:acquired_media_release, :native)) }
    end

    context "for a non-native release" do
      it { is_expected.to permit(user_context, build(:acquired_media_release, :non_native)) }
    end
  end

  permissions :destroy? do
    it { is_expected.to permit(user_context, :destroy) }
  end

  context "for an associate" do
    let(:user) { create(:user, :associate) }

    permissions :destroy? do
      it { is_expected.not_to permit(user_context, :destroy) }
    end
  end
end
