Commit d98b1833 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

first pack of tests for milestones

parent 23d95085
...@@ -16,45 +16,7 @@ module ProjectsHelper ...@@ -16,45 +16,7 @@ module ProjectsHelper
nil nil
end end
def project_tab_class
[:show, :files, :team, :edit, :update].each do |action|
return "current" if current_page?(:controller => "projects", :action => action, :id => @project)
end
if controller.controller_name == "snippets" ||
controller.controller_name == "hooks" ||
controller.controller_name == "deploy_keys" ||
controller.controller_name == "team_members"
"current"
end
end
def tree_tab_class
controller.controller_name == "refs" ?
"current" : nil
end
def repository_tab_class def repository_tab_class
#if controller.controller_name == "repositories" ||
#controller.controller_name == "hooks" ||
#controller.controller_name == "deploy_keys"
#"current"
#end
end
def commit_tab_class
if controller.controller_name == "commits" ||
controller.controller_name == "repositories" ||
controller.controller_name == "protected_branches"
"current"
end
end end
def branches_tab_class
if current_page?(branches_project_repository_path(@project)) ||
controller.controller_name == "protected_branches" ||
current_page?(project_repository_path(@project))
'active'
end
end
end end
module TabHelper
def issues_tab?
controller.controller_name == "issues" || controller.controller_name == "milestones"
end
def wall_tab?
current_page?(:controller => "projects", :action => "wall", :id => @project)
end
def project_tab_class
[:show, :files, :team, :edit, :update].each do |action|
return "current" if current_page?(:controller => "projects", :action => action, :id => @project)
end
if controller.controller_name == "snippets" ||
controller.controller_name == "hooks" ||
controller.controller_name == "deploy_keys" ||
controller.controller_name == "team_members"
"current"
end
end
def tree_tab_class
controller.controller_name == "refs" ?
"current" : nil
end
def commit_tab_class
if controller.controller_name == "commits" ||
controller.controller_name == "repositories" ||
controller.controller_name == "protected_branches"
"current"
end
end
def branches_tab_class
if current_page?(branches_project_repository_path(@project)) ||
controller.controller_name == "protected_branches" ||
current_page?(project_repository_path(@project))
'active'
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
= link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil = link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil
- if @project.issues_enabled - if @project.issues_enabled
= link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do = link_to project_issues_filter_path(@project), :class => issues_tab? ? "current" : nil do
Issues Issues
%span.count= @project.issues.opened.count %span.count= @project.issues.opened.count
- if @project.merge_requests_enabled - if @project.merge_requests_enabled
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
%span.count= @project.merge_requests.opened.count %span.count= @project.merge_requests.opened.count
- if @project.wall_enabled - if @project.wall_enabled
= link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do = link_to wall_project_path(@project), :class => wall_tab? ? "current" : nil do
Wall Wall
- if @project.wiki_enabled - if @project.wiki_enabled
......
...@@ -65,16 +65,16 @@ ActiveRecord::Schema.define(:version => 20120408181910) do ...@@ -65,16 +65,16 @@ ActiveRecord::Schema.define(:version => 20120408181910) do
t.text "st_commits", :limit => 2147483647 t.text "st_commits", :limit => 2147483647
t.text "st_diffs", :limit => 2147483647 t.text "st_diffs", :limit => 2147483647
t.boolean "merged", :default => false, :null => false t.boolean "merged", :default => false, :null => false
t.boolean "auto_merge", :default => true, :null => false
end end
add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id"
create_table "milestones", :force => true do |t| create_table "milestones", :force => true do |t|
t.string "title", :null => false t.string "title", :null => false
t.text "description"
t.date "due_date", :null => false
t.integer "project_id", :null => false t.integer "project_id", :null => false
t.text "description"
t.date "due_date"
t.boolean "closed", :default => false, :null => false
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
......
...@@ -75,3 +75,8 @@ Factory.add(:event, Event) do |obj| ...@@ -75,3 +75,8 @@ Factory.add(:event, Event) do |obj|
obj.title = Faker::Lorem.sentence obj.title = Faker::Lorem.sentence
obj.project = Factory(:project) obj.project = Factory(:project)
end end
Factory.add(:milestone, Milestone) do |obj|
obj.title = Faker::Lorem.sentence
obj.due_date = Date.today + 1.month
end
...@@ -5,6 +5,7 @@ describe Issue do ...@@ -5,6 +5,7 @@ describe Issue do
it { should belong_to(:project) } it { should belong_to(:project) }
it { should belong_to(:author) } it { should belong_to(:author) }
it { should belong_to(:assignee) } it { should belong_to(:assignee) }
it { should belong_to(:milestone) }
end end
describe "Validation" do describe "Validation" do
...@@ -22,7 +23,7 @@ describe Issue do ...@@ -22,7 +23,7 @@ describe Issue do
it { Factory.create(:issue, it { Factory.create(:issue,
:author => Factory(:user), :author => Factory(:user),
:assignee => Factory(:user), :assignee => Factory(:user),
:project => Factory.create(:project)).should be_valid } :projet => Factory.create(:project)).should be_valid }
describe "plus 1" do describe "plus 1" do
let(:project) { Factory(:project) } let(:project) { Factory(:project) }
......
require 'spec_helper' require 'spec_helper'
describe Milestone do describe Milestone do
pending "add some examples to (or delete) #{__FILE__}" describe "Associations" do
it { should belong_to(:project) }
it { should have_many(:issues) }
end
describe "Validation" do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:project_id) }
end
let(:project) { Factory :project }
let(:milestone) { Factory :milestone, :project => project }
let(:issue) { Factory :issue, :project => project }
it { milestone.should be_valid }
describe "Issues" do
before do
milestone.issues << issue
end
it { milestone.percent_complete.should == 0 }
it do
issue.update_attributes :closed => true
milestone.percent_complete.should == 100
end
end
describe :expires_at do
before do
milestone.update_attributes :due_date => Date.today + 1.day
end
it { milestone.expires_at.should_not be_nil }
end
end end
require 'spec_helper'
describe "Milestones" do
let(:project) { Factory :project }
before do
login_as :user
project.add_access(@user, :admin)
@milestone = Factory :milestone, :project => project
@issue = Factory :issue, :project => project
@milestone.issues << @issue
end
describe "GET /milestones" do
before do
visit project_milestones_path(project)
end
subject { page }
it { should have_content(@milestone.title[0..10]) }
it { should have_content(@milestone.expires_at) }
it { should have_content("Browse Issues") }
end
describe "GET /milestone/:id" do
before do
visit project_milestone_path(project, @milestone)
end
subject { page }
it { should have_content(@milestone.title[0..10]) }
it { should have_content(@milestone.expires_at) }
it { should have_content("Browse Issues") }
end
describe "GET /milestones/new" do
before do
visit new_project_milestone_path(project)
fill_in "milestone_title", :with => "v2.3"
click_button "Create milestone"
end
it { current_path.should == project_milestone_path(project, project.milestones.last) }
it { should have_content(@milestone.title[0..10]) }
it { should have_content(@milestone.expires_at) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment