From 36dbac2fd90c12a74781c9982db8f18bae938265 Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 30 Oct 2012 10:03:21 +0200 Subject: [PATCH] More seeds --- app/views/milestones/_milestone.html.haml | 17 ++++---- db/fixtures/development/005_issues.rb | 40 ------------------- .../{007_milestones.rb => 005_milestones.rb} | 0 db/fixtures/development/007_issues.rb | 20 ++++++++++ db/fixtures/development/008_merge_requests.rb | 37 +++++++++-------- 5 files changed, 49 insertions(+), 65 deletions(-) delete mode 100644 db/fixtures/development/005_issues.rb rename db/fixtures/development/{007_milestones.rb => 005_milestones.rb} (100%) create mode 100644 db/fixtures/development/007_issues.rb diff --git a/app/views/milestones/_milestone.html.haml b/app/views/milestones/_milestone.html.haml index c28fb186..7c4c0e67 100644 --- a/app/views/milestones/_milestone.html.haml +++ b/app/views/milestones/_milestone.html.haml @@ -9,13 +9,14 @@ %small = milestone.expires_at .row - .progress.progress-info.span4 - .bar{style: "width: #{milestone.percent_complete}%;"} + .span4 + .progress.progress-info + .bar{style: "width: #{milestone.percent_complete}%;"} .span6 - - if milestone.issues.any? - = link_to project_issues_path(milestone.project, milestone_id: milestone.id) do - = pluralize milestone.issues.count, 'Issue' + = link_to project_issues_path(milestone.project, milestone_id: milestone.id) do + = pluralize milestone.issues.count, 'Issue'   - - if milestone.merge_requests.any? - = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id) do - = pluralize milestone.merge_requests.count, 'Merge Request' + = link_to project_merge_requests_path(milestone.project, milestone_id: milestone.id) do + = pluralize milestone.merge_requests.count, 'Merge Request' +   + %span.light #{milestone.percent_complete}% complete diff --git a/db/fixtures/development/005_issues.rb b/db/fixtures/development/005_issues.rb deleted file mode 100644 index 32375387..00000000 --- a/db/fixtures/development/005_issues.rb +++ /dev/null @@ -1,40 +0,0 @@ -Issue.seed(:id, [ - { :id => 1, :project_id => 1, :author_id => 1, :assignee_id => 1, :title => Faker::Lorem.sentence(6) }, - { :id => 2, :project_id => 1, :author_id => 2, :assignee_id => 2, :title => Faker::Lorem.sentence(6) }, - { :id => 3, :project_id => 1, :author_id => 3, :assignee_id => 3, :title => Faker::Lorem.sentence(6) }, - { :id => 4, :project_id => 1, :author_id => 4, :assignee_id => 4, :title => Faker::Lorem.sentence(6) }, - { :id => 5, :project_id => 1, :author_id => 5, :assignee_id => 5, :title => Faker::Lorem.sentence(6) }, - - { :id => 6, :project_id => 2, :author_id => 1, :assignee_id => 1, :title => Faker::Lorem.sentence(6) }, - { :id => 7, :project_id => 2, :author_id => 2, :assignee_id => 2, :title => Faker::Lorem.sentence(6) }, - { :id => 8, :project_id => 2, :author_id => 3, :assignee_id => 3, :title => Faker::Lorem.sentence(6) }, - { :id => 9, :project_id => 2, :author_id => 4, :assignee_id => 4, :title => Faker::Lorem.sentence(6) }, - { :id => 11, :project_id => 2, :author_id => 5, :assignee_id => 5, :title => Faker::Lorem.sentence(6) }, - - { :id => 12, :project_id => 3, :author_id => 1, :assignee_id => 1, :title => Faker::Lorem.sentence(6)}, - { :id => 13, :project_id => 3, :author_id => 2, :assignee_id => 2, :title => Faker::Lorem.sentence(6)}, - { :id => 14, :project_id => 3, :author_id => 3, :assignee_id => 3, :title => Faker::Lorem.sentence(6)}, - { :id => 15, :project_id => 3, :author_id => 4, :assignee_id => 4, :title => Faker::Lorem.sentence(6)}, - { :id => 16, :project_id => 3, :author_id => 5, :assignee_id => 5, :title => Faker::Lorem.sentence(6)}, - - { :id => 21, :project_id => 1, :author_id => 1, :assignee_id => 1, :title => Faker::Lorem.sentence(6) }, - { :id => 22, :project_id => 1, :author_id => 2, :assignee_id => 2, :title => Faker::Lorem.sentence(6) }, - { :id => 23, :project_id => 1, :author_id => 3, :assignee_id => 3, :title => Faker::Lorem.sentence(6) }, - { :id => 24, :project_id => 1, :author_id => 4, :assignee_id => 4, :title => Faker::Lorem.sentence(6) }, - { :id => 25, :project_id => 1, :author_id => 5, :assignee_id => 5, :title => Faker::Lorem.sentence(6) }, - - { :id => 26, :project_id => 2, :author_id => 1, :assignee_id => 1, :title => Faker::Lorem.sentence(6) }, - { :id => 27, :project_id => 2, :author_id => 2, :assignee_id => 2, :title => Faker::Lorem.sentence(6) }, - { :id => 28, :project_id => 2, :author_id => 3, :assignee_id => 3, :title => Faker::Lorem.sentence(6) }, - { :id => 29, :project_id => 2, :author_id => 4, :assignee_id => 4, :title => Faker::Lorem.sentence(6) }, - { :id => 30, :project_id => 2, :author_id => 5, :assignee_id => 5, :title => Faker::Lorem.sentence(6) }, - - { :id => 32, :project_id => 3, :author_id => 1, :assignee_id => 1, :title => Faker::Lorem.sentence(6)}, - { :id => 33, :project_id => 3, :author_id => 2, :assignee_id => 2, :title => Faker::Lorem.sentence(6)}, - { :id => 34, :project_id => 3, :author_id => 3, :assignee_id => 3, :title => Faker::Lorem.sentence(6)}, - { :id => 35, :project_id => 3, :author_id => 4, :assignee_id => 4, :title => Faker::Lorem.sentence(6)}, - { :id => 36, :project_id => 3, :author_id => 5, :assignee_id => 5, :title => Faker::Lorem.sentence(6)} -]) - - - diff --git a/db/fixtures/development/007_milestones.rb b/db/fixtures/development/005_milestones.rb similarity index 100% rename from db/fixtures/development/007_milestones.rb rename to db/fixtures/development/005_milestones.rb diff --git a/db/fixtures/development/007_issues.rb b/db/fixtures/development/007_issues.rb new file mode 100644 index 00000000..d60af71e --- /dev/null +++ b/db/fixtures/development/007_issues.rb @@ -0,0 +1,20 @@ +(1..300).each do |i| + # Random Project + project_id = rand(2) + 1 + project = Project.find(project_id) + + # Random user + user = project.users.sample + user_id = user.id + IssueObserver.current_user = user + + Issue.seed(:id, [{ + id: i, + project_id: project_id, + author_id: user_id, + assignee_id: user_id, + closed: [true, false].sample, + milestone: project.milestones.sample, + title: Faker::Lorem.sentence(6) + }]) +end diff --git a/db/fixtures/development/008_merge_requests.rb b/db/fixtures/development/008_merge_requests.rb index 6e0d67c4..8d20e628 100644 --- a/db/fixtures/development/008_merge_requests.rb +++ b/db/fixtures/development/008_merge_requests.rb @@ -1,19 +1,22 @@ -MergeRequest.seed(:id, [ - { :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) }, - { :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) }, - { :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) }, - { :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) }, - { :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) }, +(1..300).each do |i| + # Random Project + project_id = rand(2) + 1 + project = Project.find(project_id) - { :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) }, - { :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) }, - { :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) }, - { :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) }, - { :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) }, + # Random user + user = project.users.sample + user_id = user.id + MergeRequestObserver.current_user = user - { :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)}, - { :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)}, - { :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)}, - { :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)}, - { :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)}, -]) + MergeRequest.seed(:id, [{ + id: i, + source_branch: 'master', + target_branch: 'feature', + project_id: project_id, + author_id: user_id, + assignee_id: user_id, + closed: [true, false].sample, + milestone: project.milestones.sample, + title: Faker::Lorem.sentence(6) + }]) +end