Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix rendering customizable form

ulferts4beff7d46d36
diff --git a/app/views/customizable/_form.html.erb b/app/views/customizable/_form.html.erb
index 169a146d696..5ff6c263a99 100644
--- a/app/views/customizable/_form.html.erb
+++ b/app/views/customizable/_form.html.erb
@@ -32,8 +32,8 @@ See docs/COPYRIGHT.rdoc for more details.
<% form.object.custom_field_values.each do |value| %>
<%= form.fields_for_custom_fields :custom_field_values, value do |value_form| %>
<%# display all fields OR only display required fields OR only display optional fields #%>
+ <% required = value.custom_field.is_required? %>
<% if all_fields || (only_required && required) || (!only_required && !required) %>
- <% required = value.custom_field.is_required? %>
<% container_class = value.custom_field.field_format == 'text' ? '-xxwide' : '-wide' %>
<div class="form--field custom_field_<%= value.custom_field.id %> <%= required ? '-required' : '' %>">
<%= value_form.custom_field(container_class: container_class, required: required) %>
diff --git a/spec_legacy/functional/projects_controller_spec.rb b/spec_legacy/functional/projects_controller_spec.rb
index 39b6b25b3b0..0d3dfaa036a 100644
--- a/spec_legacy/functional/projects_controller_spec.rb
+++ b/spec_legacy/functional/projects_controller_spec.rb
@@ -42,57 +42,7 @@ describe ProjectsController, type: :controller do
Setting.default_language = 'en'
end
- it 'should index' do
- get :index
- assert_response :success
- assert_template 'index'
- refute_nil assigns(:projects)
-
- assert_select 'ul',
- child: {
- tag: 'li',
- descendant: { tag: 'a', content: 'eCookbook' },
- child: {
- tag: 'ul',
- descendant: {
- tag: 'a',
- content: 'Child of private child'
- }
- }
- }
-
- assert_select('a', { content: /Private child of eCookbook/ }, false)
- end
-
- context '#index' do
- context 'by non-admin user without view_time_entries permission' do
- before do
- Role.find(2).remove_permission! :view_time_entries
- Role.non_member.remove_permission! :view_time_entries
- Role.anonymous.remove_permission! :view_time_entries
- session[:user_id] = 3
- end
- it 'should not show overall spent time link' do
- get :index
- assert_template 'index'
- assert_select('a', { attributes: { href: '/time_entries' } }, false)
- end
- end
- end
-
context '#new' do
- context 'by admin user' do
- before do
- session[:user_id] = 1
- end
-
- it 'should accept get' do
- get :new
- assert_response :success
- assert_template 'new'
- end
- end
-
context 'by non-admin user with add_project permission' do
before do
Role.non_member.add_permission! :add_project