Commit 64ae89da authored by charlieablett's avatar charlieablett

Make test constants consistent

- Use shared context
parent 70f5a5b0
...@@ -4987,20 +4987,6 @@ ...@@ -4987,20 +4987,6 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "descendantWeightSum",
"description": "Total weight of open and closed descendant epic's issues",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "EpicDescendantWeights",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "description", "name": "description",
"description": "Description of the epic", "description": "Description of the epic",
...@@ -13098,47 +13084,6 @@ ...@@ -13098,47 +13084,6 @@
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "OBJECT",
"name": "EpicDescendantWeights",
"description": "Total weight of open and closed descendant issues",
"fields": [
{
"name": "closedIssues",
"description": "Total weight of completed (closed) issues in this epic, including epic descendants",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "openedIssues",
"description": "Total weight of opened issues in this epic, including epic descendants",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "TimelogConnection", "name": "TimelogConnection",
......
# frozen_string_literal: true # frozen_string_literal: true
describe Epics::Aggregate do require 'spec_helper'
let(:epic_type) { described_class::EPIC_TYPE }
let(:issue_type) { described_class::ISSUE_TYPE }
let(:opened_epic_state) { described_class::OPENED_EPIC_STATE }
let(:closed_epic_state) { described_class::CLOSED_EPIC_STATE }
let(:opened_issue_state) { described_class::OPENED_ISSUE_STATE }
let(:closed_issue_state) { described_class::CLOSED_ISSUE_STATE }
let(:weight_sum) { Epics::EpicNode::WEIGHT_SUM }
let(:count) { Epics::EpicNode::COUNT }
class Constants describe Epics::Aggregate do
include ::Epics::AggregateConstants include_context 'includes EpicAggregate constants'
end
context 'when CountAggregate' do context 'when CountAggregate' do
subject { Epics::CountAggregate.new(sums) } subject { Epics::CountAggregate.new(sums) }
...@@ -34,11 +23,11 @@ describe Epics::Aggregate do ...@@ -34,11 +23,11 @@ describe Epics::Aggregate do
context 'when some sums exist' do context 'when some sums exist' do
let(:sums) do let(:sums) do
[ [
Epics::Sum.new(facet: :count, type: epic_type, value: 1, state: opened_epic_state), double(:sum, facet: COUNT_FACET, type: EPIC_TYPE, value: 1, state: OPENED_EPIC_STATE),
Epics::Sum.new(facet: :count, type: epic_type, value: 1, state: closed_epic_state), double(:sum, facet: COUNT_FACET, type: EPIC_TYPE, value: 1, state: CLOSED_EPIC_STATE),
Epics::Sum.new(facet: :count, type: issue_type, value: 1, state: opened_issue_state), double(:sum, facet: COUNT_FACET, type: ISSUE_TYPE, value: 1, state: OPENED_ISSUE_STATE),
Epics::Sum.new(facet: :count, type: issue_type, value: 1, state: opened_issue_state), double(:sum, facet: COUNT_FACET, type: ISSUE_TYPE, value: 1, state: OPENED_ISSUE_STATE),
Epics::Sum.new(facet: :weight_sum, type: issue_type, value: 22, state: closed_issue_state) double(:sum, facet: WEIGHT_SUM_FACET, type: ISSUE_TYPE, value: 22, state: CLOSED_ISSUE_STATE)
] ]
end end
...@@ -68,9 +57,9 @@ describe Epics::Aggregate do ...@@ -68,9 +57,9 @@ describe Epics::Aggregate do
context 'when some sums exist' do context 'when some sums exist' do
let(:sums) do let(:sums) do
[ [
Epics::Sum.new(facet: :weight_sum, type: issue_type, value: 1, state: opened_issue_state), double(:sum, facet: WEIGHT_SUM_FACET, type: ISSUE_TYPE, value: 1, state: OPENED_ISSUE_STATE),
Epics::Sum.new(facet: :weight_sum, type: issue_type, value: 1, state: opened_issue_state), double(:sum, facet: WEIGHT_SUM_FACET, type: ISSUE_TYPE, value: 1, state: OPENED_ISSUE_STATE),
Epics::Sum.new(facet: :count, type: issue_type, value: 22, state: closed_issue_state) double(:sum, facet: COUNT_FACET, type: ISSUE_TYPE, value: 22, state: CLOSED_ISSUE_STATE)
] ]
end end
......
...@@ -3,14 +3,16 @@ ...@@ -3,14 +3,16 @@
require 'spec_helper' require 'spec_helper'
describe Epics::EpicNode do describe Epics::EpicNode do
include_context 'includes EpicAggregate constants'
let(:epic_id) { 34 } let(:epic_id) { 34 }
let(:epic_iid) { 5 } let(:epic_iid) { 5 }
describe '#initialize' do describe '#initialize' do
let(:fake_data) do let(:fake_data) do
[ [
{ iid: epic_iid, epic_state_id: epic_state_id, issues_count: 1, issues_weight_sum: 2, parent_id: parent_id, issues_state_id: Constants::OPENED_ISSUE_STATE }, { iid: epic_iid, epic_state_id: epic_state_id, issues_count: 1, issues_weight_sum: 2, parent_id: parent_id, issues_state_id: OPENED_ISSUE_STATE },
{ iid: epic_iid, epic_state_id: epic_state_id, issues_count: 2, issues_weight_sum: 2, parent_id: parent_id, issues_state_id: Constants::CLOSED_ISSUE_STATE } { iid: epic_iid, epic_state_id: epic_state_id, issues_count: 2, issues_weight_sum: 2, parent_id: parent_id, issues_state_id: CLOSED_ISSUE_STATE }
] ]
end end
...@@ -25,8 +27,8 @@ describe Epics::EpicNode do ...@@ -25,8 +27,8 @@ describe Epics::EpicNode do
end end
end end
it_behaves_like 'setting attributes based on the first record', { epic_state_id: Constants::OPENED_EPIC_STATE, parent_id: nil } it_behaves_like 'setting attributes based on the first record', { epic_state_id: OPENED_EPIC_STATE, parent_id: nil }
it_behaves_like 'setting attributes based on the first record', { epic_state_id: Constants::CLOSED_EPIC_STATE, parent_id: 2 } it_behaves_like 'setting attributes based on the first record', { epic_state_id: CLOSED_EPIC_STATE, parent_id: 2 }
end end
describe '#assemble_issue_sums' do describe '#assemble_issue_sums' do
...@@ -35,7 +37,7 @@ describe Epics::EpicNode do ...@@ -35,7 +37,7 @@ describe Epics::EpicNode do
context 'an epic with no issues' do context 'an epic with no issues' do
let(:fake_data) do let(:fake_data) do
[ [
{ iid: epic_iid, epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 0, issues_weight_sum: 0, parent_id: nil, issues_state_id: nil } { iid: epic_iid, epic_state_id: OPENED_EPIC_STATE, issues_count: 0, issues_weight_sum: 0, parent_id: nil, issues_state_id: nil }
] ]
end end
...@@ -50,7 +52,7 @@ describe Epics::EpicNode do ...@@ -50,7 +52,7 @@ describe Epics::EpicNode do
context 'with a nonzero count but a zero weight' do context 'with a nonzero count but a zero weight' do
let(:fake_data) do let(:fake_data) do
[ [
{ iid: epic_iid, epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 1, issues_weight_sum: 0, parent_id: nil, issues_state_id: Constants::OPENED_ISSUE_STATE } { iid: epic_iid, epic_state_id: OPENED_EPIC_STATE, issues_count: 1, issues_weight_sum: 0, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE }
] ]
end end
...@@ -58,14 +60,14 @@ describe Epics::EpicNode do ...@@ -58,14 +60,14 @@ describe Epics::EpicNode do
subject.assemble_issue_sums subject.assemble_issue_sums
expect(subject.direct_sums.count).to eq 1 expect(subject.direct_sums.count).to eq 1
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::COUNT, Constants::OPENED_ISSUE_STATE, 1) expect(subject).to have_direct_sum(ISSUE_TYPE, COUNT_FACET, OPENED_ISSUE_STATE, 1)
end end
end end
context 'with a nonzero count and nonzero weight for a single state' do context 'with a nonzero count and nonzero weight for a single state' do
let(:fake_data) do let(:fake_data) do
[ [
{ iid: epic_iid, epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 1, issues_weight_sum: 2, parent_id: nil, issues_state_id: Constants::OPENED_ISSUE_STATE } { iid: epic_iid, epic_state_id: OPENED_EPIC_STATE, issues_count: 1, issues_weight_sum: 2, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE }
] ]
end end
...@@ -73,16 +75,16 @@ describe Epics::EpicNode do ...@@ -73,16 +75,16 @@ describe Epics::EpicNode do
subject.assemble_issue_sums subject.assemble_issue_sums
expect(subject.direct_sums.count).to eq 2 expect(subject.direct_sums.count).to eq 2
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::COUNT, Constants::OPENED_ISSUE_STATE, 1) expect(subject).to have_direct_sum(ISSUE_TYPE, COUNT_FACET, OPENED_ISSUE_STATE, 1)
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::OPENED_ISSUE_STATE, 2) expect(subject).to have_direct_sum(ISSUE_TYPE, WEIGHT_SUM_FACET, OPENED_ISSUE_STATE, 2)
end end
end end
context 'with a nonzero count and nonzero weight for multiple states' do context 'with a nonzero count and nonzero weight for multiple states' do
let(:fake_data) do let(:fake_data) do
[ [
{ iid: epic_iid, epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 1, issues_weight_sum: 2, parent_id: nil, issues_state_id: Constants::OPENED_ISSUE_STATE }, { iid: epic_iid, epic_state_id: OPENED_EPIC_STATE, issues_count: 1, issues_weight_sum: 2, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE },
{ iid: epic_iid, epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 3, issues_weight_sum: 5, parent_id: nil, issues_state_id: Constants::CLOSED_ISSUE_STATE } { iid: epic_iid, epic_state_id: OPENED_EPIC_STATE, issues_count: 3, issues_weight_sum: 5, parent_id: nil, issues_state_id: CLOSED_ISSUE_STATE }
] ]
end end
...@@ -90,21 +92,21 @@ describe Epics::EpicNode do ...@@ -90,21 +92,21 @@ describe Epics::EpicNode do
subject.assemble_issue_sums subject.assemble_issue_sums
expect(subject.direct_sums.count).to eq 4 expect(subject.direct_sums.count).to eq 4
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::COUNT, Constants::OPENED_ISSUE_STATE, 1) expect(subject).to have_direct_sum(ISSUE_TYPE, COUNT_FACET, OPENED_ISSUE_STATE, 1)
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::OPENED_ISSUE_STATE, 2) expect(subject).to have_direct_sum(ISSUE_TYPE, WEIGHT_SUM_FACET, OPENED_ISSUE_STATE, 2)
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::COUNT, Constants::CLOSED_ISSUE_STATE, 3) expect(subject).to have_direct_sum(ISSUE_TYPE, COUNT_FACET, CLOSED_ISSUE_STATE, 3)
expect(subject).to have_direct_sum(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::CLOSED_ISSUE_STATE, 5) expect(subject).to have_direct_sum(ISSUE_TYPE, WEIGHT_SUM_FACET, CLOSED_ISSUE_STATE, 5)
end end
end end
end end
end end
describe '#assemble_epic_sums' do describe '#assemble_epic_sums' do
subject { described_class.new(epic_id, [{ parent_id: nil, epic_state_id: Constants::CLOSED_EPIC_STATE }]) } subject { described_class.new(epic_id, [{ parent_id: nil, epic_state_id: CLOSED_EPIC_STATE }]) }
context 'with a child epic' do context 'with a child epic' do
let(:child_epic_id) { 45 } let(:child_epic_id) { 45 }
let!(:child_epic_node) { described_class.new(child_epic_id, [{ parent_id: epic_id, epic_state_id: Constants::CLOSED_EPIC_STATE }]) } let!(:child_epic_node) { described_class.new(child_epic_id, [{ parent_id: epic_id, epic_state_id: CLOSED_EPIC_STATE }]) }
before do before do
subject.child_ids << child_epic_id subject.child_ids << child_epic_id
...@@ -114,13 +116,13 @@ describe Epics::EpicNode do ...@@ -114,13 +116,13 @@ describe Epics::EpicNode do
subject.assemble_epic_sums([child_epic_node]) subject.assemble_epic_sums([child_epic_node])
expect(subject.direct_sums.count).to eq 1 expect(subject.direct_sums.count).to eq 1
expect(subject).to have_direct_sum(Constants::EPIC_TYPE, Constants::COUNT, Constants::CLOSED_EPIC_STATE, 1) expect(subject).to have_direct_sum(EPIC_TYPE, COUNT_FACET, CLOSED_EPIC_STATE, 1)
end end
end end
end end
describe '#calculate_recursive_sums' do describe '#calculate_recursive_sums' do
subject { described_class.new(epic_id, [{ parent_id: nil, epic_state_id: Constants::CLOSED_EPIC_STATE }]) } subject { described_class.new(epic_id, [{ parent_id: nil, epic_state_id: CLOSED_EPIC_STATE }]) }
before do before do
allow(subject).to receive(:direct_sums).and_return(direct_sums) allow(subject).to receive(:direct_sums).and_return(direct_sums)
...@@ -146,7 +148,7 @@ describe Epics::EpicNode do ...@@ -146,7 +148,7 @@ describe Epics::EpicNode do
context 'with an issue with 0 weight' do context 'with an issue with 0 weight' do
let(:direct_sums) do let(:direct_sums) do
[Epics::EpicNode::Sum.new(Constants::COUNT, Constants::CLOSED_EPIC_STATE, Constants::ISSUE_TYPE, 1)] [Epics::EpicNode::Sum.new(COUNT_FACET, CLOSED_EPIC_STATE, ISSUE_TYPE, 1)]
end end
it 'returns a SumTotal with only a weight sum' do it 'returns a SumTotal with only a weight sum' do
...@@ -160,8 +162,8 @@ describe Epics::EpicNode do ...@@ -160,8 +162,8 @@ describe Epics::EpicNode do
context 'with an issue with nonzero weight' do context 'with an issue with nonzero weight' do
let(:direct_sums) do let(:direct_sums) do
[ [
Epics::EpicNode::Sum.new(Constants::COUNT, Constants::CLOSED_EPIC_STATE, Constants::ISSUE_TYPE, 1), Epics::EpicNode::Sum.new(COUNT_FACET, CLOSED_EPIC_STATE, ISSUE_TYPE, 1),
Epics::EpicNode::Sum.new(Constants::WEIGHT_SUM, Constants::CLOSED_EPIC_STATE, Constants::ISSUE_TYPE, 2) Epics::EpicNode::Sum.new(WEIGHT_SUM_FACET, CLOSED_EPIC_STATE, ISSUE_TYPE, 2)
] ]
end end
...@@ -179,10 +181,10 @@ describe Epics::EpicNode do ...@@ -179,10 +181,10 @@ describe Epics::EpicNode do
let(:tree) do let(:tree) do
{ epic_id => subject, child_epic_id => child_epic_node } { epic_id => subject, child_epic_id => child_epic_node }
end end
let(:child_epic_node) { described_class.new(child_epic_id, [{ parent_id: epic_id, epic_state_id: Constants::CLOSED_EPIC_STATE }]) } let(:child_epic_node) { described_class.new(child_epic_id, [{ parent_id: epic_id, epic_state_id: CLOSED_EPIC_STATE }]) }
let(:direct_sums) do let(:direct_sums) do
[ # only one opened epic, the child [ # only one opened epic, the child
Epics::EpicNode::Sum.new(Constants::COUNT, Constants::OPENED_EPIC_STATE, Constants::EPIC_TYPE, 1) Epics::EpicNode::Sum.new(COUNT_FACET, OPENED_EPIC_STATE, EPIC_TYPE, 1)
] ]
end end
...@@ -194,8 +196,8 @@ describe Epics::EpicNode do ...@@ -194,8 +196,8 @@ describe Epics::EpicNode do
context 'with a child that has issues of nonzero weight' do context 'with a child that has issues of nonzero weight' do
let(:child_sums) do let(:child_sums) do
[ # 1 issue of weight 2 [ # 1 issue of weight 2
Epics::EpicNode::Sum.new(Constants::COUNT, Constants::OPENED_ISSUE_STATE, Constants::ISSUE_TYPE, 1), Epics::EpicNode::Sum.new(COUNT_FACET, OPENED_ISSUE_STATE, ISSUE_TYPE, 1),
Epics::EpicNode::Sum.new(Constants::WEIGHT_SUM, Constants::OPENED_ISSUE_STATE, Constants::ISSUE_TYPE, 2) Epics::EpicNode::Sum.new(WEIGHT_SUM_FACET, OPENED_ISSUE_STATE, ISSUE_TYPE, 2)
] ]
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Epics::LazyEpicAggregate do describe Epics::LazyEpicAggregate do
include_context 'includes EpicAggregate constants'
let(:query_ctx) do let(:query_ctx) do
{} {}
end end
...@@ -40,7 +42,7 @@ describe Epics::LazyEpicAggregate do ...@@ -40,7 +42,7 @@ describe Epics::LazyEpicAggregate do
describe '#epic_aggregate' do describe '#epic_aggregate' do
let(:single_record) do let(:single_record) do
{ iid: 6, issues_count: 4, issues_weight_sum: 9, parent_id: nil, issues_state_id: Constants::OPENED_ISSUE_STATE, epic_state_id: Constants::OPENED_EPIC_STATE } { iid: 6, issues_count: 4, issues_weight_sum: 9, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE, epic_state_id: OPENED_EPIC_STATE }
end end
let(:epic_info_node) { Epics::EpicNode.new(epic_id, [single_record] ) } let(:epic_info_node) { Epics::EpicNode.new(epic_id, [single_record] ) }
...@@ -70,9 +72,9 @@ describe Epics::LazyEpicAggregate do ...@@ -70,9 +72,9 @@ describe Epics::LazyEpicAggregate do
end end
let(:fake_data) do let(:fake_data) do
{ {
epic_id => [{ epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 2, issues_weight_sum: 5, parent_id: nil, issues_state_id: Constants::OPENED_ISSUE_STATE }], epic_id => [{ epic_state_id: OPENED_EPIC_STATE, issues_count: 2, issues_weight_sum: 5, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE }],
child_epic_id => [{ epic_state_id: Constants::CLOSED_EPIC_STATE, issues_count: 4, issues_weight_sum: 17, parent_id: epic_id, issues_state_id: Constants::CLOSED_ISSUE_STATE }], child_epic_id => [{ epic_state_id: CLOSED_EPIC_STATE, issues_count: 4, issues_weight_sum: 17, parent_id: epic_id, issues_state_id: CLOSED_ISSUE_STATE }],
other_epic_id => [{ epic_state_id: Constants::OPENED_EPIC_STATE, issues_count: 0, issues_weight_sum: 0, parent_id: nil, issues_state_id: nil }] # represents an epic with no parent and no issues other_epic_id => [{ epic_state_id: OPENED_EPIC_STATE, issues_count: 0, issues_weight_sum: 0, parent_id: nil, issues_state_id: nil }] # represents an epic with no parent and no issues
} }
end end
...@@ -106,12 +108,12 @@ describe Epics::LazyEpicAggregate do ...@@ -106,12 +108,12 @@ describe Epics::LazyEpicAggregate do
lazy_state = subject.instance_variable_get(:@lazy_state) lazy_state = subject.instance_variable_get(:@lazy_state)
tree = lazy_state[:tree] tree = lazy_state[:tree]
expect(tree[epic_id]).to have_direct_sum(Constants::EPIC_TYPE, Constants::COUNT, Constants::CLOSED_EPIC_STATE, 1) expect(tree[epic_id]).to have_direct_sum(EPIC_TYPE, COUNT_FACET, CLOSED_EPIC_STATE, 1)
expect(tree[epic_id]).to have_direct_sum(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::OPENED_ISSUE_STATE, 5) expect(tree[epic_id]).to have_direct_sum(ISSUE_TYPE, WEIGHT_SUM_FACET, OPENED_ISSUE_STATE, 5)
expect(tree[epic_id]).to have_direct_sum(Constants::EPIC_TYPE, Constants::COUNT, Constants::CLOSED_EPIC_STATE, 1) expect(tree[epic_id]).to have_direct_sum(EPIC_TYPE, COUNT_FACET, CLOSED_EPIC_STATE, 1)
expect(tree[child_epic_id]).to have_direct_sum(Constants::ISSUE_TYPE, Constants::COUNT, Constants::CLOSED_ISSUE_STATE, 4) expect(tree[child_epic_id]).to have_direct_sum(ISSUE_TYPE, COUNT_FACET, CLOSED_ISSUE_STATE, 4)
expect(tree[child_epic_id]).to have_direct_sum(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::CLOSED_ISSUE_STATE, 17) expect(tree[child_epic_id]).to have_direct_sum(ISSUE_TYPE, WEIGHT_SUM_FACET, CLOSED_ISSUE_STATE, 17)
end end
it 'assembles recursive sums for the parent', :aggregate_failures do it 'assembles recursive sums for the parent', :aggregate_failures do
...@@ -120,11 +122,11 @@ describe Epics::LazyEpicAggregate do ...@@ -120,11 +122,11 @@ describe Epics::LazyEpicAggregate do
lazy_state = subject.instance_variable_get(:@lazy_state) lazy_state = subject.instance_variable_get(:@lazy_state)
tree = lazy_state[:tree] tree = lazy_state[:tree]
expect(tree[epic_id]).to have_aggregate(Constants::ISSUE_TYPE, Constants::COUNT, Constants::OPENED_ISSUE_STATE, 2) expect(tree[epic_id]).to have_aggregate(ISSUE_TYPE, COUNT_FACET, OPENED_ISSUE_STATE, 2)
expect(tree[epic_id]).to have_aggregate(Constants::ISSUE_TYPE, Constants::COUNT, Constants::CLOSED_ISSUE_STATE, 4) expect(tree[epic_id]).to have_aggregate(ISSUE_TYPE, COUNT_FACET, CLOSED_ISSUE_STATE, 4)
expect(tree[epic_id]).to have_aggregate(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::OPENED_ISSUE_STATE, 5) expect(tree[epic_id]).to have_aggregate(ISSUE_TYPE, WEIGHT_SUM_FACET, OPENED_ISSUE_STATE, 5)
expect(tree[epic_id]).to have_aggregate(Constants::ISSUE_TYPE, Constants::WEIGHT_SUM, Constants::CLOSED_ISSUE_STATE, 17) expect(tree[epic_id]).to have_aggregate(ISSUE_TYPE, WEIGHT_SUM_FACET, CLOSED_ISSUE_STATE, 17)
expect(tree[epic_id]).to have_aggregate(Constants::EPIC_TYPE, Constants::COUNT, Constants::CLOSED_EPIC_STATE, 1) expect(tree[epic_id]).to have_aggregate(EPIC_TYPE, COUNT_FACET, CLOSED_EPIC_STATE, 1)
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec::Matchers.define :have_direct_sum do |type, facet, state, value| RSpec::Matchers.define :have_direct_sum do |type, facet, state, value|
# supports_block_expectations
match do |epic_node_result| match do |epic_node_result|
expect(epic_node_result).not_to be_nil expect(epic_node_result).not_to be_nil
expect(epic_node_result.direct_sums).not_to be_empty expect(epic_node_result.direct_sums).not_to be_empty
...@@ -24,8 +22,6 @@ RSpec::Matchers.define :have_direct_sum do |type, facet, state, value| ...@@ -24,8 +22,6 @@ RSpec::Matchers.define :have_direct_sum do |type, facet, state, value|
end end
RSpec::Matchers.define :have_aggregate do |type, facet, state, value| RSpec::Matchers.define :have_aggregate do |type, facet, state, value|
supports_block_expectations
match do |epic_node_result| match do |epic_node_result|
aggregate_object = epic_node_result.aggregate_object_by(facet) aggregate_object = epic_node_result.aggregate_object_by(facet)
expect(aggregate_object.send(method_name(type, state))).to eq value expect(aggregate_object.send(method_name(type, state))).to eq value
...@@ -38,12 +34,12 @@ RSpec::Matchers.define :have_aggregate do |type, facet, state, value| ...@@ -38,12 +34,12 @@ RSpec::Matchers.define :have_aggregate do |type, facet, state, value|
end end
def method_name(type, state) def method_name(type, state)
if type == Constants::ISSUE_TYPE if type == ISSUE_TYPE
return :opened_issues if state == Constants::OPENED_ISSUE_STATE return :opened_issues if state == OPENED_ISSUE_STATE
:closed_issues :closed_issues
elsif type == Constants::EPIC_TYPE elsif type == EPIC_TYPE
return :opened_epics if state == Constants::OPENED_EPIC_STATE return :opened_epics if state == OPENED_EPIC_STATE
:closed_epics :closed_epics
end end
......
# frozen_string_literal: true
shared_context 'includes EpicAggregate constants' do
EPIC_TYPE = Epics::AggregateConstants::EPIC_TYPE
ISSUE_TYPE = Epics::AggregateConstants::ISSUE_TYPE
OPENED_EPIC_STATE = Epics::AggregateConstants::OPENED_EPIC_STATE
CLOSED_EPIC_STATE = Epics::AggregateConstants::CLOSED_EPIC_STATE
OPENED_ISSUE_STATE = Epics::AggregateConstants::OPENED_ISSUE_STATE
CLOSED_ISSUE_STATE = Epics::AggregateConstants::CLOSED_ISSUE_STATE
WEIGHT_SUM_FACET = Epics::AggregateConstants::WEIGHT_SUM
COUNT_FACET = Epics::AggregateConstants::COUNT
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment