[refs #54] Fix user_id validation into issues

This commit is contained in:
konstantin.grabar 2011-12-27 21:49:08 +04:00
parent b48ffecc28
commit ecbfed9300
3 changed files with 8 additions and 4 deletions

View File

@ -27,7 +27,7 @@ class IssuesController < ApplicationController
@issue = Issue.new(params[:issue])
@issue.user_id = @user_id
@issue.project_id = @project.id
if @issue.save!
if @issue.save
flash[:notice] = I18n.t("flash.issue.saved")
redirect_to project_issues_path(@project)
else

View File

@ -7,7 +7,7 @@ class Issue < ActiveRecord::Base
has_many :comments, :as => :commentable
has_many :subscribes, :as => :subscribeable
validates :title, :body, :project_id, :user_id, :presence => true
validates :title, :body, :project_id, :presence => true
#attr_readonly :serial_id
@ -17,6 +17,10 @@ class Issue < ActiveRecord::Base
after_create :deliver_issue_assign_notification
after_update :deliver_issue_assign_notification
def assign_uname
user.uname if user
end
protected
def set_serial_id
@ -52,7 +56,7 @@ class Issue < ActiveRecord::Base
def collect_recipient_ids
recipients = self.project.relations.by_role('admin').where(:object_type => 'User').map { |rel| rel.read_attribute(:object_id) }
recipients = recipients | [self.user_id]
recipients = recipients | [self.user_id] if self.user_id
recipients = recipients | [self.project.owner_id] if self.project.owner_type == 'User'
recipients
end

View File

@ -9,7 +9,7 @@
%td
= link_to issue.title, show_issue_path(@project, issue.serial_id)
%td
= link_to issue.user.uname, user_path(issue.user)
= link_to issue.user.uname, user_path(issue.user) if issue.user
%td
= issue.status
%td.last