Sha256: 6ce510c9129cc1167bc29f59e164f4134caea746eead4dc31bf9679d9d799689

Contents?: true

Size: 1.78 KB

Versions: 20

Compression:

Stored size: 1.78 KB

Contents

require 'rails_helper'

describe ActiveAdmin::Views::UnsupportedBrowser do

  let(:helpers){ mock_action_view }
  let(:namespace) { double :namespace, unsupported_browser_matcher: /MSIE [1-8]\.0/ }
  let(:component) { double :unsupported_browser_component }
  let(:view_factory) { double :view_factory, unsupported_browser: component }
  let(:base) { ActiveAdmin::Views::Pages::Base.new }

  def build_panel
    render_arbre_component({}, helpers) do
      insert_tag ActiveAdmin::Views::UnsupportedBrowser
    end
  end

  it "should render the panel" do
    expect(I18n).to receive(:t).and_return("headline", "recommendation" ,"turn_off_compatibility_view")
    expect(build_panel.content.gsub(/\s+/, "")).to eq "<h1>headline</h1><p>recommendation</p><p>turn_off_compatibility_view</p>"
  end

  describe "ActiveAdmin::Views::Pages::Base behavior" do
    context "when the reqex match" do

      it "should build the unsupported browser panel" do
        expect(base).to receive(:active_admin_namespace).and_return(namespace)
        expect(base).to receive(:env).and_return({ "HTTP_USER_AGENT" => "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.2; Trident/6.0)" })
        expect(base).to receive(:view_factory).and_return(view_factory)
        expect(base).to receive(:insert_tag).with(component)
        base.send(:build_unsupported_browser)
      end

    end

    context "when the regex not match" do

      it "should not build the unsupported browser panel" do
        expect(base).to receive(:active_admin_namespace).and_return(namespace)
        expect(base).to receive(:env).and_return({ "HTTP_USER_AGENT" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" })
        expect(base).to receive(:insert_tag).never
        base.send(:build_unsupported_browser)
      end

    end
  end

end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/unsupported_browser_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/views/components/unsupported_browser_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/unsupported_browser_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/unsupported_browser_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/views/components/unsupported_browser_spec.rb
activeadmin-1.0.0.pre2 spec/unit/views/components/unsupported_browser_spec.rb
activeadmin-1.0.0.pre1 spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.7.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.6.pre spec/unit/views/components/unsupported_browser_spec.rb
yousty-activeadmin-1.0.5.pre spec/unit/views/components/unsupported_browser_spec.rb