Sha256: 0c7327fddab26c80cf4e90d37aa768ccc72f17e3ffd530be16f288ba6e7011f0

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require 'katapult/elements/web_ui'
require 'katapult/elements/model'
require 'katapult/application_model'

describe Katapult::WebUI do

  subject { described_class.new 'web_ui' }

  let(:application_model) { Katapult::ApplicationModel.new }

  describe '#path' do
    it 'raises an error if the given action does not exist' do
      expect do
        subject.path(:foobar)
      end.to raise_error(Katapult::WebUI::UnknownActionError)
    end
  end

  describe '#crud_only?' do
    it 'is true for a crud WebUI' do
      subject.crud
      expect(subject.crud_only?).to be true
    end

    it 'is false if the WebUI has custom actions' do
      subject.crud
      subject.action :custom, method: :get, scope: :collection
      expect(subject.crud_only?).to be false
    end

    it 'is false if the WebUI does not have all CRUD actions' do
      subject.action :index
      subject.action :show
      expect(subject.crud_only?).to be false
    end
  end

  describe '#model' do
    it 'returns the model object' do
      application_model.model 'User'

      subject = described_class.new('Customer',
        model: 'User',
        application_model: application_model,
      )

      expect(subject.model).to be application_model.models.first
    end

    it 'detects the model from its own name, if not stated explicitly' do
      application_model.model 'Customer'
      subject = described_class.new('Customer', application_model: application_model)

      expect(subject.model).to be application_model.models.first
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katapult-0.5.0 spec/web_ui_spec.rb
katapult-0.4.1 spec/web_ui_spec.rb
katapult-0.4.0 spec/web_ui_spec.rb