Sha256: 148a7ae97f9799bc3fafade6d227e6de471cabbe15356d66a7711b9bf9ec1745

Contents?: true

Size: 1.36 KB

Versions: 12

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'
require 'open-uri'

describe Dossier::ApplicationHelper do
  describe "#formatted_dossier_report_path" do
    let(:options) { {divisions: %w[Alpha Omega], salary: 125_000} }
    let(:report)  { EmployeeReport.new(options) }
    let(:path)    { helper.formatted_dossier_report_path('csv', report) }
    let(:uri)     { URI.parse(path) }

    it "generates a path with the given format" do
      expect(uri.path).to match(/\.csv\z/)
    end

    it "generates a path with the given report name" do
      expect(uri.path).to match(/employee/)
    end

    it "generates a path with the given report options" do
      expect(uri.query).to eq({options: options}.to_query)
    end
  end

  describe "render_options" do
    describe "if exists" do
      let(:report) { EmployeeWithCustomViewReport.new }
      it "will render the options partial" do
        expect(helper.render_options report).to match('options be here matey!')
      end
    end

    describe "if missing" do
      let(:report) { EmployeeReport.new }
      it "will do nothing" do
        expect(helper.render_options report).to be_nil
      end
    end

    describe "if part of a multi report" do
      let(:multi)  { CombinationReport.new }
      let(:report) { multi.reports.first }
      it "will not render options" do
        expect(helper.render_options report).to be_nil
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dossier-3.0.0.pre spec/helpers/dossier/application_helper_spec.rb
dossier-2.13.1 spec/helpers/dossier/application_helper_spec.rb
dossier-2.12.2 spec/helpers/dossier/application_helper_spec.rb
dossier-2.12.1 spec/helpers/dossier/application_helper_spec.rb
dossier-2.12.0 spec/helpers/dossier/application_helper_spec.rb
dossier-2.11.0 spec/helpers/dossier/application_helper_spec.rb
dossier-2.10.0 spec/helpers/dossier/application_helper_spec.rb
dossier-2.9.3 spec/helpers/dossier/application_helper_spec.rb
dossier-2.9.2 spec/helpers/dossier/application_helper_spec.rb
dossier-2.9.1 spec/helpers/dossier/application_helper_spec.rb
dossier-2.9.0 spec/helpers/dossier/application_helper_spec.rb
dossier-2.8.0 spec/helpers/dossier/application_helper_spec.rb