Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template.visibililty Checks Not Always Working as Expected #3419

Open
aaronskiba opened this issue May 17, 2024 · 0 comments
Open

Template.visibililty Checks Not Always Working as Expected #3419

aaronskiba opened this issue May 17, 2024 · 0 comments
Assignees

Comments

@aaronskiba
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant