Commit 1d69788099f4c28c8b6795cacc9a1ffaa8600ee0

Authored by Dmitriy Zaporozhets
1 parent 016012b1

fix encoding error, issues critical status added

app/assets/stylesheets/projects.css.scss
... ... @@ -647,3 +647,37 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
647 647 background: none repeat scroll 0 0 #FFBBBB
648 648 }
649 649 }
  650 +
  651 +.tag {
  652 + @include round-borders-all(4px);
  653 + padding:2px 4px;
  654 + border:none;
  655 +
  656 + &.high {
  657 + background: #D12F19;
  658 + color:white;
  659 + }
  660 +
  661 + &.today {
  662 + background: #44aa22;
  663 + color:white;
  664 + }
  665 +
  666 + &.yours {
  667 + background: #4466cc;
  668 + color:white;
  669 + }
  670 + &.notes {
  671 + background: #2c5c66;
  672 + color:white;
  673 + }
  674 +}
  675 +
  676 +#issues-table .issue {
  677 + &.critical {
  678 + td {
  679 + //background: #D12F19;
  680 + //color:#fff;
  681 + }
  682 + }
  683 +}
... ...
app/controllers/issues_controller.rb
... ... @@ -12,7 +12,7 @@ class IssuesController < ApplicationController
12 12  
13 13 def index
14 14 @issues = case params[:f].to_i
15   - when 1 then @project.issues.all
  15 + when 1 then @project.issues
16 16 when 2 then @project.issues.closed
17 17 when 3 then @project.issues.opened.assigned(current_user)
18 18 else @project.issues.opened
... ...
app/models/issue.rb
... ... @@ -18,11 +18,22 @@ class Issue < ActiveRecord::Base
18 18 :presence => true,
19 19 :length => { :within => 0..2000 }
20 20  
  21 + scope :critical, where(:critical => true)
  22 + scope :non_critical, where(:critical => false)
  23 +
21 24 scope :opened, where(:closed => false)
22 25 scope :closed, where(:closed => true)
23 26 scope :assigned, lambda { |u| where(:assignee_id => u.id)}
24 27  
25 28 acts_as_list
  29 +
  30 + def today?
  31 + Date.today == created_at.to_date
  32 + end
  33 +
  34 + def new?
  35 + today? && created_at == updated_at
  36 + end
26 37 end
27 38 # == Schema Information
28 39 #
... ...
app/views/commits/_commits.html.haml
... ... @@ -11,7 +11,7 @@
11 11 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
12 12 %p
13 13 %strong
14   - = commit.truncated_message
  14 + = truncate(commit.safe_message, :length => 60)
15 15 = link_to "Browse Code", tree_project_path(@project, :commit_id => commit.id), :class => "lite_button", :style => "float:right"
16 16 = link_to truncate(commit.id.to_s, :length => 16), project_commit_path(@project, :id => commit.id), :class => "lite_button", :style => "width:120px;float:right"
17 17 %span
... ...
app/views/commits/show.html.haml
1 1 %h3
2   - = "[ #{@commit.committer} ] #{@commit.truncated_message(40)}"
  2 + = "[ #{@commit.committer} ] #{truncate(@commit.safe_message)}"
3 3 -#= link_to 'Back', project_commits_path(@project), :class => "button"
4 4 %table.round-borders
5 5 %tr
... ... @@ -16,7 +16,7 @@
16 16 %td= @commit.committed_date
17 17 %tr
18 18 %td Message
19   - %td= @commit.message
  19 + %td= @commit.safe_message
20 20 %tr
21 21 %td Tree
22 22 %td= link_to 'Browse Code', tree_project_path(@project, :commit_id => @commit.id)
... ...
app/views/issues/_form.html.haml
... ... @@ -5,17 +5,21 @@
5 5 - @issue.errors.full_messages.each do |msg|
6 6 %li= msg
7 7  
8   - .span-6
  8 + .span-8
9 9 = f.label :title
10 10 = f.text_field :title, :style => "width:450px"
11   - .span-6
  11 + .span-8
12 12 = f.label :content
13 13 = f.text_area :content, :style => "width:450px; height:130px"
14   - .span-6.append-bottom
  14 + .span-8.append-bottom
15 15 = f.label :assignee_id
16 16 = f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" })
  17 + .span-1
  18 + = f.label :critical, "Critical"
  19 + %br
  20 + = f.check_box :critical
17 21 - unless @issue.new_record?
18   - .span-3.right
  22 + .span-2.right
19 23 = f.label :closed
20 24 %br
21 25 = f.check_box :closed
... ...
app/views/issues/_issues.html.haml
1 1 %table.round-borders#issues-table
2 2 %tr
  3 + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
  4 + %th
