From 2258db66c2e8ddccc1716b92f9d9a3a1cb3eff7f Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 27 Oct 2011 18:18:50 +0300 Subject: [PATCH 1/3] issue can be edit from show page --- app/views/issues/index.html.haml | 2 +- app/views/issues/show.html.haml | 9 +++++++++ app/views/issues/update.js.haml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index 56042fa2446..a70c65d47c6 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -45,7 +45,7 @@ }); $('.delete-issue').live('ajax:success', function() { - $(this).closest('tr').fadeOut(); }); + $(this).closest('tr').fadeOut(); updatePage();}); function setSortable(){ $('#issues-table>tbody').sortable({ diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 29b6f3f7b84..58bebe9b3de 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -3,6 +3,10 @@ .span-15 = simple_format html_escape(@issue.content) + + + .clear + %br .issue_notes= render "notes/notes" .span-8.right .span-8 @@ -39,5 +43,10 @@ - else = check_box_tag "closed", 1, @issue.closed, :disabled => true + + - if can?(current_user, :admin_issue, @issue) + .clear + = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true + .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" .clear diff --git a/app/views/issues/update.js.haml b/app/views/issues/update.js.haml index 30fca38c38e..137dba3cc71 100644 --- a/app/views/issues/update.js.haml +++ b/app/views/issues/update.js.haml @@ -6,7 +6,7 @@ - if @issue.valid? :plain $("#edit_issue_dialog").dialog("close"); - $.ajax({type: "GET", url: location.href, dataType: "script"}); + updatePage(); - else :plain $("#edit_issue_dialog").empty(); From 56d9761844b2665e9e48d50f15f7ac3a63d60618 Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Thu, 27 Oct 2011 18:46:30 +0300 Subject: [PATCH 2/3] moving out of body --- app/models/issue.rb | 6 +++--- app/views/issues/_form.html.haml | 8 ++++---- app/views/issues/_show.html.haml | 2 +- app/views/issues/show.html.haml | 8 ++------ db/migrate/20111027152724_issue_conten_to_note.rb | 11 +++++++++++ 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20111027152724_issue_conten_to_note.rb diff --git a/app/models/issue.rb b/app/models/issue.rb index ca1c5eaf52d..9fb7ef3060a 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -14,9 +14,9 @@ class Issue < ActiveRecord::Base :presence => true, :length => { :within => 0..255 } - validates :content, - :presence => true, - :length => { :within => 0..2000 } + #validates :content, + #:presence => true, + #:length => { :within => 0..2000 } scope :critical, where(:critical => true) scope :non_critical, where(:critical => false) diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index eae0ee0f52c..80f19d627f4 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -7,10 +7,10 @@ .span-8 = f.label :title - = f.text_field :title, :style => "width:450px" - .span-8 - = f.label :content - = f.text_area :content, :style => "width:450px; height:130px" + = f.text_area :title, :style => "width:450px; height:100px", :maxlength => 255 + -#.span-8 + -#= f.label :content + -#= f.text_area :content, :style => "width:450px; height:130px" .span-8.append-bottom = f.label :assignee_id = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }) diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index ebcaae29ef5..9cce2871331 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -7,7 +7,7 @@ = truncate issue.assignee.name, :lenght => 20 %td ##{issue.id} %td - = html_escape issue.title + = truncate(html_escape(issue.title), :length => 50) %br - if issue.critical %span.tag.high critical diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 58bebe9b3de..eb972d33abd 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,12 +1,8 @@ %h2 - = "Issue ##{@issue.id} - #{@issue.title}" + = "Issue ##{@issue.id} - #{truncate @issue.title, :length => 50}" .span-15 - = simple_format html_escape(@issue.content) - - - .clear - %br + -#= simple_format html_escape(@issue.content) .issue_notes= render "notes/notes" .span-8.right .span-8 diff --git a/db/migrate/20111027152724_issue_conten_to_note.rb b/db/migrate/20111027152724_issue_conten_to_note.rb new file mode 100644 index 00000000000..15d96c30b43 --- /dev/null +++ b/db/migrate/20111027152724_issue_conten_to_note.rb @@ -0,0 +1,11 @@ +class IssueContenToNote < ActiveRecord::Migration + def up + raise "Not ready" + Issue.find_each(:batch_size => 100) do |issue| + + end + end + + def down + end +end From a0171813391c8226802621a710798e376fea2f1e Mon Sep 17 00:00:00 2001 From: gitlabhq Date: Fri, 28 Oct 2011 12:22:09 +0300 Subject: [PATCH 3/3] new issue format --- app/assets/stylesheets/projects.css.scss | 4 +++ app/controllers/issues_controller.rb | 2 +- app/views/issues/_show.html.haml | 2 +- app/views/issues/show.html.haml | 13 +++++++-- .../20111027152724_issue_conten_to_note.rb | 27 +++++++++++++++++-- db/schema.rb | 2 +- spec/factories.rb | 1 - spec/requests/issues_spec.rb | 19 +++++++++++-- 8 files changed, 60 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index f9c7592bd91..bde9aa5d15f 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -662,6 +662,10 @@ tbody tr:nth-child(2n) td, tbody tr.even td { background: #4466cc; color:white; } + &.normal { + background: #2c5ca6; + color:white; + } &.notes { background: #2c5c66; color:white; diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 26e4a5734c2..d0fad8ed647 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -34,7 +34,7 @@ class IssuesController < ApplicationController end def show - @notes = @issue.notes + @notes = @issue.notes.order("created_at ASC") @note = @project.notes.new(:noteable => @issue) end diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index 9cce2871331..94cc03d17ae 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -7,7 +7,7 @@ = truncate issue.assignee.name, :lenght => 20 %td ##{issue.id} %td - = truncate(html_escape(issue.title), :length => 50) + = truncate(html_escape(issue.title), :length => 60) %br - if issue.critical %span.tag.high critical diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index eb972d33abd..c61052839f9 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,6 +1,5 @@ %h2 - = "Issue ##{@issue.id} - #{truncate @issue.title, :length => 50}" - + = "Issue ##{@issue.id} - #{html_escape(@issue.title)}" .span-15 -#= simple_format html_escape(@issue.content) .issue_notes= render "notes/notes" @@ -29,6 +28,16 @@ %td = image_tag gravatar_icon(@issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" = @issue.assignee.name + %tr + %td Tags + %td + - if @issue.critical + %span.tag.high critical + - else + %span.tag.normal normal + + - if @issue.today? + %span.tag.today today %tr %td Closed? %td diff --git a/db/migrate/20111027152724_issue_conten_to_note.rb b/db/migrate/20111027152724_issue_conten_to_note.rb index 15d96c30b43..c151a9317ff 100644 --- a/db/migrate/20111027152724_issue_conten_to_note.rb +++ b/db/migrate/20111027152724_issue_conten_to_note.rb @@ -1,8 +1,31 @@ class IssueContenToNote < ActiveRecord::Migration def up - raise "Not ready" + puts "Issue content is deprecated -> move to notes" Issue.find_each(:batch_size => 100) do |issue| - + next if issue.content.blank? + note = Note.new( + :note => issue.content, + :project_id => issue.project_id, + :noteable => issue, + :created_at => issue.created_at, + :updated_at => issue.created_at + ) + note.author_id = issue.author_id + + if note.save + issue.update_attributes(:content => nil) + print "." + else + print "F" + end + end + + total = Issue.where("content is not null").count + + if total > 0 + puts "content of #{total} issues were not migrated" + else + puts "Done" end end diff --git a/db/schema.rb b/db/schema.rb index 9c99e5328e5..e4f7379c379 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111027142641) do +ActiveRecord::Schema.define(:version => 20111027152724) do create_table "issues", :force => true do |t| t.string "title" diff --git a/spec/factories.rb b/spec/factories.rb index cc0cd4e5e8f..36aa4fc9454 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -32,7 +32,6 @@ end Factory.add(:issue, Issue) do |obj| obj.title = Faker::Lorem.sentence - obj.content = Faker::Lorem.sentences end Factory.add(:snippet, Snippet) do |obj| diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index 184f82931b7..b13e43adc6c 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -80,7 +80,6 @@ describe "Issues" do describe "fill in" do before do fill_in "issue_title", :with => "bug 345" - fill_in "issue_content", :with => "app bug 345" click_link "Select user" click_link @user.name end @@ -112,6 +111,23 @@ describe "Issues" do end end + describe "Show issue" do + before do + @issue = Factory :issue, + :author => @user, + :assignee => @user, + :project => project + + visit project_issue_path(project, @issue) + end + + it "should have valid show page for issue" do + page.should have_content @issue.title + page.should have_content @user.name + page.should have_content "today" + end + end + describe "Edit issue", :js => true do before do @issue = Factory :issue, @@ -129,7 +145,6 @@ describe "Issues" do describe "fill in" do before do fill_in "issue_title", :with => "bug 345" - fill_in "issue_content", :with => "app bug 345" end it { expect { click_button "Save" }.to_not change {Issue.count} }