Chris@441: # Redmine - project management software Chris@1115: # Copyright (C) 2006-2012 Jean-Philippe Lang chris@22: # chris@22: # This program is free software; you can redistribute it and/or chris@22: # modify it under the terms of the GNU General Public License chris@22: # as published by the Free Software Foundation; either version 2 chris@22: # of the License, or (at your option) any later version. Chris@909: # chris@22: # This program is distributed in the hope that it will be useful, chris@22: # but WITHOUT ANY WARRANTY; without even the implied warranty of chris@22: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the chris@22: # GNU General Public License for more details. Chris@909: # chris@22: # You should have received a copy of the GNU General Public License chris@22: # along with this program; if not, write to the Free Software chris@22: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. chris@22: Chris@119: require File.expand_path('../../../../../test_helper', __FILE__) chris@22: Chris@1115: class Redmine::Helpers::GanttHelperTest < ActionView::TestCase Chris@1115: fixtures :projects, :trackers, :issue_statuses, :issues, Chris@1115: :journals, :journal_details, Chris@1115: :enumerations, :users, :issue_categories, Chris@1115: :projects_trackers, Chris@1115: :roles, Chris@1115: :member_roles, Chris@1115: :members, Chris@1115: :enabled_modules, Chris@1115: :workflows, Chris@1115: :versions, Chris@1115: :groups_users Chris@909: Chris@1115: include ApplicationHelper Chris@1115: include ProjectsHelper Chris@1115: include IssuesHelper Chris@1115: include ERB::Util chris@22: chris@22: def setup Chris@1115: setup_with_controller chris@22: User.current = User.find(1) chris@22: end chris@22: Chris@1115: def today Chris@1115: @today ||= Date.today chris@22: end chris@22: chris@22: # Creates a Gantt chart for a 4 week span Chris@119: def create_gantt(project=Project.generate!, options={}) chris@22: @project = project Chris@119: @gantt = Redmine::Helpers::Gantt.new(options) chris@22: @gantt.project = @project Chris@1115: @gantt.query = Query.create!(:project => @project, :name => 'Gantt') Chris@1115: @gantt.view = self Chris@1115: @gantt.instance_variable_set('@date_from', options[:date_from] || (today - 14)) Chris@1115: @gantt.instance_variable_set('@date_to', options[:date_to] || (today + 14)) chris@22: end chris@22: chris@22: context "#number_of_rows" do chris@22: context "with one project" do chris@22: should "return the number of rows just for that project" chris@22: end chris@22: chris@22: context "with no project" do chris@22: should "return the total number of rows for all the projects, resursively" chris@22: end chris@22: Chris@119: should "not exceed max_rows option" do Chris@119: p = Project.generate! Chris@119: 5.times do Chris@1115: Issue.generate!(:project => p) Chris@119: end Chris@119: create_gantt(p) Chris@119: @gantt.render Chris@119: assert_equal 6, @gantt.number_of_rows Chris@119: assert !@gantt.truncated Chris@119: create_gantt(p, :max_rows => 3) Chris@119: @gantt.render Chris@119: assert_equal 3, @gantt.number_of_rows Chris@119: assert @gantt.truncated Chris@119: end chris@22: end chris@22: chris@22: context "#number_of_rows_on_project" do chris@22: setup do chris@22: create_gantt chris@22: end chris@22: Chris@441: should "count 0 for an empty the project" do Chris@441: assert_equal 0, @gantt.number_of_rows_on_project(@project) chris@22: end chris@22: chris@22: should "count the number of issues without a version" do Chris@1115: @project.issues << Issue.generate!(:project => @project, :fixed_version => nil) chris@22: assert_equal 2, @gantt.number_of_rows_on_project(@project) chris@22: end chris@22: chris@22: should "count the number of issues on versions, including cross-project" do chris@22: version = Version.generate! chris@22: @project.versions << version Chris@1115: @project.issues << Issue.generate!(:project => @project, :fixed_version => version) chris@22: assert_equal 3, @gantt.number_of_rows_on_project(@project) chris@22: end chris@22: end chris@22: chris@22: # TODO: more of an integration test chris@22: context "#subjects" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker Chris@1115: @version = Version.generate!(:effective_date => (today + 7), :sharing => 'none') chris@22: @project.versions << @version chris@22: @issue = Issue.generate!(:fixed_version => @version, chris@22: :subject => "gantt#line_for_project", chris@22: :tracker => @tracker, chris@22: :project => @project, chris@22: :done_ratio => 30, Chris@1115: :start_date => (today - 1), Chris@1115: :due_date => (today + 7)) Chris@909: @project.issues << @issue chris@22: end Chris@909: chris@22: context "project" do chris@22: should "be rendered" do Chris@1115: @output_buffer = @gantt.subjects chris@22: assert_select "div.project-name a", /#{@project.name}/ chris@22: end Chris@909: chris@22: should "have an indent of 4" do Chris@1115: @output_buffer = @gantt.subjects chris@22: assert_select "div.project-name[style*=left:4px]" chris@22: end chris@22: end Chris@909: chris@22: context "version" do chris@22: should "be rendered" do Chris@1115: @output_buffer = @gantt.subjects chris@22: assert_select "div.version-name a", /#{@version.name}/ chris@22: end Chris@909: chris@22: should "be indented 24 (one level)" do Chris@1115: @output_buffer = @gantt.subjects chris@22: assert_select "div.version-name[style*=left:24px]" chris@22: end Chris@909: Chris@441: context "without assigned issues" do Chris@441: setup do Chris@1115: @version = Version.generate!(:effective_date => (today + 14), Chris@1115: :sharing => 'none', Chris@1115: :name => 'empty_version') Chris@441: @project.versions << @version Chris@441: end Chris@909: Chris@441: should "not be rendered" do Chris@1115: @output_buffer = @gantt.subjects Chris@441: assert_select "div.version-name a", :text => /#{@version.name}/, :count => 0 Chris@441: end Chris@441: end chris@22: end Chris@909: chris@22: context "issue" do chris@22: should "be rendered" do Chris@1115: @output_buffer = @gantt.subjects chris@22: assert_select "div.issue-subject", /#{@issue.subject}/ chris@22: end Chris@909: chris@22: should "be indented 44 (two levels)" do Chris@1115: @output_buffer = @gantt.subjects chris@22: assert_select "div.issue-subject[style*=left:44px]" chris@22: end Chris@909: Chris@441: context "assigned to a shared version of another project" do Chris@441: setup do Chris@441: p = Project.generate! Chris@441: p.enabled_module_names = [:issue_tracking] Chris@441: @shared_version = Version.generate!(:sharing => 'system') Chris@441: p.versions << @shared_version Chris@441: # Reassign the issue to a shared version of another project Chris@441: @issue = Issue.generate!(:fixed_version => @shared_version, Chris@441: :subject => "gantt#assigned_to_shared_version", Chris@441: :tracker => @tracker, Chris@441: :project => @project, Chris@441: :done_ratio => 30, Chris@1115: :start_date => (today - 1), Chris@1115: :due_date => (today + 7)) Chris@441: @project.issues << @issue Chris@441: end Chris@909: Chris@441: should "be rendered" do Chris@1115: @output_buffer = @gantt.subjects Chris@441: assert_select "div.issue-subject", /#{@issue.subject}/ Chris@441: end Chris@441: end Chris@909: Chris@119: context "with subtasks" do Chris@119: setup do Chris@119: attrs = {:project => @project, :tracker => @tracker, :fixed_version => @version} Chris@1115: @child1 = Issue.generate!( Chris@1115: attrs.merge(:subject => 'child1', Chris@1115: :parent_issue_id => @issue.id, Chris@1115: :start_date => (today - 1), Chris@1115: :due_date => (today + 2)) Chris@1115: ) Chris@1115: @child2 = Issue.generate!( Chris@1115: attrs.merge(:subject => 'child2', Chris@1115: :parent_issue_id => @issue.id, Chris@1115: :start_date => today, Chris@1115: :due_date => (today + 7)) Chris@1115: ) Chris@1115: @grandchild = Issue.generate!( Chris@1115: attrs.merge(:subject => 'grandchild', Chris@1115: :parent_issue_id => @child1.id, Chris@1115: :start_date => (today - 1), Chris@1115: :due_date => (today + 2)) Chris@1115: ) Chris@119: end Chris@909: Chris@119: should "indent subtasks" do Chris@1115: @output_buffer = @gantt.subjects Chris@119: # parent task 44px Chris@119: assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ Chris@119: # children 64px Chris@119: assert_select "div.issue-subject[style*=left:64px]", /child1/ Chris@119: assert_select "div.issue-subject[style*=left:64px]", /child2/ Chris@119: # grandchild 84px Chris@1115: assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer Chris@119: end Chris@119: end chris@22: end chris@22: end chris@22: chris@22: context "#lines" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker Chris@1115: @version = Version.generate!(:effective_date => (today + 7)) chris@22: @project.versions << @version chris@22: @issue = Issue.generate!(:fixed_version => @version, chris@22: :subject => "gantt#line_for_project", chris@22: :tracker => @tracker, chris@22: :project => @project, chris@22: :done_ratio => 30, Chris@1115: :start_date => (today - 1), Chris@1115: :due_date => (today + 7)) chris@22: @project.issues << @issue Chris@1115: @output_buffer = @gantt.lines chris@22: end chris@22: chris@22: context "project" do chris@22: should "be rendered" do Chris@119: assert_select "div.project.task_todo" Chris@119: assert_select "div.project.starting" Chris@119: assert_select "div.project.ending" Chris@119: assert_select "div.label.project", /#{@project.name}/ chris@22: end chris@22: end chris@22: chris@22: context "version" do chris@22: should "be rendered" do Chris@119: assert_select "div.version.task_todo" Chris@119: assert_select "div.version.starting" Chris@119: assert_select "div.version.ending" Chris@119: assert_select "div.label.version", /#{@version.name}/ chris@22: end chris@22: end chris@22: chris@22: context "issue" do chris@22: should "be rendered" do chris@22: assert_select "div.task_todo" Chris@119: assert_select "div.task.label", /#{@issue.done_ratio}/ chris@22: assert_select "div.tooltip", /#{@issue.subject}/ chris@22: end chris@22: end chris@22: end chris@22: chris@22: context "#render_project" do chris@22: should "be tested" chris@22: end chris@22: chris@22: context "#render_issues" do chris@22: should "be tested" chris@22: end chris@22: chris@22: context "#render_version" do chris@22: should "be tested" chris@22: end chris@22: chris@22: context "#subject_for_project" do chris@22: setup do chris@22: create_gantt chris@22: end Chris@909: chris@22: context ":html format" do chris@22: should "add an absolute positioned div" do Chris@1115: @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) chris@22: assert_select "div[style*=absolute]" chris@22: end chris@22: chris@22: should "use the indent option to move the div to the right" do Chris@1115: @output_buffer = @gantt.subject_for_project(@project, {:format => :html, :indent => 40}) chris@22: assert_select "div[style*=left:40]" chris@22: end chris@22: chris@22: should "include the project name" do Chris@1115: @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) chris@22: assert_select 'div', :text => /#{@project.name}/ chris@22: end chris@22: chris@22: should "include a link to the project" do Chris@1115: @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) chris@22: assert_select 'a[href=?]', "/projects/#{@project.identifier}", :text => /#{@project.name}/ chris@22: end chris@22: chris@22: should "style overdue projects" do chris@22: @project.enabled_module_names = [:issue_tracking] Chris@1115: @project.versions << Version.generate!(:effective_date => (today - 1)) Chris@1115: assert @project.reload.overdue?, "Need an overdue project for this test" Chris@1115: @output_buffer = @gantt.subject_for_project(@project, {:format => :html}) chris@22: assert_select 'div span.project-overdue' chris@22: end chris@22: end chris@22: should "test the PNG format" chris@22: should "test the PDF format" chris@22: end chris@22: chris@22: context "#line_for_project" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker Chris@1115: @version = Version.generate!(:effective_date => (today - 1)) chris@22: @project.versions << @version chris@22: @project.issues << Issue.generate!(:fixed_version => @version, chris@22: :subject => "gantt#line_for_project", chris@22: :tracker => @tracker, chris@22: :project => @project, chris@22: :done_ratio => 30, Chris@1115: :start_date => (today - 7), Chris@1115: :due_date => (today + 7)) chris@22: end chris@22: chris@22: context ":html format" do chris@22: context "todo line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.task_todo[style*=left:28px]", true, @output_buffer chris@22: end chris@22: chris@22: should "be the total width of the project" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.task_todo[style*=width:58px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "late line" do Chris@119: should_eventually "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.task_late[style*=left:28px]", true, @output_buffer chris@22: end chris@22: Chris@119: should_eventually "be the total delayed width of the project" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.task_late[style*=width:30px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "done line" do Chris@119: should_eventually "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.task_done[style*=left:28px]", true, @output_buffer chris@22: end chris@22: Chris@119: should_eventually "Be the total done width of the project" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.task_done[style*=width:18px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "starting marker" do chris@22: should "not appear if the starting point is off the gantt chart" do chris@22: # Shift the date range of the chart Chris@1115: @gantt.instance_variable_set('@date_from', today) Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.starting", false, @output_buffer chris@22: end chris@22: chris@22: should "appear at the starting point" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.starting[style*=left:28px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "ending marker" do chris@22: should "not appear if the starting point is off the gantt chart" do chris@22: # Shift the date range of the chart Chris@1115: @gantt.instance_variable_set('@date_to', (today - 14)) Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.ending", false, @output_buffer chris@22: end chris@22: chris@22: should "appear at the end of the date range" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.project.ending[style*=left:88px]", true, @output_buffer chris@22: end chris@22: end Chris@909: chris@22: context "status content" do chris@22: should "appear at the far left, even if it's far in the past" do Chris@1115: @gantt.instance_variable_set('@date_to', (today - 14)) Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.project.label", /#{@project.name}/ chris@22: end chris@22: chris@22: should "show the project name" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.project.label", /#{@project.name}/ chris@22: end chris@22: Chris@119: should_eventually "show the percent complete" do Chris@1115: @output_buffer = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.project.label", /0%/ chris@22: end chris@22: end chris@22: end chris@22: should "test the PNG format" chris@22: should "test the PDF format" chris@22: end chris@22: chris@22: context "#subject_for_version" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker Chris@1115: @version = Version.generate!(:effective_date => (today - 1)) chris@22: @project.versions << @version chris@22: @project.issues << Issue.generate!(:fixed_version => @version, chris@22: :subject => "gantt#subject_for_version", chris@22: :tracker => @tracker, chris@22: :project => @project, Chris@1115: :start_date => today) chris@22: chris@22: end chris@22: chris@22: context ":html format" do chris@22: should "add an absolute positioned div" do Chris@1115: @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) chris@22: assert_select "div[style*=absolute]" chris@22: end chris@22: chris@22: should "use the indent option to move the div to the right" do Chris@1115: @output_buffer = @gantt.subject_for_version(@version, {:format => :html, :indent => 40}) chris@22: assert_select "div[style*=left:40]" chris@22: end chris@22: chris@22: should "include the version name" do Chris@1115: @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) chris@22: assert_select 'div', :text => /#{@version.name}/ chris@22: end chris@22: chris@22: should "include a link to the version" do Chris@1115: @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) Chris@909: assert_select 'a[href=?]', Regexp.escape("/versions/#{@version.to_param}"), :text => /#{@version.name}/ chris@22: end chris@22: chris@22: should "style late versions" do chris@22: assert @version.overdue?, "Need an overdue version for this test" Chris@1115: @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) chris@22: assert_select 'div span.version-behind-schedule' chris@22: end chris@22: chris@22: should "style behind schedule versions" do chris@22: assert @version.behind_schedule?, "Need a behind schedule version for this test" Chris@1115: @output_buffer = @gantt.subject_for_version(@version, {:format => :html}) chris@22: assert_select 'div span.version-behind-schedule' chris@22: end chris@22: end chris@22: should "test the PNG format" chris@22: should "test the PDF format" chris@22: end chris@22: chris@22: context "#line_for_version" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker Chris@1115: @version = Version.generate!(:effective_date => (today + 7)) chris@22: @project.versions << @version chris@22: @project.issues << Issue.generate!(:fixed_version => @version, chris@22: :subject => "gantt#line_for_project", chris@22: :tracker => @tracker, chris@22: :project => @project, chris@22: :done_ratio => 30, Chris@1115: :start_date => (today - 7), Chris@1115: :due_date => (today + 7)) chris@22: end chris@22: chris@22: context ":html format" do chris@22: context "todo line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.task_todo[style*=left:28px]", true, @output_buffer chris@22: end chris@22: chris@22: should "be the total width of the version" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.task_todo[style*=width:58px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "late line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.task_late[style*=left:28px]", true, @output_buffer chris@22: end chris@22: chris@22: should "be the total delayed width of the version" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.task_late[style*=width:30px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "done line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.task_done[style*=left:28px]", true, @output_buffer chris@22: end chris@22: Chris@441: should "be the total done width of the version" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.task_done[style*=width:16px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "starting marker" do chris@22: should "not appear if the starting point is off the gantt chart" do chris@22: # Shift the date range of the chart Chris@1115: @gantt.instance_variable_set('@date_from', today) Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.version.starting", false chris@22: end chris@22: chris@22: should "appear at the starting point" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.starting[style*=left:28px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "ending marker" do chris@22: should "not appear if the starting point is off the gantt chart" do chris@22: # Shift the date range of the chart Chris@1115: @gantt.instance_variable_set('@date_to', (today - 14)) Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.version.ending", false chris@22: end chris@22: chris@22: should "appear at the end of the date range" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.version.ending[style*=left:88px]", true, @output_buffer chris@22: end chris@22: end Chris@909: chris@22: context "status content" do chris@22: should "appear at the far left, even if it's far in the past" do Chris@1115: @gantt.instance_variable_set('@date_to', (today - 14)) Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.version.label", /#{@version.name}/ chris@22: end chris@22: chris@22: should "show the version name" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.version.label", /#{@version.name}/ chris@22: end chris@22: chris@22: should "show the percent complete" do Chris@1115: @output_buffer = @gantt.line_for_version(@version, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.version.label", /30%/ chris@22: end chris@22: end chris@22: end chris@22: should "test the PNG format" chris@22: should "test the PDF format" chris@22: end chris@22: chris@22: context "#subject_for_issue" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker chris@22: @issue = Issue.generate!(:subject => "gantt#subject_for_issue", chris@22: :tracker => @tracker, chris@22: :project => @project, Chris@1115: :start_date => (today - 3), Chris@1115: :due_date => (today - 1)) chris@22: @project.issues << @issue chris@22: end chris@22: chris@22: context ":html format" do chris@22: should "add an absolute positioned div" do Chris@1115: @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) chris@22: assert_select "div[style*=absolute]" chris@22: end chris@22: chris@22: should "use the indent option to move the div to the right" do Chris@1115: @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html, :indent => 40}) chris@22: assert_select "div[style*=left:40]" chris@22: end chris@22: chris@22: should "include the issue subject" do Chris@1115: @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) chris@22: assert_select 'div', :text => /#{@issue.subject}/ chris@22: end chris@22: chris@22: should "include a link to the issue" do Chris@1115: @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) chris@22: assert_select 'a[href=?]', Regexp.escape("/issues/#{@issue.to_param}"), :text => /#{@tracker.name} ##{@issue.id}/ chris@22: end chris@22: chris@22: should "style overdue issues" do chris@22: assert @issue.overdue?, "Need an overdue issue for this test" Chris@1115: @output_buffer = @gantt.subject_for_issue(@issue, {:format => :html}) chris@22: assert_select 'div span.issue-overdue' chris@22: end chris@22: end chris@22: should "test the PNG format" chris@22: should "test the PDF format" chris@22: end chris@22: chris@22: context "#line_for_issue" do chris@22: setup do chris@22: create_gantt chris@22: @project.enabled_module_names = [:issue_tracking] chris@22: @tracker = Tracker.generate! chris@22: @project.trackers << @tracker Chris@1115: @version = Version.generate!(:effective_date => (today + 7)) chris@22: @project.versions << @version chris@22: @issue = Issue.generate!(:fixed_version => @version, chris@22: :subject => "gantt#line_for_project", chris@22: :tracker => @tracker, chris@22: :project => @project, chris@22: :done_ratio => 30, Chris@1115: :start_date => (today - 7), Chris@1115: :due_date => (today + 7)) chris@22: @project.issues << @issue chris@22: end chris@22: chris@22: context ":html format" do chris@22: context "todo line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_todo[style*=left:28px]", true, @output_buffer chris@22: end chris@22: chris@22: should "be the total width of the issue" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_todo[style*=width:58px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "late line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_late[style*=left:28px]", true, @output_buffer chris@22: end chris@22: chris@22: should "be the total delayed width of the issue" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_late[style*=width:30px]", true, @output_buffer chris@22: end chris@22: end chris@22: chris@22: context "done line" do chris@22: should "start from the starting point on the left" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_done[style*=left:28px]", true, @output_buffer chris@22: end chris@22: Chris@441: should "be the total done width of the issue" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@441: # 15 days * 4 px * 30% - 2 px for borders = 16 px Chris@1115: assert_select "div.task_done[style*=width:16px]", true, @output_buffer Chris@119: end Chris@119: Chris@119: should "not be the total done width if the chart starts after issue start date" do Chris@1115: create_gantt(@project, :date_from => (today - 5)) Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_done[style*=left:0px]", true, @output_buffer Chris@1115: assert_select "div.task_done[style*=width:8px]", true, @output_buffer Chris@441: end Chris@909: Chris@441: context "for completed issue" do Chris@441: setup do Chris@441: @issue.done_ratio = 100 Chris@441: end Chris@441: Chris@441: should "be the total width of the issue" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_done[style*=width:58px]", true, @output_buffer Chris@441: end Chris@909: Chris@441: should "be the total width of the issue with due_date=start_date" do Chris@441: @issue.due_date = @issue.start_date Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task_done[style*=width:2px]", true, @output_buffer Chris@441: end chris@22: end chris@22: end chris@22: chris@22: context "status content" do chris@22: should "appear at the far left, even if it's far in the past" do Chris@1115: @gantt.instance_variable_set('@date_to', (today - 14)) Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@1115: assert_select "div.task.label", true, @output_buffer chris@22: end chris@22: chris@22: should "show the issue status" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.task.label", /#{@issue.status.name}/ chris@22: end chris@22: chris@22: should "show the percent complete" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) Chris@119: assert_select "div.task.label", /30%/ chris@22: end chris@22: end chris@22: end chris@22: chris@22: should "have an issue tooltip" do Chris@1115: @output_buffer = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) chris@22: assert_select "div.tooltip", /#{@issue.subject}/ chris@22: end chris@22: should "test the PNG format" chris@22: should "test the PDF format" chris@22: end chris@22: chris@22: context "#to_image" do chris@22: should "be tested" chris@22: end chris@22: chris@22: context "#to_pdf" do chris@22: should "be tested" chris@22: end chris@22: end