first pack of tests for milestones
This commit is contained in:
parent
23d950855d
commit
d98b183361
8 changed files with 145 additions and 48 deletions
|
@ -16,45 +16,7 @@ module ProjectsHelper
|
|||
nil
|
||||
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
|
||||
#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
|
||||
|
||||
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
|
||||
|
|
43
app/helpers/tab_helper.rb
Normal file
43
app/helpers/tab_helper.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
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 @@
|
|||
|
||||
= link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil
|
||||
- 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
|
||||
%span.count= @project.issues.opened.count
|
||||
- if @project.merge_requests_enabled
|
||||
|
@ -19,7 +19,7 @@
|
|||
%span.count= @project.merge_requests.opened.count
|
||||
|
||||
- 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
|
||||
|
||||
- if @project.wiki_enabled
|
||||
|
|
12
db/schema.rb
12
db/schema.rb
|
@ -65,18 +65,18 @@ ActiveRecord::Schema.define(:version => 20120408181910) do
|
|||
t.text "st_commits", :limit => 2147483647
|
||||
t.text "st_diffs", :limit => 2147483647
|
||||
t.boolean "merged", :default => false, :null => false
|
||||
t.boolean "auto_merge", :default => true, :null => false
|
||||
end
|
||||
|
||||
add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id"
|
||||
|
||||
create_table "milestones", :force => true do |t|
|
||||
t.string "title", :null => false
|
||||
t.string "title", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
t.text "description"
|
||||
t.date "due_date", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.date "due_date"
|
||||
t.boolean "closed", :default => false, :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "notes", :force => true do |t|
|
||||
|
|
|
@ -75,3 +75,8 @@ Factory.add(:event, Event) do |obj|
|
|||
obj.title = Faker::Lorem.sentence
|
||||
obj.project = Factory(:project)
|
||||
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
|
|||
it { should belong_to(:project) }
|
||||
it { should belong_to(:author) }
|
||||
it { should belong_to(:assignee) }
|
||||
it { should belong_to(:milestone) }
|
||||
end
|
||||
|
||||
describe "Validation" do
|
||||
|
@ -22,7 +23,7 @@ describe Issue do
|
|||
it { Factory.create(:issue,
|
||||
:author => Factory(:user),
|
||||
:assignee => Factory(:user),
|
||||
:project => Factory.create(:project)).should be_valid }
|
||||
:projet => Factory.create(:project)).should be_valid }
|
||||
|
||||
describe "plus 1" do
|
||||
let(:project) { Factory(:project) }
|
||||
|
|
|
@ -1,5 +1,40 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
|
|
51
spec/requests/milestones_spec.rb
Normal file
51
spec/requests/milestones_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
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
|
Loading…
Reference in a new issue