File: time_tracking_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (40 lines) | stat: -rw-r--r-- 1,419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe WorkItems::Widgets::TimeTracking, feature_category: :team_planning do
  let_it_be(:work_item) { create(:work_item, time_estimate: 12.hours) }
  let_it_be(:timelog1) { create(:timelog, issue: work_item, time_spent: 1.hour.to_i) }
  let_it_be(:timelog2) { create(:timelog, issue: work_item, time_spent: 2.hours.to_i) }

  describe '.quick_action_params' do
    subject { described_class.quick_action_params }

    it { is_expected.to contain_exactly(:time_estimate, :spend_time) }
  end

  describe '.quick_action_commands' do
    subject { described_class.quick_action_commands }

    it 'lists all available quick actions' do
      is_expected.to contain_exactly(
        :estimate, :estimate_time, :remove_estimate,
        :remove_time_estimate, :remove_time_spent, :spend, :spend_time, :spent
      )
    end
  end

  describe '.type' do
    it { expect(described_class.type).to eq(:time_tracking) }
  end

  describe '#type' do
    it { expect(described_class.new(work_item).type).to eq(:time_tracking) }
  end

  describe 'time tracking data' do
    it { expect(described_class.new(work_item).time_estimate).to eq(work_item.time_estimate) }
    it { expect(described_class.new(work_item).total_time_spent).to eq(3.hours) }
    it { expect(described_class.new(work_item).timelogs.map(&:id)).to match_array([timelog1.id, timelog2.id]) }
  end
end