Sha256: 4ce0f968b491f8adb6780ae2681c131174ed9d76c34f7085450a7a29cf270225

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

require 'rails_helper'

module MnoEnterprise
  describe ApplicationController, type: :controller do
    # create an anonymous subclass of ApplicationController to expose protected methods
    controller(MnoEnterprise::ApplicationController) do
      def after_sign_in_path_for(resource)
        super
      end
      def add_param_to_fragment(url, param_name, param_value)
        super
      end
    end

    describe '#add_param_to_fragment' do
      it { expect(controller.add_param_to_fragment('/#/platform/accounts', 'foo', 'bar')).to eq('/#/platform/accounts?foo=bar') }
      it { expect(controller.add_param_to_fragment('/', 'foo', 'bar')).to eq('/#?foo=bar') }
      it { expect(controller.add_param_to_fragment('/#/platform/dashboard/he/43?en=690', 'foo', 'bar')).to eq('/#/platform/dashboard/he/43?en=690&foo=bar') }
      it { expect(controller.add_param_to_fragment('/#/platform/dashboard/he/43?en=690', 'foo', [{msg: 'yolo'}])).to eq('/#/platform/dashboard/he/43?en=690&foo=%7B%3Amsg%3D%3E%22yolo%22%7D') }
    end

    describe '#after_sign_in_path_for' do
      before { @request.env["devise.mapping"] = Devise.mappings[:user] }

      it { expect(controller.after_sign_in_path_for(User.new())).to eq('/dashboard/') }
      it { expect(controller.after_sign_in_path_for(User.new(admin_role: "staff"))).to eq('/admin/') }
      it { expect(controller.after_sign_in_path_for(User.new(admin_role: ""))).to eq('/dashboard/') }
      it { expect(controller.after_sign_in_path_for(User.new(admin_role: "admin"))).to eq('/admin/') }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mno-enterprise-core-3.2.1 spec/controllers/mno_enterprise/application_controller_spec.rb
mno-enterprise-core-3.2.0 spec/controllers/mno_enterprise/application_controller_spec.rb
mno-enterprise-core-3.1.4 spec/controllers/mno_enterprise/application_controller_spec.rb
mno-enterprise-core-3.1.3 spec/controllers/mno_enterprise/application_controller_spec.rb
mno-enterprise-core-3.1.2 spec/controllers/mno_enterprise/application_controller_spec.rb
mno-enterprise-core-3.1.1 spec/controllers/mno_enterprise/application_controller_spec.rb