summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-06-26 21:47:25 +0300
committerrandx <dmitriy.zaporozhets@gmail.com>2012-06-26 21:47:25 +0300
commit88c625e3f718eb2dffcae7e8d2d03a86a51cd309 (patch)
treea6e083bdf4aec8a2f8c986417cced47d09ece2a8
parent6abc649590cfb110a88e6b2bdd3755c7d8ab6b4e (diff)
downloadgitlab-ce-88c625e3f718eb2dffcae7e8d2d03a86a51cd309.tar.gz
Issues can be unassigned now
-rw-r--r--app/assets/images/no_avatar.pngbin1335 -> 1337 bytes
-rw-r--r--app/models/issue.rb6
-rw-r--r--app/observers/issue_observer.rb6
-rw-r--r--app/views/issues/_form.html.haml2
-rw-r--r--app/views/issues/_show.html.haml22
-rw-r--r--app/views/issues/show.html.haml7
-rw-r--r--app/views/milestones/show.html.haml2
-rw-r--r--spec/models/issue_spec.rb1
8 files changed, 29 insertions, 17 deletions
diff --git a/app/assets/images/no_avatar.png b/app/assets/images/no_avatar.png
index 99e5fd9b436..752d26adba7 100644
--- a/app/assets/images/no_avatar.png
+++ b/app/assets/images/no_avatar.png
Binary files differ
diff --git a/app/models/issue.rb b/app/models/issue.rb
index fa2aa2f401d..40e14dac0d6 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -11,7 +11,6 @@ class Issue < ActiveRecord::Base
attr_accessor :author_id_of_changes
validates_presence_of :project_id
- validates_presence_of :assignee_id
validates_presence_of :author_id
delegate :name,
@@ -22,6 +21,7 @@ class Issue < ActiveRecord::Base
delegate :name,
:email,
:to => :assignee,
+ :allow_nil => true,
:prefix => true
validates :title,
@@ -56,6 +56,10 @@ class Issue < ActiveRecord::Base
today? && created_at == updated_at
end
+ def is_assigned?
+ !!assignee_id
+ end
+
def is_being_reassigned?
assignee_id_changed?
end
diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb
index fadedd301f4..92b0f8368cb 100644
--- a/app/observers/issue_observer.rb
+++ b/app/observers/issue_observer.rb
@@ -2,7 +2,9 @@ class IssueObserver < ActiveRecord::Observer
cattr_accessor :current_user
def after_create(issue)
- Notify.new_issue_email(issue.id).deliver if issue.assignee != current_user
+ if issue.assignee && issue.assignee != current_user
+ Notify.new_issue_email(issue.id).deliver
+ end
end
def after_update(issue)
@@ -14,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer
protected
def send_reassigned_email(issue)
- recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id }
+ recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id }
recipient_ids.each do |recipient_id|
Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver
diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml
index 4dcba4fb657..444fbd768fe 100644
--- a/app/views/issues/_form.html.haml
+++ b/app/views/issues/_form.html.haml
@@ -14,7 +14,7 @@
= f.text_field :title, :maxlength => 255, :class => "xxlarge"
.issue_middle_block
.issue_assignee
- = f.label :assignee_id, "Assign to *"
+ = f.label :assignee_id, "Assign to"
.input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" })
.issue_milestone
= f.label :milestone_id
diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml
index de27555952f..b6b5d72d587 100644
--- a/app/views/issues/_show.html.haml
+++ b/app/views/issues/_show.html.haml
@@ -15,12 +15,20 @@
%i.icon-edit
Edit
- = image_tag gravatar_icon(issue.assignee_email), :class => "avatar"
- %span.update-author
- assigned to
- %strong= issue.assignee_name
- - if issue.upvotes > 0
- %span.badge.badge-success= "+#{issue.upvotes}"
-
+ - if issue.assignee
+ = image_tag gravatar_icon(issue.assignee_email), :class => "avatar"
+ %span.update-author
+ assigned to
+ %strong= issue.assignee_name
+ - if issue.upvotes > 0
+ %span.badge.badge-success= "+#{issue.upvotes}"
+
+ - else
+ = image_tag "no_avatar.png", :class => "avatar"
+ %span.update-author
+ Unassigned
+ - if issue.upvotes > 0
+ %span.badge.badge-success= "+#{issue.upvotes}"
+
= link_to project_issue_path(issue.project, issue) do
%p.row_title= truncate(issue.title, :length => 100)
diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml
index 0d3c4e19097..1bb4e04d2b6 100644
--- a/app/views/issues/show.html.haml
+++ b/app/views/issues/show.html.haml
@@ -38,9 +38,10 @@
= image_tag gravatar_icon(@issue.author_email), :width => 16, :class => "lil_av"
%strong.author= link_to_issue_author(@issue)
- %cite.cgray and currently assigned to
- = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av"
- %strong.author= link_to_issue_assignee(@issue)
+ - if @issue.assignee
+ %cite.cgray and currently assigned to
+ = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av"
+ %strong.author= link_to_issue_assignee(@issue)
- if @issue.milestone
- milestone = @issue.milestone
diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml
index dccfe625dd1..727fa0fd155 100644
--- a/app/views/milestones/show.html.haml
+++ b/app/views/milestones/show.html.haml
@@ -49,8 +49,6 @@
%tr
%td
= link_to [@project, issue] do
- = image_tag gravatar_icon(issue.assignee_email, 16), :width => "16"
- &nbsp;
%span.badge.badge-info ##{issue.id}
&ndash;
= truncate issue.title, :length => 60
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 486b9f656c8..fbd4031fa0b 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -12,7 +12,6 @@ describe Issue do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:author_id) }
it { should validate_presence_of(:project_id) }
- it { should validate_presence_of(:assignee_id) }
end
describe "Scope" do