it'raises an error for an invalid :issuable_type option'do
expect{find(nil,issuable_type: 'foo')}.toraise_error(described_class::InvalidIssuableTypeError,"Invalid `:issuable_type` option: `foo`. Allowed values are #{described_class::FINDERS.keys}!")
end
it'raises an error for an invalid entity object'do
expect{find(build(:user),issuable_type: 'issue')}.toraise_error(described_class::InvalidEntityError,'Entity class `User` is not supported. Supported classes are Project and Namespace!')
end
it'raises an error for an invalid :group_by option'do
expect{find(nil,issuable_type: 'issue',group_by: 'foo')}.toraise_error(described_class::InvalidGroupByError,"Invalid `:group_by` option: `foo`. Allowed values are #{described_class::PERIODS.keys}!")
end
it'raises an error for an invalid :period_limit option'do
expect{find(build(:user),issuable_type: 'issue',group_by: 'months',period_limit: 'many')}.toraise_error(described_class::InvalidPeriodLimitError,"Invalid `:period_limit` option: `many`. Expected an integer!")
it'raises an error for an unknown :issuable_type option'do
expect{reduce(issuable_relation,nil)}.toraise_error(described_class::InvalidLabelsError,"Invalid value for `labels`: `[]`. It must be a non-empty array!")
end
it'returns issuables with only the needed fields'do
it'raises an error for an unknown :period option'do
expect{reduce(issuable_relation,'unknown')}.toraise_error(described_class::InvalidPeriodError,"Invalid value for `period`: `unknown`. Allowed values are #{described_class::VALID_PERIOD}!")
end
it'raises an error for an unknown :period_field option'do
expect{reduce(issuable_relation,'month',:foo)}.toraise_error(described_class::InvalidPeriodFieldError,"Invalid value for `period_field`: `foo`. Allowed values are #{described_class::VALID_PERIOD_FIELD}!")
end
it'returns issuables with only the needed fields'do
it'raises an error if the input is not in the correct format'do
expect{described_class.present(input)}.toraise_error(described_class::WrongInsightsFormatError,/Expected `input` to be of the form `Hash\[Symbol\|String, Integer\]`, .+ given!/)
it'raises an error if the input is not in the correct format'do
expect{described_class.present(input)}.toraise_error(described_class::WrongInsightsFormatError,/Expected `input` to be of the form `Hash\[Symbol\|String, Hash\[Symbol\|String, Integer\]\]`, .+ given!/)