fill `nil` criteria attributes with PointGroup::DEFAULT_CRITERIA
parent
313008b21b
commit
c0fab4a38c
|
@ -4,4 +4,8 @@ class PointGroupSerializer < ApplicationSerializer
|
|||
def point_ids
|
||||
object.point_group_items.pluck(:point_id)
|
||||
end
|
||||
|
||||
def criteria
|
||||
object.criteria || PointGroup::DEFAULT_CRITERIA
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,4 +17,12 @@ describe Api::PointGroupsController do
|
|||
expect(response.status).to eq(200)
|
||||
expect(json.fetch(:name)).to eq pg.name
|
||||
end
|
||||
|
||||
it "fills `nil` criteria with PointGroup::DEFAULT_CRITERIA" do
|
||||
pg = PointGroup.create!(name: "x", device: device, criteria: nil )
|
||||
sign_in user
|
||||
get :show, params: { id: pg.id }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json.fetch(:criteria)).to eq PointGroup::DEFAULT_CRITERIA
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue