User.current = User.find(1)
end
+ def today
+ @today ||= Date.today
+ end
+
# Creates a Gantt chart for a 4 week span
def create_gantt(project=Project.generate!, options={})
@project = project
@gantt.project = @project
@gantt.query = Query.create!(:project => @project, :name => 'Gantt')
@gantt.view = self
- @gantt.instance_variable_set('@date_from', options[:date_from] || 2.weeks.ago.to_date)
- @gantt.instance_variable_set('@date_to', options[:date_to] || 2.weeks.from_now.to_date)
+ @gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14))
+ @gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14))
end
context "#number_of_rows" do
@project.enabled_module_names = [:issue_tracking]
@tracker = Tracker.generate!
@project.trackers << @tracker
- @version = Version.generate!(:effective_date => 1.week.from_now.to_date, :sharing => 'none')
+ @version = Version.generate!(:effective_date => (today + 7), :sharing => 'none')
@project.versions << @version
@issue = Issue.generate!(:fixed_version => @version,
:project => @project,
:done_ratio => 30,
:start_date => Date.yesterday,
- :due_date => 1.week.from_now.to_date)
+ :due_date => (today + 7))
@project.issues << @issue
end
context "without assigned issues" do
setup do
- @version = Version.generate!(:effective_date => 2.week.from_now.to_date, :sharing => 'none', :name => 'empty_version')
+ @version = Version.generate!(:effective_date => (today + 14), :sharing => 'none', :name => 'empty_version')
@project.versions << @version
end
:project => @project,
:done_ratio => 30,
:start_date => Date.yesterday,
- :due_date => 1.week.from_now.to_date)
+ :due_date => (today + 7))
@project.issues << @issue
end
context "with subtasks" do
setup do
attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version}
- @child1 = Issue.generate!(attrs.merge(:subject => 'child1', :parent_issue_id => @issue.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date))
- @child2 = Issue.generate!(attrs.merge(:subject => 'child2', :parent_issue_id => @issue.id, :start_date => Date.today, :due_date => 1.week.from_now.to_date))
- @grandchild = Issue.generate!(attrs.merge(:subject => 'grandchild', :parent_issue_id => @child1.id, :start_date => Date.yesterday, :due_date => 2.day.from_now.to_date))
+ @child1 = Issue.generate!(attrs.merge(:subject => 'child1', :parent_issue_id => @issue.id, :start_date => Date.yesterday, :due_date => (today + 2)))
+ @child2 = Issue.generate!(attrs.merge(:subject => 'child2', :parent_issue_id => @issue.id, :start_date => Date.today, :due_date => (today + 7)))
+ @grandchild = Issue.generate!(attrs.merge(:subject => 'grandchild', :parent_issue_id => @child1.id, :start_date => Date.yesterday, :due_date => (today + 2)))
end
should "indent subtasks" do
@project.enabled_module_names = [:issue_tracking]
@tracker = Tracker.generate!
@project.trackers << @tracker
- @version = Version.generate!(:effective_date => 1.week.from_now.to_date)
+ @version = Version.generate!(:effective_date => (today + 7))
@project.versions << @version
@issue = Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project",
:project => @project,
:done_ratio => 30,
:start_date => Date.yesterday,
- :due_date => 1.week.from_now.to_date)
+ :due_date => (today + 7))
@project.issues << @issue
@output_buffer = @gantt.lines
:tracker => @tracker,
:project => @project,
:done_ratio => 30,
- :start_date => 1.week.ago.to_date,
- :due_date => 1.week.from_now.to_date)
+ :start_date => (today - 7),
+ :due_date => (today + 7))
end
context ":html format" do
context "ending marker" do
should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart
- @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
+ @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.ending", false, @output_buffer
context "status content" do
should "appear at the far left, even if it's far in the past" do
- @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
+ @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4})
assert_select "div.project.label", /#{@project.name}/
@project.enabled_module_names = [:issue_tracking]
@tracker = Tracker.generate!
@project.trackers << @tracker
- @version = Version.generate!(:effective_date => 1.week.from_now.to_date)
+ @version = Version.generate!(:effective_date => (today + 7))
@project.versions << @version
@project.issues << Issue.generate!(:fixed_version => @version,
:tracker => @tracker,
:project => @project,
:done_ratio => 30,
- :start_date => 1.week.ago.to_date,
- :due_date => 1.week.from_now.to_date)
+ :start_date => (today - 7),
+ :due_date => (today + 7))
end
context ":html format" do
context "ending marker" do
should "not appear if the starting point is off the gantt chart" do
# Shift the date range of the chart
- @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
+ @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.ending", false
context "status content" do
should "appear at the far left, even if it's far in the past" do
- @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
+ @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
assert_select "div.version.label", /#{@version.name}/
@issue = Issue.generate!(:subject => "gantt#subject_for_issue",
:tracker => @tracker,
:project => @project,
- :start_date => 3.days.ago.to_date,
+ :start_date => (today - 3),
:due_date => Date.yesterday)
@project.issues << @issue
@project.enabled_module_names = [:issue_tracking]
@tracker = Tracker.generate!
@project.trackers << @tracker
- @version = Version.generate!(:effective_date => 1.week.from_now.to_date)
+ @version = Version.generate!(:effective_date => (today + 7))
@project.versions << @version
@issue = Issue.generate!(:fixed_version => @version,
:subject => "gantt#line_for_project",
:tracker => @tracker,
:project => @project,
:done_ratio => 30,
- :start_date => 1.week.ago.to_date,
- :due_date => 1.week.from_now.to_date)
+ :start_date => (today - 7),
+ :due_date => (today + 7))
@project.issues << @issue
end
end
should "not be the total done width if the chart starts after issue start date" do
- create_gantt(@project, :date_from => 5.days.ago.to_date)
+ create_gantt(@project, :date_from => (today - 5))
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task_done[style*=left:0px]", true, @output_buffer
context "status content" do
should "appear at the far left, even if it's far in the past" do
- @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
+ @gantt.instance_variable_set('@date_to', (today - 14))
@output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.task.label", true, @output_buffer