Commit e4cf99db4615f406dfc60bfc8bca473581b4f910

Authored by randx
1 parent 53a3be03

Refactor milestones related functionality. Added seeds for Milestine and MR

app/models/issue.rb
... ... @@ -7,8 +7,6 @@ class Issue < ActiveRecord::Base
7 7  
8 8 acts_as_taggable_on :labels
9 9  
10   - belongs_to :milestone
11   -
12 10 validates :description, length: { within: 0..2000 }
13 11  
14 12 def self.open_for(user)
... ...
app/models/merge_request.rb
... ... @@ -10,8 +10,6 @@ class MergeRequest < ActiveRecord::Base
10 10  
11 11 attr_accessor :should_remove_source_branch
12 12  
13   - belongs_to :milestone
14   -
15 13 BROKEN_DIFF = "--broken-diff"
16 14  
17 15 UNCHECKED = 1
... ...
app/roles/issue_commonality.rb
... ... @@ -6,6 +6,7 @@ module IssueCommonality
6 6 belongs_to :project
7 7 belongs_to :author, class_name: "User"
8 8 belongs_to :assignee, class_name: "User"
  9 + belongs_to :milestone
9 10 has_many :notes, as: :noteable, dependent: :destroy
10 11  
11 12 validates :project, presence: true
... ...
app/views/merge_requests/_merge_request.html.haml
... ... @@ -13,7 +13,7 @@
13 13 - if merge_request.milestone_id?
14 14 %span.btn.small.disabled.grouped
15 15 %i.icon-time
16   - = merge_request.project.milestones.find(merge_request.milestone_id).title
  16 + = merge_request.milestone.title
17 17 %span.btn.small.disabled.grouped
18 18 = merge_request.source_branch
19 19 →
... ...
app/views/milestones/_milestone.html.haml
... ... @@ -13,9 +13,9 @@
13 13 .bar{style: "width: #{milestone.percent_complete}%;"}
14 14 .span6
15 15 - if milestone.issues.any?
16   - = link_to project_issues_path(milestone.project, milestone_id: milestone.id), class: "btn very_small" do
17   - %strong= pluralize milestone.issues.count, 'Issue'
18   -
  16 + = link_to project_issues_path(milestone.project, milestone_id: milestone.id) do
  17 + = pluralize milestone.issues.count, 'Issue'
  18 +  
19 19 - if milestone.merge_requests.any?
20   - = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id), class: "btn very_small" do
21   - %strong= pluralize milestone.merge_requests.count, 'Merge Request'
  20 + = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id) do
  21 + = pluralize milestone.merge_requests.count, 'Merge Request'
... ...
db/fixtures/development/007_milestones.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +Milestone.seed(:id, [
  2 + { :id => 1, :project_id => 1, :title => 'v' + Faker::Address.zip_code },
  3 + { :id => 2, :project_id => 1, :title => 'v' + Faker::Address.zip_code },
  4 + { :id => 3, :project_id => 1, :title => 'v' + Faker::Address.zip_code },
  5 + { :id => 4, :project_id => 2, :title => 'v' + Faker::Address.zip_code },
  6 + { :id => 5, :project_id => 2, :title => 'v' + Faker::Address.zip_code },
  7 +
  8 + { :id => 6, :project_id => 2, :title => 'v' + Faker::Address.zip_code },
  9 + { :id => 7, :project_id => 2, :title => 'v' + Faker::Address.zip_code },
  10 + { :id => 8, :project_id => 3, :title => 'v' + Faker::Address.zip_code },
  11 + { :id => 9, :project_id => 3, :title => 'v' + Faker::Address.zip_code },
  12 + { :id => 11, :project_id => 3, :title => 'v' + Faker::Address.zip_code },
  13 +])
... ...
db/fixtures/development/008_merge_requests.rb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +MergeRequest.seed(:id, [
  2 + { :id => 1, milestone_id: 1, project_id: 1, source_branch: 'master', target_branch: 'feature', author_id: 1, assignee_id: 1, title: Faker::Lorem.sentence(6) },
  3 + { :id => 2, milestone_id: 1, project_id: 1, source_branch: 'master', target_branch: 'feature', author_id: 2, assignee_id: 2, title: Faker::Lorem.sentence(6) },
  4 + { :id => 3, milestone_id: 1, project_id: 1, source_branch: 'master', target_branch: 'feature', author_id: 3, assignee_id: 3, title: Faker::Lorem.sentence(6) },
  5 + { :id => 4, milestone_id: 1, project_id: 1, source_branch: 'master', target_branch: 'feature', author_id: 4, assignee_id: 4, title: Faker::Lorem.sentence(6) },
  6 + { :id => 5, milestone_id: 1, project_id: 1, source_branch: 'master', target_branch: 'feature', author_id: 5, assignee_id: 5, title: Faker::Lorem.sentence(6) },
  7 +
  8 + { :id => 6, milestone_id: 5, project_id: 2, source_branch: 'master', target_branch: 'feature', author_id: 1, assignee_id: 1, title: Faker::Lorem.sentence(6) },
  9 + { :id => 7, milestone_id: 6, project_id: 2, source_branch: 'master', target_branch: 'feature', author_id: 2, assignee_id: 2, title: Faker::Lorem.sentence(6) },
  10 + { :id => 8, milestone_id: 6, project_id: 2, source_branch: 'master', target_branch: 'feature', author_id: 3, assignee_id: 3, title: Faker::Lorem.sentence(6) },
  11 + { :id => 9, milestone_id: 6, project_id: 2, source_branch: 'master', target_branch: 'feature', author_id: 4, assignee_id: 4, title: Faker::Lorem.sentence(6) },
  12 + { :id => 11, milestone_id: 5, project_id: 2, source_branch: 'master', target_branch: 'feature', author_id: 5, assignee_id: 5, title: Faker::Lorem.sentence(6) },
  13 +
  14 + { :id => 12, milestone_id: 9, project_id: 3, source_branch: 'master', target_branch: 'feature', author_id: 1, assignee_id: 1, title: Faker::Lorem.sentence(6)},
  15 + { :id => 13, milestone_id: 9, project_id: 3, source_branch: 'master', target_branch: 'feature', author_id: 2, assignee_id: 2, title: Faker::Lorem.sentence(6)},
  16 + { :id => 14, milestone_id: 9, project_id: 3, source_branch: 'master', target_branch: 'feature', author_id: 3, assignee_id: 3, title: Faker::Lorem.sentence(6)},
  17 + { :id => 15, milestone_id: 9, project_id: 3, source_branch: 'master', target_branch: 'feature', author_id: 4, assignee_id: 4, title: Faker::Lorem.sentence(6)},
  18 + { :id => 16, milestone_id: 9, project_id: 3, source_branch: 'master', target_branch: 'feature', author_id: 5, assignee_id: 5, title: Faker::Lorem.sentence(6)},
  19 +])
... ...