Commit d98b1833612af09fb405880ef7acd63a4e2a42fa
1 parent
23d95085
Exists in
master
and in
4 other branches
first pack of tests for milestones
Showing
8 changed files
with
145 additions
and
48 deletions
Show diff stats
app/helpers/projects_helper.rb
| @@ -16,45 +16,7 @@ module ProjectsHelper | @@ -16,45 +16,7 @@ module ProjectsHelper | ||
| 16 | nil | 16 | nil |
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | - def project_tab_class | ||
| 20 | - [:show, :files, :team, :edit, :update].each do |action| | ||
| 21 | - return "current" if current_page?(:controller => "projects", :action => action, :id => @project) | ||
| 22 | - end | ||
| 23 | - | ||
| 24 | - if controller.controller_name == "snippets" || | ||
| 25 | - controller.controller_name == "hooks" || | ||
| 26 | - controller.controller_name == "deploy_keys" || | ||
| 27 | - controller.controller_name == "team_members" | ||
| 28 | - "current" | ||
| 29 | - end | ||
| 30 | - end | ||
| 31 | - | ||
| 32 | - def tree_tab_class | ||
| 33 | - controller.controller_name == "refs" ? | ||
| 34 | - "current" : nil | ||
| 35 | - end | ||
| 36 | - | ||
| 37 | def repository_tab_class | 19 | def repository_tab_class |
| 38 | - #if controller.controller_name == "repositories" || | ||
| 39 | - #controller.controller_name == "hooks" || | ||
| 40 | - #controller.controller_name == "deploy_keys" | ||
| 41 | - #"current" | ||
| 42 | - #end | ||
| 43 | - end | ||
| 44 | - | ||
| 45 | - def commit_tab_class | ||
| 46 | - if controller.controller_name == "commits" || | ||
| 47 | - controller.controller_name == "repositories" || | ||
| 48 | - controller.controller_name == "protected_branches" | ||
| 49 | - "current" | ||
| 50 | - end | ||
| 51 | end | 20 | end |
| 52 | 21 | ||
| 53 | - def branches_tab_class | ||
| 54 | - if current_page?(branches_project_repository_path(@project)) || | ||
| 55 | - controller.controller_name == "protected_branches" || | ||
| 56 | - current_page?(project_repository_path(@project)) | ||
| 57 | - 'active' | ||
| 58 | - end | ||
| 59 | - end | ||
| 60 | end | 22 | end |
| @@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
| 1 | +module TabHelper | ||
| 2 | + def issues_tab? | ||
| 3 | + controller.controller_name == "issues" || controller.controller_name == "milestones" | ||
| 4 | + end | ||
| 5 | + | ||
| 6 | + def wall_tab? | ||
| 7 | + current_page?(:controller => "projects", :action => "wall", :id => @project) | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + def project_tab_class | ||
| 11 | + [:show, :files, :team, :edit, :update].each do |action| | ||
| 12 | + return "current" if current_page?(:controller => "projects", :action => action, :id => @project) | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + if controller.controller_name == "snippets" || | ||
| 16 | + controller.controller_name == "hooks" || | ||
| 17 | + controller.controller_name == "deploy_keys" || | ||
| 18 | + controller.controller_name == "team_members" | ||
| 19 | + "current" | ||
| 20 | + end | ||
| 21 | + end | ||
| 22 | + | ||
| 23 | + def tree_tab_class | ||
| 24 | + controller.controller_name == "refs" ? | ||
| 25 | + "current" : nil | ||
| 26 | + end | ||
| 27 | + | ||
| 28 | + def commit_tab_class | ||
| 29 | + if controller.controller_name == "commits" || | ||
| 30 | + controller.controller_name == "repositories" || | ||
| 31 | + controller.controller_name == "protected_branches" | ||
| 32 | + "current" | ||
| 33 | + end | ||
| 34 | + end | ||
| 35 | + | ||
| 36 | + def branches_tab_class | ||
| 37 | + if current_page?(branches_project_repository_path(@project)) || | ||
| 38 | + controller.controller_name == "protected_branches" || | ||
| 39 | + current_page?(project_repository_path(@project)) | ||
| 40 | + 'active' | ||
| 41 | + end | ||
| 42 | + end | ||
| 43 | +end |
app/views/layouts/_project_menu.html.haml
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | 10 | ||
| 11 | = link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil | 11 | = link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil |
| 12 | - if @project.issues_enabled | 12 | - if @project.issues_enabled |
| 13 | - = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do | 13 | + = link_to project_issues_filter_path(@project), :class => issues_tab? ? "current" : nil do |
| 14 | Issues | 14 | Issues |
| 15 | %span.count= @project.issues.opened.count | 15 | %span.count= @project.issues.opened.count |
| 16 | - if @project.merge_requests_enabled | 16 | - if @project.merge_requests_enabled |
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | %span.count= @project.merge_requests.opened.count | 19 | %span.count= @project.merge_requests.opened.count |
| 20 | 20 | ||
| 21 | - if @project.wall_enabled | 21 | - if @project.wall_enabled |
| 22 | - = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do | 22 | + = link_to wall_project_path(@project), :class => wall_tab? ? "current" : nil do |
| 23 | Wall | 23 | Wall |
| 24 | 24 | ||
| 25 | - if @project.wiki_enabled | 25 | - if @project.wiki_enabled |
db/schema.rb
| @@ -65,18 +65,18 @@ ActiveRecord::Schema.define(:version => 20120408181910) do | @@ -65,18 +65,18 @@ ActiveRecord::Schema.define(:version => 20120408181910) do | ||
| 65 | t.text "st_commits", :limit => 2147483647 | 65 | t.text "st_commits", :limit => 2147483647 |
| 66 | t.text "st_diffs", :limit => 2147483647 | 66 | t.text "st_diffs", :limit => 2147483647 |
| 67 | t.boolean "merged", :default => false, :null => false | 67 | t.boolean "merged", :default => false, :null => false |
| 68 | - t.boolean "auto_merge", :default => true, :null => false | ||
| 69 | end | 68 | end |
| 70 | 69 | ||
| 71 | add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" | 70 | add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" |
| 72 | 71 | ||
| 73 | create_table "milestones", :force => true do |t| | 72 | create_table "milestones", :force => true do |t| |
| 74 | - t.string "title", :null => false | 73 | + t.string "title", :null => false |
| 74 | + t.integer "project_id", :null => false | ||
| 75 | t.text "description" | 75 | t.text "description" |
| 76 | - t.date "due_date", :null => false | ||
| 77 | - t.integer "project_id", :null => false | ||
| 78 | - t.datetime "created_at", :null => false | ||
| 79 | - t.datetime "updated_at", :null => false | 76 | + t.date "due_date" |
| 77 | + t.boolean "closed", :default => false, :null => false | ||
| 78 | + t.datetime "created_at", :null => false | ||
| 79 | + t.datetime "updated_at", :null => false | ||
| 80 | end | 80 | end |
| 81 | 81 | ||
| 82 | create_table "notes", :force => true do |t| | 82 | create_table "notes", :force => true do |t| |
spec/factories.rb
| @@ -75,3 +75,8 @@ Factory.add(:event, Event) do |obj| | @@ -75,3 +75,8 @@ Factory.add(:event, Event) do |obj| | ||
| 75 | obj.title = Faker::Lorem.sentence | 75 | obj.title = Faker::Lorem.sentence |
| 76 | obj.project = Factory(:project) | 76 | obj.project = Factory(:project) |
| 77 | end | 77 | end |
| 78 | + | ||
| 79 | +Factory.add(:milestone, Milestone) do |obj| | ||
| 80 | + obj.title = Faker::Lorem.sentence | ||
| 81 | + obj.due_date = Date.today + 1.month | ||
| 82 | +end |
spec/models/issue_spec.rb
| @@ -5,6 +5,7 @@ describe Issue do | @@ -5,6 +5,7 @@ describe Issue do | ||
| 5 | it { should belong_to(:project) } | 5 | it { should belong_to(:project) } |
| 6 | it { should belong_to(:author) } | 6 | it { should belong_to(:author) } |
| 7 | it { should belong_to(:assignee) } | 7 | it { should belong_to(:assignee) } |
| 8 | + it { should belong_to(:milestone) } | ||
| 8 | end | 9 | end |
| 9 | 10 | ||
| 10 | describe "Validation" do | 11 | describe "Validation" do |
| @@ -22,7 +23,7 @@ describe Issue do | @@ -22,7 +23,7 @@ describe Issue do | ||
| 22 | it { Factory.create(:issue, | 23 | it { Factory.create(:issue, |
| 23 | :author => Factory(:user), | 24 | :author => Factory(:user), |
| 24 | :assignee => Factory(:user), | 25 | :assignee => Factory(:user), |
| 25 | - :project => Factory.create(:project)).should be_valid } | 26 | + :projet => Factory.create(:project)).should be_valid } |
| 26 | 27 | ||
| 27 | describe "plus 1" do | 28 | describe "plus 1" do |
| 28 | let(:project) { Factory(:project) } | 29 | let(:project) { Factory(:project) } |
spec/models/milestone_spec.rb
| 1 | require 'spec_helper' | 1 | require 'spec_helper' |
| 2 | 2 | ||
| 3 | describe Milestone do | 3 | describe Milestone do |
| 4 | - pending "add some examples to (or delete) #{__FILE__}" | 4 | + describe "Associations" do |
| 5 | + it { should belong_to(:project) } | ||
| 6 | + it { should have_many(:issues) } | ||
| 7 | + end | ||
| 8 | + | ||
| 9 | + describe "Validation" do | ||
| 10 | + it { should validate_presence_of(:title) } | ||
| 11 | + it { should validate_presence_of(:project_id) } | ||
| 12 | + end | ||
| 13 | + | ||
| 14 | + let(:project) { Factory :project } | ||
| 15 | + let(:milestone) { Factory :milestone, :project => project } | ||
| 16 | + let(:issue) { Factory :issue, :project => project } | ||
| 17 | + | ||
| 18 | + it { milestone.should be_valid } | ||
| 19 | + | ||
| 20 | + describe "Issues" do | ||
| 21 | + before do | ||
| 22 | + milestone.issues << issue | ||
| 23 | + end | ||
| 24 | + | ||
| 25 | + it { milestone.percent_complete.should == 0 } | ||
| 26 | + | ||
| 27 | + it do | ||
| 28 | + issue.update_attributes :closed => true | ||
| 29 | + milestone.percent_complete.should == 100 | ||
| 30 | + end | ||
| 31 | + end | ||
| 32 | + | ||
| 33 | + describe :expires_at do | ||
| 34 | + before do | ||
| 35 | + milestone.update_attributes :due_date => Date.today + 1.day | ||
| 36 | + end | ||
| 37 | + | ||
| 38 | + it { milestone.expires_at.should_not be_nil } | ||
| 39 | + end | ||
| 5 | end | 40 | end |
| @@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
| 1 | +require 'spec_helper' | ||
| 2 | + | ||
| 3 | +describe "Milestones" do | ||
| 4 | + let(:project) { Factory :project } | ||
| 5 | + | ||
| 6 | + before do | ||
| 7 | + login_as :user | ||
| 8 | + project.add_access(@user, :admin) | ||
| 9 | + | ||
| 10 | + @milestone = Factory :milestone, :project => project | ||
| 11 | + @issue = Factory :issue, :project => project | ||
| 12 | + | ||
| 13 | + @milestone.issues << @issue | ||
| 14 | + end | ||
| 15 | + | ||
| 16 | + describe "GET /milestones" do | ||
| 17 | + before do | ||
| 18 | + visit project_milestones_path(project) | ||
| 19 | + end | ||
| 20 | + | ||
| 21 | + subject { page } | ||
| 22 | + | ||
| 23 | + it { should have_content(@milestone.title[0..10]) } | ||
| 24 | + it { should have_content(@milestone.expires_at) } | ||
| 25 | + it { should have_content("Browse Issues") } | ||
| 26 | + end | ||
| 27 | + | ||
| 28 | + describe "GET /milestone/:id" do | ||
| 29 | + before do | ||
| 30 | + visit project_milestone_path(project, @milestone) | ||
| 31 | + end | ||
| 32 | + | ||
| 33 | + subject { page } | ||
| 34 | + | ||
| 35 | + it { should have_content(@milestone.title[0..10]) } | ||
| 36 | + it { should have_content(@milestone.expires_at) } | ||
| 37 | + it { should have_content("Browse Issues") } | ||
| 38 | + end | ||
| 39 | + | ||
| 40 | + describe "GET /milestones/new" do | ||
| 41 | + before do | ||
| 42 | + visit new_project_milestone_path(project) | ||
| 43 | + fill_in "milestone_title", :with => "v2.3" | ||
| 44 | + click_button "Create milestone" | ||
| 45 | + end | ||
| 46 | + | ||
| 47 | + it { current_path.should == project_milestone_path(project, project.milestones.last) } | ||
| 48 | + it { should have_content(@milestone.title[0..10]) } | ||
| 49 | + it { should have_content(@milestone.expires_at) } | ||
| 50 | + end | ||
| 51 | +end |