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