Skip to content

Commit

Permalink
Merge pull request #109 from katylouise/katylouise/webdev-836_add-bus…
Browse files Browse the repository at this point in the history
…iness-item

[WEBDEV-836] Added work_package to business item decorator
  • Loading branch information
Christine-horrocks authored Oct 19, 2018
2 parents 354923c + 2ee116e commit 6e78adc
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 4 deletions.
11 changes: 11 additions & 0 deletions lib/parliament/grom/decorator/business_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ def procedure_step
def date
respond_to?(:businessItemDate) ? DateTime.parse(businessItemDate) : nil
end

# Alias businessItemHasWorkPackage with fallback.
#
# @return [Grom::Node, nil] the WorkPackage of the Grom::Node or nil.
def work_package
return @work_package if @work_package

return nil unless respond_to?(:businessItemHasWorkPackage)

@work_package = Helpers::Utils.type_safe_first(businessItemHasWorkPackage, Parliament::Grom::Decorator::WorkPackage)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/parliament/grom/decorator/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Parliament
module Grom
module Decorator
VERSION = '1.0.2'.freeze
VERSION = '1.0.3'.freeze
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions spec/parliament/grom/decorator/business_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@

# Test #procedure_step
include_examples(
'type_safe_first',
{
'type_safe_first',
{
request: request_object,
filter_type: 'https://id.parliament.uk/schema/BusinessItem',
predicate: :businessItemHasProcedureStep,
decorator_method: :procedure_step,
type_klass: Parliament::Grom::Decorator::ProcedureStep
}
)
# Test #work_package
include_examples(
'type_safe_first',
{
request: request_object,
filter_type: 'https://id.parliament.uk/schema/BusinessItem',
predicate: :businessItemHasWorkPackage,
decorator_method: :work_package,
type_klass: Parliament::Grom::Decorator::WorkPackage
}
)

describe '#date' do
context 'Grom::Node has a date' do
Expand Down
2 changes: 1 addition & 1 deletion spec/parliament/grom/decorator/laid_thing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
decorators: Parliament::Grom::Decorator
).statutory_instrument_by_id

# Test #body
# Test #laying
include_examples(
'type_safe_first',
{
Expand Down

0 comments on commit 6e78adc

Please sign in to comment.