comparison test/unit/project_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents 5f33065ddc4b
children 622f24f53b42 261b3d9a4903
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class ProjectTest < ActiveSupport::TestCase 20 class ProjectTest < ActiveSupport::TestCase
21 fixtures :projects, :trackers, :issue_statuses, :issues, 21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :journals, :journal_details,
22 :enumerations, :users, :issue_categories, 23 :enumerations, :users, :issue_categories,
23 :projects_trackers, 24 :projects_trackers,
25 :custom_fields,
26 :custom_fields_projects,
27 :custom_fields_trackers,
28 :custom_values,
24 :roles, 29 :roles,
25 :member_roles, 30 :member_roles,
26 :members, 31 :members,
27 :enabled_modules, 32 :enabled_modules,
28 :workflows, 33 :workflows,
29 :versions, 34 :versions,
30 :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, 35 :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions,
31 :groups_users, 36 :groups_users,
32 :boards 37 :boards, :messages,
38 :repositories,
39 :news, :comments,
40 :documents
33 41
34 def setup 42 def setup
35 @ecookbook = Project.find(1) 43 @ecookbook = Project.find(1)
36 @ecookbook_sub1 = Project.find(3) 44 @ecookbook_sub1 = Project.find(3)
45 set_tmp_attachments_directory
37 User.current = nil 46 User.current = nil
38 end
39
40 should_validate_presence_of :name
41 should_validate_presence_of :identifier
42
43 should_validate_uniqueness_of :identifier
44
45 context "associations" do
46 should_have_many :members
47 should_have_many :users, :through => :members
48 should_have_many :member_principals
49 should_have_many :principals, :through => :member_principals
50 should_have_many :enabled_modules
51 should_have_many :issues
52 should_have_many :issue_changes, :through => :issues
53 should_have_many :versions
54 should_have_many :time_entries
55 should_have_many :queries
56 should_have_many :documents
57 should_have_many :news
58 should_have_many :issue_categories
59 should_have_many :boards
60 should_have_many :changesets, :through => :repository
61
62 should_have_one :repository
63 should_have_one :wiki
64
65 should_have_and_belong_to_many :trackers
66 should_have_and_belong_to_many :issue_custom_fields
67 end 47 end
68 48
69 def test_truth 49 def test_truth
70 assert_kind_of Project, @ecookbook 50 assert_kind_of Project, @ecookbook
71 assert_equal "eCookbook", @ecookbook.name 51 assert_equal "eCookbook", @ecookbook.name
110 90
111 def test_validate_identifier 91 def test_validate_identifier
112 to_test = {"abc" => true, 92 to_test = {"abc" => true,
113 "ab12" => true, 93 "ab12" => true,
114 "ab-12" => true, 94 "ab-12" => true,
95 "ab_12" => true,
115 "12" => false, 96 "12" => false,
116 "new" => false} 97 "new" => false}
117 98
118 to_test.each do |identifier, valid| 99 to_test.each do |identifier, valid|
119 p = Project.new 100 p = Project.new
120 p.identifier = identifier 101 p.identifier = identifier
121 p.valid? 102 p.valid?
122 assert_equal valid, p.errors['identifier'].nil? 103 if valid
123 end 104 assert p.errors['identifier'].blank?, "identifier #{identifier} was not valid"
105 else
106 assert p.errors['identifier'].present?, "identifier #{identifier} was valid"
107 end
108 end
109 end
110
111 def test_identifier_should_not_be_frozen_for_a_new_project
112 assert_equal false, Project.new.identifier_frozen?
113 end
114
115 def test_identifier_should_not_be_frozen_for_a_saved_project_with_blank_identifier
116 Project.update_all(["identifier = ''"], "id = 1")
117
118 assert_equal false, Project.find(1).identifier_frozen?
119 end
120
121 def test_identifier_should_be_frozen_for_a_saved_project_with_valid_identifier
122 assert_equal true, Project.find(1).identifier_frozen?
124 end 123 end
125 124
126 def test_members_should_be_active_users 125 def test_members_should_be_active_users
127 Project.all.each do |project| 126 Project.all.each do |project|
128 assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) } 127 assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) }
131 130
132 def test_users_should_be_active_users 131 def test_users_should_be_active_users
133 Project.all.each do |project| 132 Project.all.each do |project|
134 assert_nil project.users.detect {|u| !(u.is_a?(User) && u.active?) } 133 assert_nil project.users.detect {|u| !(u.is_a?(User) && u.active?) }
135 end 134 end
135 end
136
137 def test_open_scope_on_issues_association
138 assert_kind_of Issue, Project.find(1).issues.open.first
136 end 139 end
137 140
138 def test_archive 141 def test_archive
139 user = @ecookbook.members.first.user 142 user = @ecookbook.members.first.user
140 @ecookbook.archive 143 @ecookbook.archive
191 assert_nil Member.first(:conditions => {:project_id => @ecookbook.id}) 194 assert_nil Member.first(:conditions => {:project_id => @ecookbook.id})
192 assert_nil Board.first(:conditions => {:project_id => @ecookbook.id}) 195 assert_nil Board.first(:conditions => {:project_id => @ecookbook.id})
193 assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id}) 196 assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id})
194 end 197 end
195 198
199 def test_destroy_should_destroy_subtasks
200 issues = (0..2).to_a.map {Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :subject => 'test')}
201 issues[0].update_attribute :parent_issue_id, issues[1].id
202 issues[2].update_attribute :parent_issue_id, issues[1].id
203 assert_equal 2, issues[1].children.count
204
205 assert_nothing_raised do
206 Project.find(1).destroy
207 end
208 assert Issue.find_all_by_id(issues.map(&:id)).empty?
209 end
210
196 def test_destroying_root_projects_should_clear_data 211 def test_destroying_root_projects_should_clear_data
197 Project.roots.each do |root| 212 Project.roots.each do |root|
198 root.destroy 213 root.destroy
199 end 214 end
200 215
202 assert_equal 0, Member.count, "Members were not deleted: #{Member.all.inspect}" 217 assert_equal 0, Member.count, "Members were not deleted: #{Member.all.inspect}"
203 assert_equal 0, MemberRole.count 218 assert_equal 0, MemberRole.count
204 assert_equal 0, Issue.count 219 assert_equal 0, Issue.count
205 assert_equal 0, Journal.count 220 assert_equal 0, Journal.count
206 assert_equal 0, JournalDetail.count 221 assert_equal 0, JournalDetail.count
207 assert_equal 0, Attachment.count 222 assert_equal 0, Attachment.count, "Attachments were not deleted: #{Attachment.all.inspect}"
208 assert_equal 0, EnabledModule.count 223 assert_equal 0, EnabledModule.count
209 assert_equal 0, IssueCategory.count 224 assert_equal 0, IssueCategory.count
210 assert_equal 0, IssueRelation.count 225 assert_equal 0, IssueRelation.count
211 assert_equal 0, Board.count 226 assert_equal 0, Board.count
212 assert_equal 0, Message.count 227 assert_equal 0, Message.count
271 Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(parent) 286 Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(parent)
272 Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(parent) 287 Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(parent)
273 288
274 parent.reload 289 parent.reload
275 assert_equal 4, parent.children.size 290 assert_equal 4, parent.children.size
276 assert_equal parent.children.sort_by(&:name), parent.children 291 assert_equal parent.children.all.sort_by(&:name), parent.children.all
277 end 292 end
278
279 def test_rebuild_should_sort_children_alphabetically
280 ProjectCustomField.delete_all
281 parent = Project.create!(:name => 'Parent', :identifier => 'parent')
282 Project.create!(:name => 'Project C', :identifier => 'project-c').move_to_child_of(parent)
283 Project.create!(:name => 'Project B', :identifier => 'project-b').move_to_child_of(parent)
284 Project.create!(:name => 'Project D', :identifier => 'project-d').move_to_child_of(parent)
285 Project.create!(:name => 'Project A', :identifier => 'project-a').move_to_child_of(parent)
286
287 Project.update_all("lft = NULL, rgt = NULL")
288 Project.rebuild!
289
290 parent.reload
291 assert_equal 4, parent.children.size
292 assert_equal parent.children.sort_by(&:name), parent.children
293 end
294
295 293
296 def test_set_parent_should_update_issue_fixed_version_associations_when_a_fixed_version_is_moved_out_of_the_hierarchy 294 def test_set_parent_should_update_issue_fixed_version_associations_when_a_fixed_version_is_moved_out_of_the_hierarchy
297 # Parent issue with a hierarchy project's fixed version 295 # Parent issue with a hierarchy project's fixed version
298 parent_issue = Issue.find(1) 296 parent_issue = Issue.find(1)
299 parent_issue.update_attribute(:fixed_version_id, 4) 297 parent_issue.update_attribute(:fixed_version_id, 4)
757 755
758 test 'activities should not include active System activities if the project has an override that is inactive' do 756 test 'activities should not include active System activities if the project has an override that is inactive' do
759 project = Project.find(1) 757 project = Project.find(1)
760 system_activity = TimeEntryActivity.find_by_name('Design') 758 system_activity = TimeEntryActivity.find_by_name('Design')
761 assert system_activity.active? 759 assert system_activity.active?
762 overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false) 760 overridden_activity = TimeEntryActivity.create!(:name => "Project", :project => project, :parent => system_activity, :active => false)
763 assert overridden_activity.save! 761 assert overridden_activity.save!
764 762
765 assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found" 763 assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found"
766 assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override" 764 assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override"
767 end 765 end
808 assert copied_issue 806 assert copied_issue
809 assert copied_issue.status 807 assert copied_issue.status
810 assert_equal "Closed", copied_issue.status.name 808 assert_equal "Closed", copied_issue.status.name
811 end 809 end
812 810
811 should "copy issues assigned to a locked version" do
812 User.current = User.find(1)
813 assigned_version = Version.generate!(:name => "Assigned Issues")
814 @source_project.versions << assigned_version
815 Issue.generate!(:project => @source_project,
816 :fixed_version_id => assigned_version.id,
817 :subject => "copy issues assigned to a locked version")
818 assigned_version.update_attribute :status, 'locked'
819
820 assert @project.copy(@source_project)
821 @project.reload
822 copied_issue = @project.issues.first(:conditions => {:subject => "copy issues assigned to a locked version"})
823
824 assert copied_issue
825 assert copied_issue.fixed_version
826 assert_equal "Assigned Issues", copied_issue.fixed_version.name # Same name
827 assert_equal 'locked', copied_issue.fixed_version.status
828 end
829
813 should "change the new issues to use the copied version" do 830 should "change the new issues to use the copied version" do
814 User.current = User.find(1) 831 User.current = User.find(1)
815 assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open') 832 assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open')
816 @source_project.versions << assigned_version 833 @source_project.versions << assigned_version
817 assert_equal 3, @source_project.versions.size 834 assert_equal 3, @source_project.versions.size
818 Issue.generate_for_project!(@source_project, 835 Issue.generate!(:project => @source_project,
819 :fixed_version_id => assigned_version.id, 836 :fixed_version_id => assigned_version.id,
820 :subject => "change the new issues to use the copied version", 837 :subject => "change the new issues to use the copied version")
821 :tracker_id => 1,
822 :project_id => @source_project.id)
823 838
824 assert @project.copy(@source_project) 839 assert @project.copy(@source_project)
825 @project.reload 840 @project.reload
826 copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"}) 841 copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"})
827 842
828 assert copied_issue 843 assert copied_issue
829 assert copied_issue.fixed_version 844 assert copied_issue.fixed_version
830 assert_equal "Assigned Issues", copied_issue.fixed_version.name # Same name 845 assert_equal "Assigned Issues", copied_issue.fixed_version.name # Same name
831 assert_not_equal assigned_version.id, copied_issue.fixed_version.id # Different record 846 assert_not_equal assigned_version.id, copied_issue.fixed_version.id # Different record
847 end
848
849 should "keep target shared versions from other project" do
850 assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open', :project_id => 1, :sharing => 'system')
851 issue = Issue.generate!(:project => @source_project,
852 :fixed_version => assigned_version,
853 :subject => "keep target shared versions")
854
855 assert @project.copy(@source_project)
856 @project.reload
857 copied_issue = @project.issues.first(:conditions => {:subject => "keep target shared versions"})
858
859 assert copied_issue
860 assert_equal assigned_version, copied_issue.fixed_version
832 end 861 end
833 862
834 should "copy issue relations" do 863 should "copy issue relations" do
835 Setting.cross_project_issue_relations = '1' 864 Setting.cross_project_issue_relations = '1'
836 865
837 second_issue = Issue.generate!(:status_id => 5, 866 second_issue = Issue.generate!(:status_id => 5,
838 :subject => "copy issue relation", 867 :subject => "copy issue relation",
839 :tracker_id => 1, 868 :tracker_id => 1,
840 :assigned_to_id => 2, 869 :assigned_to_id => 2,
841 :project_id => @source_project.id) 870 :project_id => @source_project.id)
842 source_relation = IssueRelation.generate!(:issue_from => Issue.find(4), 871 source_relation = IssueRelation.create!(:issue_from => Issue.find(4),
843 :issue_to => second_issue, 872 :issue_to => second_issue,
844 :relation_type => "relates") 873 :relation_type => "relates")
845 source_relation_cross_project = IssueRelation.generate!(:issue_from => Issue.find(1), 874 source_relation_cross_project = IssueRelation.create!(:issue_from => Issue.find(1),
846 :issue_to => second_issue, 875 :issue_to => second_issue,
847 :relation_type => "duplicates") 876 :relation_type => "duplicates")
848 877
849 assert @project.copy(@source_project) 878 assert @project.copy(@source_project)
850 assert_equal @source_project.issues.count, @project.issues.count 879 assert_equal @source_project.issues.count, @project.issues.count
862 assert_equal 2, copied_second_issue.relations.size, "Relation not copied" 891 assert_equal 2, copied_second_issue.relations.size, "Relation not copied"
863 copied_relation = copied_second_issue.relations.select {|r| r.relation_type == 'duplicates'}.first 892 copied_relation = copied_second_issue.relations.select {|r| r.relation_type == 'duplicates'}.first
864 assert_equal "duplicates", copied_relation.relation_type 893 assert_equal "duplicates", copied_relation.relation_type
865 assert_equal 1, copied_relation.issue_from_id, "Cross project relation not kept" 894 assert_equal 1, copied_relation.issue_from_id, "Cross project relation not kept"
866 assert_not_equal source_relation_cross_project.id, copied_relation.id 895 assert_not_equal source_relation_cross_project.id, copied_relation.id
896 end
897
898 should "copy issue attachments" do
899 issue = Issue.generate!(:subject => "copy with attachment", :tracker_id => 1, :project_id => @source_project.id)
900 Attachment.create!(:container => issue, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
901 @source_project.issues << issue
902 assert @project.copy(@source_project)
903
904 copied_issue = @project.issues.first(:conditions => {:subject => "copy with attachment"})
905 assert_not_nil copied_issue
906 assert_equal 1, copied_issue.attachments.count, "Attachment not copied"
907 assert_equal "testfile.txt", copied_issue.attachments.first.filename
867 end 908 end
868 909
869 should "copy memberships" do 910 should "copy memberships" do
870 assert @project.valid? 911 assert @project.valid?
871 assert @project.members.empty? 912 assert @project.members.empty?
991 1032
992 assert @project.members.any? 1033 assert @project.members.any?
993 assert @project.issue_categories.any? 1034 assert @project.issue_categories.any?
994 assert @project.issues.empty? 1035 assert @project.issues.empty?
995 end 1036 end
996 1037 end
1038
1039 def test_copy_should_copy_subtasks
1040 source = Project.generate!(:tracker_ids => [1])
1041 issue = Issue.generate_with_descendants!(:project => source)
1042 project = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1])
1043
1044 assert_difference 'Project.count' do
1045 assert_difference 'Issue.count', 1+issue.descendants.count do
1046 assert project.copy(source.reload)
1047 end
1048 end
1049 copy = Issue.where(:parent_id => nil).order("id DESC").first
1050 assert_equal project, copy.project
1051 assert_equal issue.descendants.count, copy.descendants.count
1052 child_copy = copy.children.detect {|c| c.subject == 'Child1'}
1053 assert child_copy.descendants.any?
997 end 1054 end
998 1055
999 context "#start_date" do 1056 context "#start_date" do
1000 setup do 1057 setup do
1001 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests 1058 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests
1009 1066
1010 should "be tested when issues have no start date" 1067 should "be tested when issues have no start date"
1011 1068
1012 should "be the earliest start date of it's issues" do 1069 should "be the earliest start date of it's issues" do
1013 early = 7.days.ago.to_date 1070 early = 7.days.ago.to_date
1014 Issue.generate_for_project!(@project, :start_date => Date.today) 1071 Issue.generate!(:project => @project, :start_date => Date.today)
1015 Issue.generate_for_project!(@project, :start_date => early) 1072 Issue.generate!(:project => @project, :start_date => early)
1016 1073
1017 assert_equal early, @project.start_date 1074 assert_equal early, @project.start_date
1018 end 1075 end
1019 1076
1020 end 1077 end
1032 1089
1033 should "be tested when issues have no due date" 1090 should "be tested when issues have no due date"
1034 1091
1035 should "be the latest due date of it's issues" do 1092 should "be the latest due date of it's issues" do
1036 future = 7.days.from_now.to_date 1093 future = 7.days.from_now.to_date
1037 Issue.generate_for_project!(@project, :due_date => future) 1094 Issue.generate!(:project => @project, :due_date => future)
1038 Issue.generate_for_project!(@project, :due_date => Date.today) 1095 Issue.generate!(:project => @project, :due_date => Date.today)
1039 1096
1040 assert_equal future, @project.due_date 1097 assert_equal future, @project.due_date
1041 end 1098 end
1042 1099
1043 should "be the latest due date of it's versions" do 1100 should "be the latest due date of it's versions" do
1051 end 1108 end
1052 1109
1053 should "pick the latest date from it's issues and versions" do 1110 should "pick the latest date from it's issues and versions" do
1054 future = 7.days.from_now.to_date 1111 future = 7.days.from_now.to_date
1055 far_future = 14.days.from_now.to_date 1112 far_future = 14.days.from_now.to_date
1056 Issue.generate_for_project!(@project, :due_date => far_future) 1113 Issue.generate!(:project => @project, :due_date => far_future)
1057 @project.versions << Version.generate!(:effective_date => future) 1114 @project.versions << Version.generate!(:effective_date => future)
1058 1115
1059 assert_equal far_future, @project.due_date 1116 assert_equal far_future, @project.due_date
1060 end 1117 end
1061 1118
1082 assert_equal 0, @project.completed_percent 1139 assert_equal 0, @project.completed_percent
1083 end 1140 end
1084 1141
1085 should "return 100 if the version has only closed issues" do 1142 should "return 100 if the version has only closed issues" do
1086 v1 = Version.generate!(:project => @project) 1143 v1 = Version.generate!(:project => @project)
1087 Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v1) 1144 Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v1)
1088 v2 = Version.generate!(:project => @project) 1145 v2 = Version.generate!(:project => @project)
1089 Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v2) 1146 Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v2)
1090 1147
1091 assert_equal 100, @project.completed_percent 1148 assert_equal 100, @project.completed_percent
1092 end 1149 end
1093 1150
1094 should "return the averaged completed percent of the versions (not weighted)" do 1151 should "return the averaged completed percent of the versions (not weighted)" do
1095 v1 = Version.generate!(:project => @project) 1152 v1 = Version.generate!(:project => @project)
1096 Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v1) 1153 Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v1)
1097 v2 = Version.generate!(:project => @project) 1154 v2 = Version.generate!(:project => @project)
1098 Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v2) 1155 Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v2)
1099 1156
1100 assert_equal 50, @project.completed_percent 1157 assert_equal 50, @project.completed_percent
1101 end 1158 end
1102 1159
1103 end 1160 end
1107 setup do 1164 setup do
1108 @project = Project.generate! 1165 @project = Project.generate!
1109 @role = Role.generate! 1166 @role = Role.generate!
1110 1167
1111 @user_with_membership_notification = User.generate!(:mail_notification => 'selected') 1168 @user_with_membership_notification = User.generate!(:mail_notification => 'selected')
1112 Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true) 1169 Member.create!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true)
1113 1170
1114 @all_events_user = User.generate!(:mail_notification => 'all') 1171 @all_events_user = User.generate!(:mail_notification => 'all')
1115 Member.generate!(:project => @project, :roles => [@role], :principal => @all_events_user) 1172 Member.create!(:project => @project, :roles => [@role], :principal => @all_events_user)
1116 1173
1117 @no_events_user = User.generate!(:mail_notification => 'none') 1174 @no_events_user = User.generate!(:mail_notification => 'none')
1118 Member.generate!(:project => @project, :roles => [@role], :principal => @no_events_user) 1175 Member.create!(:project => @project, :roles => [@role], :principal => @no_events_user)
1119 1176
1120 @only_my_events_user = User.generate!(:mail_notification => 'only_my_events') 1177 @only_my_events_user = User.generate!(:mail_notification => 'only_my_events')
1121 Member.generate!(:project => @project, :roles => [@role], :principal => @only_my_events_user) 1178 Member.create!(:project => @project, :roles => [@role], :principal => @only_my_events_user)
1122 1179
1123 @only_assigned_user = User.generate!(:mail_notification => 'only_assigned') 1180 @only_assigned_user = User.generate!(:mail_notification => 'only_assigned')
1124 Member.generate!(:project => @project, :roles => [@role], :principal => @only_assigned_user) 1181 Member.create!(:project => @project, :roles => [@role], :principal => @only_assigned_user)
1125 1182
1126 @only_owned_user = User.generate!(:mail_notification => 'only_owner') 1183 @only_owned_user = User.generate!(:mail_notification => 'only_owner')
1127 Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user) 1184 Member.create!(:project => @project, :roles => [@role], :principal => @only_owned_user)
1128 end 1185 end
1129 1186
1130 should "include members with a mail notification" do 1187 should "include members with a mail notification" do
1131 assert @project.notified_users.include?(@user_with_membership_notification) 1188 assert @project.notified_users.include?(@user_with_membership_notification)
1132 end 1189 end