Sha256: 8093858717aa727f9f7d2048995abb531e23143201ac7d2a1496b08b92310af8

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require "rails_helper"

module Archangel
  RSpec.describe ApplicationHelper, type: :helper do
    before do
      without_partial_double_verification do
        allow(helper).to receive(:current_site).and_return(site)
      end
    end

    let(:site) { create(:site) }

    context "with #frontend_resource_path" do
      it "returns the permalink with a string" do
        expect(helper.frontend_resource_path("foo/bar")).to eq("/foo/bar")
      end

      it "returns the permalink with a Page resource" do
        parent = create(:page, site: site, slug: "foo")
        page = create(:page, site: site, parent: parent, slug: "bar")

        expect(helper.frontend_resource_path(page)).to eq("/foo/bar")
      end
    end

    context "with #locale" do
      it "returns default application locale" do
        expect(helper.locale).to eq("en")
      end
    end

    context "with #text_direction" do
      it "returns default `ltr` text direction" do
        expect(helper.text_direction).to eq("ltr")
      end

      it "returns rtl text direction" do
        without_partial_double_verification do
          allow(helper).to receive(:text_direction).and_return("rtl")
        end

        expect(helper.text_direction).to eq("rtl")
      end
    end

    context "with #active_backend_menu_for" do
      before do
        without_partial_double_verification do
          allow(helper).to receive(:params)
            .and_return(controller: "archangel/backend/pages")
        end
      end

      it "returns `true` when in the current controller" do
        expect(helper.active_backend_menu_for("pages")).to be_truthy
      end

      it "returns `false` when in not the current controller" do
        expect(helper.active_backend_menu_for("users")).to be_falsey
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/unit/helpers/archangel/application_helper_spec.rb