require "rails_helper"

RSpec.describe ReleaseTypesHelper do
  describe ".options_for_release_type_select" do
    context "when no arguments" do
      it "returns options for all signable release types" do
        results = helper.options_for_release_type_select
        expect(results).to match /<option value="appearance">Appearance Release<\/option>/
        expect(results).to match /<option selected="selected" value="talent">Talent Release<\/option>/
        expect(results).to match /<option value="material">Material Release<\/option>/
        expect(results).to match /<option value="location">Location Release<\/option>/
      end
    end

    context "when project given" do
      let(:project) do
        create(:project).tap do |project|
          project.settings(:features).attributes = {
            appearance_release: false,
            talent_release: true,
          }
        end
      end

      it "returns filtered options for signable release types enabled in project" do
        results = helper.options_for_release_type_select(project)
        expect(results).not_to match /<option value="appearance">Appearance Release<\/option>/
        expect(results).to match /<option selected="selected" value="talent">Talent Release<\/option>/
      end
    end
  end
end
