Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/project_test.rb.svn-base @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 94944d00e43c |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 119:8661b858af72 |
---|---|
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.dirname(__FILE__) + '/../test_helper' | 18 require File.expand_path('../../test_helper', __FILE__) |
19 | 19 |
20 class ProjectTest < ActiveSupport::TestCase | 20 class ProjectTest < ActiveSupport::TestCase |
21 fixtures :all | 21 fixtures :all |
22 | 22 |
23 def setup | 23 def setup |
58 def test_truth | 58 def test_truth |
59 assert_kind_of Project, @ecookbook | 59 assert_kind_of Project, @ecookbook |
60 assert_equal "eCookbook", @ecookbook.name | 60 assert_equal "eCookbook", @ecookbook.name |
61 end | 61 end |
62 | 62 |
63 def test_default_attributes | |
64 with_settings :default_projects_public => '1' do | |
65 assert_equal true, Project.new.is_public | |
66 assert_equal false, Project.new(:is_public => false).is_public | |
67 end | |
68 | |
69 with_settings :default_projects_public => '0' do | |
70 assert_equal false, Project.new.is_public | |
71 assert_equal true, Project.new(:is_public => true).is_public | |
72 end | |
73 | |
74 with_settings :sequential_project_identifiers => '1' do | |
75 assert !Project.new.identifier.blank? | |
76 assert Project.new(:identifier => '').identifier.blank? | |
77 end | |
78 | |
79 with_settings :sequential_project_identifiers => '0' do | |
80 assert Project.new.identifier.blank? | |
81 assert !Project.new(:identifier => 'test').blank? | |
82 end | |
83 | |
84 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | |
85 assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names | |
86 end | |
87 | |
88 assert_equal Tracker.all, Project.new.trackers | |
89 assert_equal Tracker.find(1, 3), Project.new(:tracker_ids => [1, 3]).trackers | |
90 end | |
91 | |
63 def test_update | 92 def test_update |
64 assert_equal "eCookbook", @ecookbook.name | 93 assert_equal "eCookbook", @ecookbook.name |
65 @ecookbook.name = "eCook" | 94 @ecookbook.name = "eCook" |
66 assert @ecookbook.save, @ecookbook.errors.full_messages.join("; ") | 95 assert @ecookbook.save, @ecookbook.errors.full_messages.join("; ") |
67 @ecookbook.reload | 96 @ecookbook.reload |
739 @project.memberships.each do |membership| | 768 @project.memberships.each do |membership| |
740 assert membership | 769 assert membership |
741 assert_equal @project, membership.project | 770 assert_equal @project, membership.project |
742 end | 771 end |
743 end | 772 end |
773 | |
774 should "copy memberships with groups and additional roles" do | |
775 group = Group.create!(:lastname => "Copy group") | |
776 user = User.find(7) | |
777 group.users << user | |
778 # group role | |
779 Member.create!(:project_id => @source_project.id, :principal => group, :role_ids => [2]) | |
780 member = Member.find_by_user_id_and_project_id(user.id, @source_project.id) | |
781 # additional role | |
782 member.role_ids = [1] | |
783 | |
784 assert @project.copy(@source_project) | |
785 member = Member.find_by_user_id_and_project_id(user.id, @project.id) | |
786 assert_not_nil member | |
787 assert_equal [1, 2], member.role_ids.sort | |
788 end | |
744 | 789 |
745 should "copy project specific queries" do | 790 should "copy project specific queries" do |
746 assert @project.valid? | 791 assert @project.valid? |
747 assert @project.queries.empty? | 792 assert @project.queries.empty? |
748 assert @project.copy(@source_project) | 793 assert @project.copy(@source_project) |
851 end | 896 end |
852 | 897 |
853 should "be nil if there are no issues on the project" do | 898 should "be nil if there are no issues on the project" do |
854 assert_nil @project.start_date | 899 assert_nil @project.start_date |
855 end | 900 end |
856 | |
857 should "be nil if issue tracking is disabled" do | |
858 Issue.generate_for_project!(@project, :start_date => Date.today) | |
859 @project.enabled_modules.find_all_by_name('issue_tracking').each {|m| m.destroy} | |
860 @project.reload | |
861 | |
862 assert_nil @project.start_date | |
863 end | |
864 | 901 |
865 should "be tested when issues have no start date" | 902 should "be tested when issues have no start date" |
866 | 903 |
867 should "be the earliest start date of it's issues" do | 904 should "be the earliest start date of it's issues" do |
868 early = 7.days.ago.to_date | 905 early = 7.days.ago.to_date |
880 @project = Project.generate!(:identifier => 'test0') | 917 @project = Project.generate!(:identifier => 'test0') |
881 @project.trackers << Tracker.generate! | 918 @project.trackers << Tracker.generate! |
882 end | 919 end |
883 | 920 |
884 should "be nil if there are no issues on the project" do | 921 should "be nil if there are no issues on the project" do |
885 assert_nil @project.due_date | |
886 end | |
887 | |
888 should "be nil if issue tracking is disabled" do | |
889 Issue.generate_for_project!(@project, :due_date => Date.today) | |
890 @project.enabled_modules.find_all_by_name('issue_tracking').each {|m| m.destroy} | |
891 @project.reload | |
892 | |
893 assert_nil @project.due_date | 922 assert_nil @project.due_date |
894 end | 923 end |
895 | 924 |
896 should "be tested when issues have no due date" | 925 should "be tested when issues have no due date" |
897 | 926 |