Sha256: 8b7a7bea708f6f1336c6910fbbe5588f516a4c86392af91ef5c6c3497c8a92af

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

require 'rails_helper'

module MnoEnterprise
  RSpec.describe Impac::Dashboard, type: :model do
    subject(:dashboard) { build(:impac_dashboard) }

    describe '#full_name' do
      subject { dashboard.full_name }
      it { is_expected.to eq(dashboard.name) }
    end

    describe '#sorted_widgets' do
      it 'is pending'
    end

    describe '#filtered_widgets_templates' do
      let(:templates) {
        [
          {path: 'accounts/balance', name: 'Account balance'},
          {path: 'accounts/comparison', name: 'Accounts comparison'}
        ]
      }
      subject(:dashboard) { build(:impac_dashboard, widgets_templates: templates) }

      subject { dashboard.filtered_widgets_templates }

      context 'with no filter' do
        before { MnoEnterprise.widgets_templates_listing = nil}

        it 'returns all the widgets' do
          expect(subject).to eq(templates)
        end
      end

      context 'with a filter' do
        let(:filter) { ['accounts/balance'] }
        before { MnoEnterprise.widgets_templates_listing = filter }

        it 'returns a filtered list' do
          expect(subject.size).to eq(1)
          expect(subject.map{|h| h[:path]}).to eq(filter)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mno-enterprise-core-3.2.1 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.3.1 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.3.0 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.2.0 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.1.4 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.7 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.1.3 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.6 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.1.2 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.5 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.1.1 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.4 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.1.0 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.3 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.2 spec/models/mno_enterprise/impac/dashboard_spec.rb
mno-enterprise-core-3.0.1 spec/models/mno_enterprise/impac/dashboard_spec.rb