Allow assigning both targets and local targets
Particularly useful in tests, because writing `targets` is shorter than writing `global_targets` and `local_targets`.
This commit is contained in:
@@ -69,6 +69,18 @@ describe SDG::Relatable do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#sdg_targets=" do
|
||||
it "assigns both targets and local targets" do
|
||||
global_targets = [SDG::Target[2.2], SDG::Target[1.2]]
|
||||
local_targets = %w[2.2.1 3.1.1].map { |code| create(:sdg_local_target, code: code) }
|
||||
|
||||
relatable.sdg_targets = global_targets + local_targets
|
||||
|
||||
expect(relatable.sdg_global_targets).to match_array global_targets
|
||||
expect(relatable.sdg_local_targets).to match_array local_targets
|
||||
end
|
||||
end
|
||||
|
||||
describe "#sdg_local_targets" do
|
||||
it "can assign local targets to a model" do
|
||||
relatable.sdg_local_targets = [local_target, another_local_target]
|
||||
|
||||
Reference in New Issue
Block a user