Sha256: abf6d735a373fd23b52cef5b58c041ffbb0b1c357a848b4864456117d61eaf7c

Contents?: true

Size: 1.85 KB

Versions: 14

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

module Alchemy
  class ModulesTestController < ApplicationController
    include Modules
  end

  describe Modules do
    let(:controller)      { ModulesTestController.new }
    let(:alchemy_modules) { YAML.load_file(File.expand_path('../../../config/alchemy/modules.yml', __FILE__)) }

    describe '#module_definition_for' do
      subject { controller.module_definition_for(name) }

      let(:dashboard_module) { alchemy_modules.first }

      context 'with a string given as name' do
        let(:name) { 'dashboard' }

        it "returns the module definition" do
          is_expected.to eq(dashboard_module)
        end
      end

      context 'with a hash given as name' do
        let(:controller_name) { 'alchemy/admin/dashboard' }
        let(:name)            { {controller: controller_name, action: 'index'} }

        it "returns the module definition" do
          is_expected.to eq(dashboard_module)
        end

        context 'with leading slash in controller name' do
          let(:controller_name) { '/alchemy/admin/dashboard' }

          it "returns the module definition" do
            is_expected.to eq(dashboard_module)
          end
        end
      end

      context 'with nil given as name' do
        let(:name) { nil }
        it 'raises an error' do
          expect { subject }.to raise_error('Could not find module definition for ')
        end
      end
    end

    describe '.register_module' do
      let(:alchemy_module) do
        {
          'name' => 'module',
          'navigation' => {
            'controller' => 'admin/controller_name',
            'action' => 'index'
          }
        }
      end

      it "registers a module definition into global list of modules" do
        Modules.register_module(alchemy_module)
        expect(Modules.alchemy_modules).to include(alchemy_module)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
alchemy_cms-3.1.3 spec/libraries/modules_spec.rb
alchemy_cms-3.2.0.rc1 spec/libraries/modules_spec.rb
alchemy_cms-3.2.0.beta spec/libraries/modules_spec.rb
alchemy_cms-3.1.1 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.rc3 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.rc2 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.rc1 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.beta6 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.beta5 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.beta4 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.beta3 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.beta2 spec/libraries/modules_spec.rb
alchemy_cms-3.1.0.beta1 spec/libraries/modules_spec.rb