3 5 %th Assignee
4 6 %th ID
5 7 %th Title
6 8 %th Closed?
7 9 %th
8 10  
9   - - @issues.each do |issue|
  11 + - @issues.critical.each do |issue|
  12 + = render(:partial => 'show', :locals => {:issue => issue})
  13 +
  14 + - @issues.non_critical.each do |issue|
10 15 = render(:partial => 'show', :locals => {:issue => issue})
... ...
app/views/issues/_show.html.haml
1   -%tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) }
  1 +%tr{ :id => dom_id(issue), :class => "issue #{issue.critical ? "critical" : ""}", :url => project_issue_path(@project, issue) }
  2 + - if can?(current_user, :admin_issue, @project) && !params[:f] || params[:f] == "0"
  3 + %td
  4 + = image_tag "move.png" , :class => [:handle, :left]
2 5 %td
3   - = image_tag "move.png" , :class => [:handle, :left]
4 6 = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
5 7 = truncate issue.assignee.name, :lenght => 20
6 8 %td ##{issue.id}
7   - %td= html_escape issue.title
  9 + %td
  10 + = html_escape issue.title
  11 + %br
  12 + - if issue.critical
  13 + %span.tag.high critical
  14 + - if issue.today?
  15 + %span.tag.today today
  16 + -#- if issue.author == current_user
  17 + -#%span.tag.yours yours
  18 + -#- if issue.notes.count > 0
  19 + -#%span.tag.notes
  20 + -#= issue.notes.count
  21 + -#notes
8 22 %td
9 23 - if can? current_user, :write_issue, @project
10 24 = form_for([@project, issue], :remote => true) do |f|
... ...
app/views/projects/_recent_commits.html.haml
... ... @@ -6,7 +6,7 @@
6 6 = image_tag "no_avatar.png", :class => "left", :width => 40, :style => "padding-right:5px;"
7 7 %p{:style => "margin-bottom: 3px;"}
8 8 %strong
9   - = link_to commit.truncated_message(60), project_commit_path(@project, :id => commit.id)
  9 + = link_to truncate(commit.safe_message, :length => 60), project_commit_path(@project, :id => commit.id)
10 10  
11 11 %span
12 12 %span.author
... ...
app/views/projects/_recent_messages.html.haml
... ... @@ -19,7 +19,7 @@
19 19 - css_class = "dash_commit"
20 20 - commit = parent
21 21 - item_code = commit.author.email
22   - - link_item_name = commit.truncated_message(50)
  22 + - link_item_name = truncate(commit.safe_message, :length => 50)
23 23 - link_to_item = project_commit_path(@project, :id => commit.id)
24 24 - else
25 25 - css_class = "dash_wall"
... ...
app/views/projects/_tree_item.html.haml
... ... @@ -12,4 +12,4 @@
12 12 = time_ago_in_words(content_commit.committed_date)
13 13 ago
14 14 %td
15   - = link_to content_commit.truncated_message(40), project_commit_path(@project, content_commit)
  15 + = link_to truncate(content_commit.safe_message, :length => 40), project_commit_path(@project, content_commit)
... ...
db/migrate/20111025134235_add_high_label_to_issue.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class AddHighLabelToIssue < ActiveRecord::Migration
  2 + def change
  3 + add_column :issues, :critical, :boolean, :default => false, :null => false
  4 + end
  5 +end
... ...
db/schema.rb
... ... @@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(:version => 20111021101550) do
  14 +ActiveRecord::Schema.define(:version => 20111025134235) do
15 15  
16 16 create_table "issues", :force => true do |t|
17 17 t.string "title"
... ... @@ -23,6 +23,7 @@ ActiveRecord::Schema.define(:version =&gt; 20111021101550) do
23 23 t.datetime "updated_at"
24 24 t.boolean "closed", :default => false, :null => false
25 25 t.integer "position", :default => 0
  26 + t.boolean "critical", :default => false, :null => false
26 27 end
27 28  
28 29 create_table "keys", :force => true do |t|
... ...
lib/commit_ext.rb
1 1 module CommitExt
2   - # Cause of encoding rails truncate raise error
3   - # this method is temporary decision
4   - def truncated_message(size = 80)
5   - message.length > size ? (message[0..(size - 1)] + "...") : message
  2 + def safe_message
  3 + message.encode("UTF-8",
  4 + :invalid => :replace,
  5 + :undef => :replace,
  6 + :universal_newline => true,
  7 + :replace => "")
6 8 rescue
7 9 "-- invalid encoding for commit message"
8 10 end
... ...
spec/requests/team_members_spec.rb
... ... @@ -10,7 +10,9 @@ describe &quot;TeamMembers&quot; do
10 10 describe "View profile" do
11 11 it "should be available" do
12 12 visit(team_project_path(@project))
13   - find(:xpath, "//table[@id='team-table']//a[1]").click
  13 + within "#team-table" do
  14 + click_link(@user.name)
  15 + end
14 16 page.should have_content @user.skype
15 17 page.should_not have_content 'Twitter'
16 18 end
... ...