Skip to content

Template.visibililty Checks Not Always Working as Expected #3419

@aaronskiba

Description

@aaronskiba

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)

  • v4.2.0

Expected behaviour:

  • app/views/org_admin/templates/_form.html.erb includes the following:
<%= f.check_box(:visibility, checked: f.object.visibility == 'organisationally_visible') %>
  • app/views/org_admin/templates/_show.html.erb includes the following:
<% if template.visibility == 'organisationally_visible' %>

You'd expect these checks to verify the value of template.visibility

Actual behaviour:

3.0.5 :001 > Plan.visibilities
 => {"organisationally_visible"=>0, "publicly_visible"=>1, "is_test"=>2, "privately_visible"=>3} 
3.0.5 :002 > Plan.first.visibility
  Plan Load (1.2ms)  SELECT "plans".* FROM "plans" ORDER BY "plans"."id" ASC LIMIT $1  [["LIMIT", 1]]
 => "privately_visible" 
3.0.5 :003 > Template.visibilities
 => {"organisationally_visible"=>0, "publicly_visible"=>1} 
3.0.5 :004 > Template.first.visibility
  Template Load (1.2ms)  SELECT "templates".* FROM "templates" ORDER BY "templates"."id" ASC LIMIT $1  [["LIMIT", 1]]
 => 0 

While plan.visibility outputs the string representation of the enum value, template.visibilty outputs the integer. As a result, the aforementioned == 'organisationally_visibile' checks will always return false.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions