1
0

Added test_create_binding_target

Goals (incl. binding) are required to have targets
Plugin fixtures are available through accessors
This commit is contained in:
cryptogopher
2020-08-20 21:52:18 +02:00
parent 13974e5e2f
commit f9ba308072
21 changed files with 103 additions and 27 deletions

View File

@@ -8,7 +8,8 @@ class Goal < ActiveRecord::Base
validates :target_exposures, presence: true
validates :is_binding, uniqueness: {scope: :project_id}, if: :is_binding?
validates :name, presence: true, uniqueness: {scope: :project_id}
validates :name, presence: true, uniqueness: {scope: :project_id},
exclusion: {in: [I18n.t('targets.form.binding_goal')], unless: :is_binding?}
after_initialize do
if new_record?

View File

@@ -1,4 +1,4 @@
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_import_foods"), '#', class: 'icon icon-multiple',
onclick: '$("#import-foods").show(); $("#filename").focus(); return false;' %>
<%= link_to t(".link_new_food"), new_project_food_path(@project, view: view),

View File

@@ -1,5 +1,5 @@
<%= fields_for 'goal', goal do |ff| %>
<label><%= l(:field_goal) %><span class="required"> *</span></label>
<label for="goal_id"><%= l(:field_goal) %><span class="required"> *</span></label>
<%= ff.select :id,
options_from_collection_for_select(@project.goals, :id, :name, goal.id),
{required: true}, autocomplete: 'off',

View File

@@ -29,7 +29,7 @@
<li><%= link_to t(".link_sources"), project_sources_path(@project) %></li>
<li><%= link_to t(".link_quantities"), project_quantities_path(@project) %></li>
<li><%= link_to t(".link_units"), project_units_path(@project) %></li>
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<li>&nbsp</li>
<li><p><%= link_to t(".link_defaults"), defaults_project_body_trackers_path(@project),
method: :post, data: {confirm: t(".confirm_defaults")} %></li>

View File

@@ -1,4 +1,4 @@
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_new_meal"), new_project_meal_path(@project),
{remote: true, class: 'icon icon-add'} %>
<% end %>

View File

@@ -1,4 +1,4 @@
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_new_measurement"),
new_project_measurement_path(@project, @view_params),
{remote: true, class: 'icon icon-add'} %>

View File

@@ -1,5 +1,5 @@
<div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_new_quantity"), new_project_quantity_path(@project),
{remote: true, class: 'icon icon-add'} %>
<% end %>

View File

@@ -1,5 +1,5 @@
<div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_new_source"), '#', class: 'icon icon-add',
onclick: '$("#add-source").show(); $("#source_name").focus(); return false;' %>
<% end %>

View File

@@ -1,4 +1,4 @@
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_new_target"),
new_project_target_path(@project, @view_params),
{remote: true, class: 'icon icon-add'} %>

View File

@@ -5,7 +5,6 @@
<div id='goal-form' class="tabular">
<% if goal.persisted? || goal.is_binding? %>
<p><%= render partial: 'goals/show_form', locals: {goal: goal} %></p>
<%#= t '.effective_from' %>
<p><%= f.date_field :effective_from, disabled: !goal.is_binding? %></p>
<% else %>
<%= render partial: 'goals/form', locals: {goal: goal} %>

View File

@@ -1,5 +1,5 @@
<div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %>
<% if User.current.allowed_to?(:manage_body_trackers, @project) %>
<%= link_to t(".link_new_unit"), '#', class: 'icon icon-add',
onclick: '$("#add-unit").show(); $("#unit_shortname").focus(); return false;' %>
<% end %>