Commit 3fa770dd107d01c29741032703c3f69b9ff3f072
Exists in
master
and in
4 other branches
Merge branch 'new_issue' into dev
Showing
12 changed files
with
84 additions
and
18 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
| @@ -662,6 +662,10 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | @@ -662,6 +662,10 @@ tbody tr:nth-child(2n) td, tbody tr.even td { | ||
| 662 | background: #4466cc; | 662 | background: #4466cc; |
| 663 | color:white; | 663 | color:white; |
| 664 | } | 664 | } |
| 665 | + &.normal { | ||
| 666 | + background: #2c5ca6; | ||
| 667 | + color:white; | ||
| 668 | + } | ||
| 665 | &.notes { | 669 | &.notes { |
| 666 | background: #2c5c66; | 670 | background: #2c5c66; |
| 667 | color:white; | 671 | color:white; |
app/controllers/issues_controller.rb
| @@ -34,7 +34,7 @@ class IssuesController < ApplicationController | @@ -34,7 +34,7 @@ class IssuesController < ApplicationController | ||
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | def show | 36 | def show |
| 37 | - @notes = @issue.notes | 37 | + @notes = @issue.notes.order("created_at ASC") |
| 38 | @note = @project.notes.new(:noteable => @issue) | 38 | @note = @project.notes.new(:noteable => @issue) |
| 39 | end | 39 | end |
| 40 | 40 |
app/models/issue.rb
| @@ -14,9 +14,9 @@ class Issue < ActiveRecord::Base | @@ -14,9 +14,9 @@ class Issue < ActiveRecord::Base | ||
| 14 | :presence => true, | 14 | :presence => true, |
| 15 | :length => { :within => 0..255 } | 15 | :length => { :within => 0..255 } |
| 16 | 16 | ||
| 17 | - validates :content, | ||
| 18 | - :presence => true, | ||
| 19 | - :length => { :within => 0..2000 } | 17 | + #validates :content, |
| 18 | + #:presence => true, | ||
| 19 | + #:length => { :within => 0..2000 } | ||
| 20 | 20 | ||
| 21 | scope :critical, where(:critical => true) | 21 | scope :critical, where(:critical => true) |
| 22 | scope :non_critical, where(:critical => false) | 22 | scope :non_critical, where(:critical => false) |
app/views/issues/_form.html.haml
| @@ -7,10 +7,10 @@ | @@ -7,10 +7,10 @@ | ||
| 7 | 7 | ||
| 8 | .span-8 | 8 | .span-8 |
| 9 | = f.label :title | 9 | = f.label :title |
| 10 | - = f.text_field :title, :style => "width:450px" | ||
| 11 | - .span-8 | ||
| 12 | - = f.label :content | ||
| 13 | - = f.text_area :content, :style => "width:450px; height:130px" | 10 | + = f.text_area :title, :style => "width:450px; height:100px", :maxlength => 255 |
| 11 | + -#.span-8 | ||
| 12 | + -#= f.label :content | ||
| 13 | + -#= f.text_area :content, :style => "width:450px; height:130px" | ||
| 14 | .span-8.append-bottom | 14 | .span-8.append-bottom |
| 15 | = f.label :assignee_id | 15 | = f.label :assignee_id |
| 16 | = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) | 16 | = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) |
app/views/issues/_show.html.haml
| @@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
| 7 | = truncate issue.assignee.name, :lenght => 20 | 7 | = truncate issue.assignee.name, :lenght => 20 |
| 8 | %td ##{issue.id} | 8 | %td ##{issue.id} |
| 9 | %td | 9 | %td |
| 10 | - = html_escape issue.title | 10 | + = truncate(html_escape(issue.title), :length => 60) |
| 11 | %br | 11 | %br |
| 12 | - if issue.critical | 12 | - if issue.critical |
| 13 | %span.tag.high critical | 13 | %span.tag.high critical |
app/views/issues/index.html.haml
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | }); | 45 | }); |
| 46 | 46 | ||
| 47 | $('.delete-issue').live('ajax:success', function() { | 47 | $('.delete-issue').live('ajax:success', function() { |
| 48 | - $(this).closest('tr').fadeOut(); }); | 48 | + $(this).closest('tr').fadeOut(); updatePage();}); |
| 49 | 49 | ||
| 50 | function setSortable(){ | 50 | function setSortable(){ |
| 51 | $('#issues-table>tbody').sortable({ | 51 | $('#issues-table>tbody').sortable({ |
app/views/issues/show.html.haml
| 1 | %h2 | 1 | %h2 |
| 2 | - = "Issue ##{@issue.id} - #{@issue.title}" | ||
| 3 | - | 2 | + = "Issue ##{@issue.id} - #{html_escape(@issue.title)}" |
| 4 | .span-15 | 3 | .span-15 |
| 5 | - = simple_format html_escape(@issue.content) | 4 | + -#= simple_format html_escape(@issue.content) |
| 6 | .issue_notes= render "notes/notes" | 5 | .issue_notes= render "notes/notes" |
| 7 | .span-8.right | 6 | .span-8.right |
| 8 | .span-8 | 7 | .span-8 |
| @@ -29,6 +28,16 @@ | @@ -29,6 +28,16 @@ | ||
| 29 | %td | 28 | %td |
| 30 | = image_tag gravatar_icon(@issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" | 29 | = image_tag gravatar_icon(@issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" |
| 31 | = @issue.assignee.name | 30 | = @issue.assignee.name |
| 31 | + %tr | ||
| 32 | + %td Tags | ||
| 33 | + %td | ||
| 34 | + - if @issue.critical | ||
| 35 | + %span.tag.high critical | ||
| 36 | + - else | ||
| 37 | + %span.tag.normal normal | ||
| 38 | + | ||
| 39 | + - if @issue.today? | ||
| 40 | + %span.tag.today today | ||
| 32 | %tr | 41 | %tr |
| 33 | %td Closed? | 42 | %td Closed? |
| 34 | %td | 43 | %td |
| @@ -39,5 +48,10 @@ | @@ -39,5 +48,10 @@ | ||
| 39 | - else | 48 | - else |
| 40 | = check_box_tag "closed", 1, @issue.closed, :disabled => true | 49 | = check_box_tag "closed", 1, @issue.closed, :disabled => true |
| 41 | 50 | ||
| 51 | + | ||
| 52 | + - if can?(current_user, :admin_issue, @issue) | ||
| 53 | + .clear | ||
| 54 | + = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true | ||
| 55 | + .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" | ||
| 42 | .clear | 56 | .clear |
| 43 | 57 |
app/views/issues/update.js.haml
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | - if @issue.valid? | 6 | - if @issue.valid? |
| 7 | :plain | 7 | :plain |
| 8 | $("#edit_issue_dialog").dialog("close"); | 8 | $("#edit_issue_dialog").dialog("close"); |
| 9 | - $.ajax({type: "GET", url: location.href, dataType: "script"}); | 9 | + updatePage(); |
| 10 | - else | 10 | - else |
| 11 | :plain | 11 | :plain |
| 12 | $("#edit_issue_dialog").empty(); | 12 | $("#edit_issue_dialog").empty(); |
| @@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
| 1 | +class IssueContenToNote < ActiveRecord::Migration | ||
| 2 | + def up | ||
| 3 | + puts "Issue content is deprecated -> move to notes" | ||
| 4 | + Issue.find_each(:batch_size => 100) do |issue| | ||
| 5 | + next if issue.content.blank? | ||
| 6 | + note = Note.new( | ||
| 7 | + :note => issue.content, | ||
| 8 | + :project_id => issue.project_id, | ||
| 9 | + :noteable => issue, | ||
| 10 | + :created_at => issue.created_at, | ||
| 11 | + :updated_at => issue.created_at | ||
| 12 | + ) | ||
| 13 | + note.author_id = issue.author_id | ||
| 14 | + | ||
| 15 | + if note.save | ||
| 16 | + issue.update_attributes(:content => nil) | ||
| 17 | + print "." | ||
| 18 | + else | ||
| 19 | + print "F" | ||
| 20 | + end | ||
| 21 | + end | ||
| 22 | + | ||
| 23 | + total = Issue.where("content is not null").count | ||
| 24 | + | ||
| 25 | + if total > 0 | ||
| 26 | + puts "content of #{total} issues were not migrated" | ||
| 27 | + else | ||
| 28 | + puts "Done" | ||
| 29 | + end | ||
| 30 | + end | ||
| 31 | + | ||
| 32 | + def down | ||
| 33 | + end | ||
| 34 | +end |
db/schema.rb
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | # | 11 | # |
| 12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
| 13 | 13 | ||
| 14 | -ActiveRecord::Schema.define(:version => 20111027142641) do | 14 | +ActiveRecord::Schema.define(:version => 20111027152724) do |
| 15 | 15 | ||
| 16 | create_table "issues", :force => true do |t| | 16 | create_table "issues", :force => true do |t| |
| 17 | t.string "title" | 17 | t.string "title" |
spec/factories.rb
| @@ -32,7 +32,6 @@ end | @@ -32,7 +32,6 @@ end | ||
| 32 | 32 | ||
| 33 | Factory.add(:issue, Issue) do |obj| | 33 | Factory.add(:issue, Issue) do |obj| |
| 34 | obj.title = Faker::Lorem.sentence | 34 | obj.title = Faker::Lorem.sentence |
| 35 | - obj.content = Faker::Lorem.sentences | ||
| 36 | end | 35 | end |
| 37 | 36 | ||
| 38 | Factory.add(:snippet, Snippet) do |obj| | 37 | Factory.add(:snippet, Snippet) do |obj| |
spec/requests/issues_spec.rb
| @@ -80,7 +80,6 @@ describe "Issues" do | @@ -80,7 +80,6 @@ describe "Issues" do | ||
| 80 | describe "fill in" do | 80 | describe "fill in" do |
| 81 | before do | 81 | before do |
| 82 | fill_in "issue_title", :with => "bug 345" | 82 | fill_in "issue_title", :with => "bug 345" |
| 83 | - fill_in "issue_content", :with => "app bug 345" | ||
| 84 | click_link "Select user" | 83 | click_link "Select user" |
| 85 | click_link @user.name | 84 | click_link @user.name |
| 86 | end | 85 | end |
| @@ -112,6 +111,23 @@ describe "Issues" do | @@ -112,6 +111,23 @@ describe "Issues" do | ||
| 112 | end | 111 | end |
| 113 | end | 112 | end |
| 114 | 113 | ||
| 114 | + describe "Show issue" do | ||
| 115 | + before do | ||
| 116 | + @issue = Factory :issue, | ||
| 117 | + :author => @user, | ||
| 118 | + :assignee => @user, | ||
| 119 | + :project => project | ||
| 120 | + | ||
| 121 | + visit project_issue_path(project, @issue) | ||
| 122 | + end | ||
| 123 | + | ||
| 124 | + it "should have valid show page for issue" do | ||
| 125 | + page.should have_content @issue.title | ||
| 126 | + page.should have_content @user.name | ||
| 127 | + page.should have_content "today" | ||
| 128 | + end | ||
| 129 | + end | ||
| 130 | + | ||
| 115 | describe "Edit issue", :js => true do | 131 | describe "Edit issue", :js => true do |
| 116 | before do | 132 | before do |
| 117 | @issue = Factory :issue, | 133 | @issue = Factory :issue, |
| @@ -129,7 +145,6 @@ describe "Issues" do | @@ -129,7 +145,6 @@ describe "Issues" do | ||
| 129 | describe "fill in" do | 145 | describe "fill in" do |
| 130 | before do | 146 | before do |
| 131 | fill_in "issue_title", :with => "bug 345" | 147 | fill_in "issue_title", :with => "bug 345" |
| 132 | - fill_in "issue_content", :with => "app bug 345" | ||
| 133 | end | 148 | end |
| 134 | 149 | ||
| 135 | it { expect { click_button "Save" }.to_not change {Issue.count} } | 150 | it { expect { click_button "Save" }.to_not change {Issue.count} } |