@@ -72,7 +72,7 class ProjectsController < ApplicationController | |||
|
72 | 72 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
73 | 73 | else |
|
74 | 74 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
75 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |
|
75 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } | |
|
76 | 76 | @project.custom_values = @custom_values |
|
77 | 77 | if params[:repository_enabled] && params[:repository_enabled] == "1" |
|
78 | 78 | @project.repository = Repository.factory(params[:repository_scm]) |
@@ -58,7 +58,7 class UsersController < ApplicationController | |||
|
58 | 58 | @user.admin = params[:user][:admin] || false |
|
59 | 59 | @user.login = params[:user][:login] |
|
60 | 60 | @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id |
|
61 | @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) } | |
|
61 | @custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } | |
|
62 | 62 | @user.custom_values = @custom_values |
|
63 | 63 | if @user.save |
|
64 | 64 | Mailer.deliver_account_information(@user, params[:password]) if params[:send_information] |
@@ -21,7 +21,7 class CustomValue < ActiveRecord::Base | |||
|
21 | 21 | |
|
22 | 22 | protected |
|
23 | 23 | def validate |
|
24 |
errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value. |
|
|
24 | errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value.blank? | |
|
25 | 25 | errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) |
|
26 | 26 | errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length and value.length > 0 |
|
27 | 27 | errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length |
@@ -45,7 +45,11 class AdminTest < ActionController::IntegrationTest | |||
|
45 | 45 | get "projects/add" |
|
46 | 46 | assert_response :success |
|
47 | 47 | assert_template "projects/add" |
|
48 |
post "projects/add", :project => { :name => "blog", |
|
|
48 | post "projects/add", :project => { :name => "blog", | |
|
49 | :description => "weblog", | |
|
50 | :identifier => "blog", | |
|
51 | :is_public => 1 }, | |
|
52 | 'custom_fields[3]' => 'Beta' | |
|
49 | 53 | assert_redirected_to "admin/projects" |
|
50 | 54 | assert_equal 'Successful creation.', flash[:notice] |
|
51 | 55 |
General Comments 0
You need to be logged in to leave comments.
Login now