Sha256: fadb2293286722a8be7418819f6578352e980ec9a1408454bf896aa6072e7888

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe ReportsKit::Reports::Dimension do
  subject { described_class.new(properties, measure: measure) }
  let(:measure) { ReportsKit::Reports::Measure.new('issue') }

  context 'with a datetime dimension' do
    let(:properties) { 'opened_at' }

    it 'returns the settings' do
      expect(subject.settings).to eq({ column: 'issues.opened_at', group: "date_trunc('week', issues.opened_at::timestamp)" })
    end
  end

  context 'with a belongs_to association dimension' do
    let(:properties) { 'repo' }

    it 'returns the settings' do
      expect(subject.settings).to eq({ column: 'issues.repo_id', group: 'issues.repo_id' })
    end
  end

  context 'with a has_many association dimension' do
    let(:properties) { 'tags' }

    it 'returns the settings' do
      expect(subject.settings).to eq({ joins: :tags, column: 'tags.id', group: 'issues.issue_id' })
    end
  end

  context 'with a has_many :through association dimension' do
    let(:properties) { 'labels' }

    it 'returns the settings' do
      expect(subject.settings).to eq({ joins: :issues_labels, column: 'issues_labels.label_id', group: 'issues.label_id' })
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reports_kit-0.0.4 spec/reports_kit/reports/dimension_spec.rb
reports_kit-0.0.3 spec/reports_kit/reports/dimension_spec.rb
reports_kit-0.0.2 spec/reports_kit/reports/dimension_spec.rb
reports_kit-0.0.1 spec/reports_kit/reports/dimension_spec.rb