Commit 88c625e3f718eb2dffcae7e8d2d03a86a51cd309
1 parent
6abc6495
Exists in
master
and in
4 other branches
Issues can be unassigned now
Showing
8 changed files
with
29 additions
and
17 deletions
Show diff stats
app/assets/images/no_avatar.png
app/models/issue.rb
... | ... | @@ -11,7 +11,6 @@ class Issue < ActiveRecord::Base |
11 | 11 | attr_accessor :author_id_of_changes |
12 | 12 | |
13 | 13 | validates_presence_of :project_id |
14 | - validates_presence_of :assignee_id | |
15 | 14 | validates_presence_of :author_id |
16 | 15 | |
17 | 16 | delegate :name, |
... | ... | @@ -22,6 +21,7 @@ class Issue < ActiveRecord::Base |
22 | 21 | delegate :name, |
23 | 22 | :email, |
24 | 23 | :to => :assignee, |
24 | + :allow_nil => true, | |
25 | 25 | :prefix => true |
26 | 26 | |
27 | 27 | validates :title, |
... | ... | @@ -56,6 +56,10 @@ class Issue < ActiveRecord::Base |
56 | 56 | today? && created_at == updated_at |
57 | 57 | end |
58 | 58 | |
59 | + def is_assigned? | |
60 | + !!assignee_id | |
61 | + end | |
62 | + | |
59 | 63 | def is_being_reassigned? |
60 | 64 | assignee_id_changed? |
61 | 65 | end | ... | ... |
app/observers/issue_observer.rb
... | ... | @@ -2,7 +2,9 @@ class IssueObserver < ActiveRecord::Observer |
2 | 2 | cattr_accessor :current_user |
3 | 3 | |
4 | 4 | def after_create(issue) |
5 | - Notify.new_issue_email(issue.id).deliver if issue.assignee != current_user | |
5 | + if issue.assignee && issue.assignee != current_user | |
6 | + Notify.new_issue_email(issue.id).deliver | |
7 | + end | |
6 | 8 | end |
7 | 9 | |
8 | 10 | def after_update(issue) |
... | ... | @@ -14,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer |
14 | 16 | protected |
15 | 17 | |
16 | 18 | def send_reassigned_email(issue) |
17 | - recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id } | |
19 | + recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id } | |
18 | 20 | |
19 | 21 | recipient_ids.each do |recipient_id| |
20 | 22 | Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver | ... | ... |
app/views/issues/_form.html.haml
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | = f.text_field :title, :maxlength => 255, :class => "xxlarge" |
15 | 15 | .issue_middle_block |
16 | 16 | .issue_assignee |
17 | - = f.label :assignee_id, "Assign to *" | |
17 | + = f.label :assignee_id, "Assign to" | |
18 | 18 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" }) |
19 | 19 | .issue_milestone |
20 | 20 | = f.label :milestone_id | ... | ... |
app/views/issues/_show.html.haml
... | ... | @@ -15,12 +15,20 @@ |
15 | 15 | %i.icon-edit |
16 | 16 | Edit |
17 | 17 | |
18 | - = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" | |
19 | - %span.update-author | |
20 | - assigned to | |
21 | - %strong= issue.assignee_name | |
22 | - - if issue.upvotes > 0 | |
23 | - %span.badge.badge-success= "+#{issue.upvotes}" | |
24 | - | |
18 | + - if issue.assignee | |
19 | + = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" | |
20 | + %span.update-author | |
21 | + assigned to | |
22 | + %strong= issue.assignee_name | |
23 | + - if issue.upvotes > 0 | |
24 | + %span.badge.badge-success= "+#{issue.upvotes}" | |
25 | + | |
26 | + - else | |
27 | + = image_tag "no_avatar.png", :class => "avatar" | |
28 | + %span.update-author | |
29 | + Unassigned | |
30 | + - if issue.upvotes > 0 | |
31 | + %span.badge.badge-success= "+#{issue.upvotes}" | |
32 | + | |
25 | 33 | = link_to project_issue_path(issue.project, issue) do |
26 | 34 | %p.row_title= truncate(issue.title, :length => 100) | ... | ... |
app/views/issues/show.html.haml
... | ... | @@ -38,9 +38,10 @@ |
38 | 38 | = image_tag gravatar_icon(@issue.author_email), :width => 16, :class => "lil_av" |
39 | 39 | %strong.author= link_to_issue_author(@issue) |
40 | 40 | |
41 | - %cite.cgray and currently assigned to | |
42 | - = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" | |
43 | - %strong.author= link_to_issue_assignee(@issue) | |
41 | + - if @issue.assignee | |
42 | + %cite.cgray and currently assigned to | |
43 | + = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" | |
44 | + %strong.author= link_to_issue_assignee(@issue) | |
44 | 45 | |
45 | 46 | - if @issue.milestone |
46 | 47 | - milestone = @issue.milestone | ... | ... |
app/views/milestones/show.html.haml
spec/models/issue_spec.rb
... | ... | @@ -12,7 +12,6 @@ describe Issue do |
12 | 12 | it { should validate_presence_of(:title) } |
13 | 13 | it { should validate_presence_of(:author_id) } |
14 | 14 | it { should validate_presence_of(:project_id) } |
15 | - it { should validate_presence_of(:assignee_id) } | |
16 | 15 | end |
17 | 16 | |
18 | 17 | describe "Scope" do | ... | ... |