OSDN Git Service

Issues can be unassigned now
authorrandx <dmitriy.zaporozhets@gmail.com>
Tue, 26 Jun 2012 18:47:25 +0000 (21:47 +0300)
committerrandx <dmitriy.zaporozhets@gmail.com>
Tue, 26 Jun 2012 18:47:25 +0000 (21:47 +0300)
app/assets/images/no_avatar.png
app/models/issue.rb
app/observers/issue_observer.rb
app/views/issues/_form.html.haml
app/views/issues/_show.html.haml
app/views/issues/show.html.haml
app/views/milestones/show.html.haml
spec/models/issue_spec.rb

index 99e5fd9..752d26a 100644 (file)
Binary files a/app/assets/images/no_avatar.png and b/app/assets/images/no_avatar.png differ
index fa2aa2f..40e14da 100644 (file)
@@ -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
index fadedd3..92b0f83 100644 (file)
@@ -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
index 4dcba4f..444fbd7 100644 (file)
@@ -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
index de27555..b6b5d72 100644 (file)
         %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)
index 0d3c4e1..1bb4e04 100644 (file)
     = 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
index dccfe62..727fa0f 100644 (file)
@@ -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
index 486b9f6..fbd4031 100644 (file)
@@ -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