@@ -169,8 +169,8 class ApplicationController < ActionController::Base | |||||
169 | def logout_user |
|
169 | def logout_user | |
170 | if User.current.logged? |
|
170 | if User.current.logged? | |
171 | cookies.delete(autologin_cookie_name) |
|
171 | cookies.delete(autologin_cookie_name) | |
172 |
Token. |
|
172 | Token.where(["user_id = ? AND action = ?", User.current.id, 'autologin']).delete_all | |
173 |
Token. |
|
173 | Token.where(["user_id = ? AND action = ? AND value = ?", User.current.id, 'session', session[:tk]]).delete_all | |
174 | self.logged_user = nil |
|
174 | self.logged_user = nil | |
175 | end |
|
175 | end | |
176 | end |
|
176 | end |
@@ -108,6 +108,6 class IssueStatus < ActiveRecord::Base | |||||
108 |
|
108 | |||
109 | # Deletes associated workflows |
|
109 | # Deletes associated workflows | |
110 | def delete_workflow_rules |
|
110 | def delete_workflow_rules | |
111 |
WorkflowRule. |
|
111 | WorkflowRule.where(["old_status_id = :id OR new_status_id = :id", {:id => id}]).delete_all | |
112 | end |
|
112 | end | |
113 | end |
|
113 | end |
@@ -508,7 +508,7 class Project < ActiveRecord::Base | |||||
508 | def delete_all_members |
|
508 | def delete_all_members | |
509 | me, mr = Member.table_name, MemberRole.table_name |
|
509 | me, mr = Member.table_name, MemberRole.table_name | |
510 | self.class.connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})") |
|
510 | self.class.connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})") | |
511 |
Member. |
|
511 | Member.where(:project_id => id).delete_all | |
512 | end |
|
512 | end | |
513 |
|
513 | |||
514 | # Return a Principal scope of users/groups issues can be assigned to |
|
514 | # Return a Principal scope of users/groups issues can be assigned to |
@@ -10,6 +10,6 class SetTopicAuthorsAsWatchers < ActiveRecord::Migration | |||||
10 |
|
10 | |||
11 | def self.down |
|
11 | def self.down | |
12 | # Removes all message watchers |
|
12 | # Removes all message watchers | |
13 |
Watcher. |
|
13 | Watcher.where("watchable_type = 'Message'").delete_all | |
14 | end |
|
14 | end | |
15 | end |
|
15 | end |
@@ -7,6 +7,6 class EnableCalendarAndGanttModulesWhereAppropriate < ActiveRecord::Migration | |||||
7 | end |
|
7 | end | |
8 |
|
8 | |||
9 | def self.down |
|
9 | def self.down | |
10 |
EnabledModule. |
|
10 | EnabledModule.where("name = 'calendar' OR name = 'gantt'").delete_all | |
11 | end |
|
11 | end | |
12 | end |
|
12 | end |
@@ -1,7 +1,7 | |||||
1 | class AddUniqueIndexOnMembers < ActiveRecord::Migration |
|
1 | class AddUniqueIndexOnMembers < ActiveRecord::Migration | |
2 | def self.up |
|
2 | def self.up | |
3 | # Clean and reassign MemberRole rows if needed |
|
3 | # Clean and reassign MemberRole rows if needed | |
4 |
MemberRole. |
|
4 | MemberRole.where("member_id NOT IN (SELECT id FROM #{Member.table_name})").delete_all | |
5 | MemberRole.update_all("member_id =" + |
|
5 | MemberRole.update_all("member_id =" + | |
6 | " (SELECT min(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" + |
|
6 | " (SELECT min(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" + | |
7 | " WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" + |
|
7 | " WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" + | |
@@ -9,7 +9,7 class AddUniqueIndexOnMembers < ActiveRecord::Migration | |||||
9 | # Remove duplicates |
|
9 | # Remove duplicates | |
10 | Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" + |
|
10 | Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" + | |
11 | " WHERE m.id > (SELECT min(m1.id) FROM #{Member.table_name} m1 WHERE m1.user_id = m.user_id AND m1.project_id = m.project_id)").each do |i| |
|
11 | " WHERE m.id > (SELECT min(m1.id) FROM #{Member.table_name} m1 WHERE m1.user_id = m.user_id AND m1.project_id = m.project_id)").each do |i| | |
12 |
Member. |
|
12 | Member.where(["id = ?", i]).delete_all | |
13 | end |
|
13 | end | |
14 |
|
14 | |||
15 | # Then add a unique index |
|
15 | # Then add a unique index |
@@ -4,7 +4,7 class AddUniqueIndexToIssueRelations < ActiveRecord::Migration | |||||
4 | # Remove duplicates |
|
4 | # Remove duplicates | |
5 | IssueRelation.connection.select_values("SELECT r.id FROM #{IssueRelation.table_name} r" + |
|
5 | IssueRelation.connection.select_values("SELECT r.id FROM #{IssueRelation.table_name} r" + | |
6 | " WHERE r.id > (SELECT min(r1.id) FROM #{IssueRelation.table_name} r1 WHERE r1.issue_from_id = r.issue_from_id AND r1.issue_to_id = r.issue_to_id)").each do |i| |
|
6 | " WHERE r.id > (SELECT min(r1.id) FROM #{IssueRelation.table_name} r1 WHERE r1.issue_from_id = r.issue_from_id AND r1.issue_to_id = r.issue_to_id)").each do |i| | |
7 |
IssueRelation. |
|
7 | IssueRelation.where(["id = ?", i]).delete_all | |
8 | end |
|
8 | end | |
9 |
|
9 | |||
10 | add_index :issue_relations, [:issue_from_id, :issue_to_id], :unique => true |
|
10 | add_index :issue_relations, [:issue_from_id, :issue_to_id], :unique => true |
@@ -237,7 +237,7 task :migrate_from_mantis => :environment do | |||||
237 |
|
237 | |||
238 | # Users |
|
238 | # Users | |
239 | print "Migrating users" |
|
239 | print "Migrating users" | |
240 |
User. |
|
240 | User.where("login <> 'admin'").delete_all | |
241 | users_map = {} |
|
241 | users_map = {} | |
242 | users_migrated = 0 |
|
242 | users_migrated = 0 | |
243 | MantisUser.all.each do |user| |
|
243 | MantisUser.all.each do |user| |
@@ -160,7 +160,7 class AdminControllerTest < Redmine::ControllerTest | |||||
160 | private |
|
160 | private | |
161 |
|
161 | |||
162 | def delete_configuration_data |
|
162 | def delete_configuration_data | |
163 |
Role. |
|
163 | Role.where('builtin = 0').delete_all | |
164 | Tracker.delete_all |
|
164 | Tracker.delete_all | |
165 | IssueStatus.delete_all |
|
165 | IssueStatus.delete_all | |
166 | Enumeration.delete_all |
|
166 | Enumeration.delete_all |
@@ -71,7 +71,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def test_index_should_not_list_issues_when_module_disabled |
|
73 | def test_index_should_not_list_issues_when_module_disabled | |
74 |
EnabledModule. |
|
74 | EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all | |
75 | get :index |
|
75 | get :index | |
76 | assert_response :success |
|
76 | assert_response :success | |
77 | assert_template 'index' |
|
77 | assert_template 'index' | |
@@ -1231,7 +1231,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1231 |
|
1231 | |||
1232 | def test_show_should_display_update_form_with_minimal_permissions |
|
1232 | def test_show_should_display_update_form_with_minimal_permissions | |
1233 | Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes] |
|
1233 | Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes] | |
1234 |
WorkflowTransition. |
|
1234 | WorkflowTransition.where(:role_id => 1).delete_all | |
1235 |
|
1235 | |||
1236 | @request.session[:user_id] = 2 |
|
1236 | @request.session[:user_id] = 2 | |
1237 | get :show, :id => 1 |
|
1237 | get :show, :id => 1 | |
@@ -1796,7 +1796,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1796 |
|
1796 | |||
1797 | def test_get_new_with_minimal_permissions |
|
1797 | def test_get_new_with_minimal_permissions | |
1798 | Role.find(1).update_attribute :permissions, [:add_issues] |
|
1798 | Role.find(1).update_attribute :permissions, [:add_issues] | |
1799 |
WorkflowTransition. |
|
1799 | WorkflowTransition.where(:role_id => 1).delete_all | |
1800 |
|
1800 | |||
1801 | @request.session[:user_id] = 2 |
|
1801 | @request.session[:user_id] = 2 | |
1802 | get :new, :project_id => 1, :tracker_id => 1 |
|
1802 | get :new, :project_id => 1, :tracker_id => 1 | |
@@ -2833,7 +2833,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
2833 | end |
|
2833 | end | |
2834 |
|
2834 | |||
2835 | def setup_without_workflow_privilege |
|
2835 | def setup_without_workflow_privilege | |
2836 |
WorkflowTransition. |
|
2836 | WorkflowTransition.where(["role_id = ?", Role.anonymous.id]).delete_all | |
2837 | Role.anonymous.add_permission! :add_issues, :add_issue_notes |
|
2837 | Role.anonymous.add_permission! :add_issues, :add_issue_notes | |
2838 | end |
|
2838 | end | |
2839 | private :setup_without_workflow_privilege |
|
2839 | private :setup_without_workflow_privilege | |
@@ -2900,7 +2900,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
2900 | end |
|
2900 | end | |
2901 |
|
2901 | |||
2902 | def setup_with_workflow_privilege |
|
2902 | def setup_with_workflow_privilege | |
2903 |
WorkflowTransition. |
|
2903 | WorkflowTransition.where(["role_id = ?", Role.anonymous.id]).delete_all | |
2904 | WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, |
|
2904 | WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, | |
2905 | :old_status_id => 1, :new_status_id => 3) |
|
2905 | :old_status_id => 1, :new_status_id => 3) | |
2906 | WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, |
|
2906 | WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, | |
@@ -4531,7 +4531,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
4531 | # Fixes random test failure with Mysql |
|
4531 | # Fixes random test failure with Mysql | |
4532 | # where Issue.where(:project_id => 2).limit(2).order('id desc') |
|
4532 | # where Issue.where(:project_id => 2).limit(2).order('id desc') | |
4533 | # doesn't return the expected results |
|
4533 | # doesn't return the expected results | |
4534 |
Issue. |
|
4534 | Issue.where("project_id=2").delete_all | |
4535 |
|
4535 | |||
4536 | @request.session[:user_id] = 2 |
|
4536 | @request.session[:user_id] = 2 | |
4537 | assert_difference 'Issue.count', 2 do |
|
4537 | assert_difference 'Issue.count', 2 do |
@@ -23,7 +23,7 class DefaultDataTest < ActiveSupport::TestCase | |||||
23 |
|
23 | |||
24 | def test_no_data |
|
24 | def test_no_data | |
25 | assert !Redmine::DefaultData::Loader::no_data? |
|
25 | assert !Redmine::DefaultData::Loader::no_data? | |
26 |
Role. |
|
26 | Role.where("builtin = 0").delete_all | |
27 | Tracker.delete_all |
|
27 | Tracker.delete_all | |
28 | IssueStatus.delete_all |
|
28 | IssueStatus.delete_all | |
29 | Enumeration.delete_all |
|
29 | Enumeration.delete_all | |
@@ -33,7 +33,7 class DefaultDataTest < ActiveSupport::TestCase | |||||
33 | def test_load |
|
33 | def test_load | |
34 | valid_languages.each do |lang| |
|
34 | valid_languages.each do |lang| | |
35 | begin |
|
35 | begin | |
36 |
Role. |
|
36 | Role.where("builtin = 0").delete_all | |
37 | Tracker.delete_all |
|
37 | Tracker.delete_all | |
38 | IssueStatus.delete_all |
|
38 | IssueStatus.delete_all | |
39 | Enumeration.delete_all |
|
39 | Enumeration.delete_all |
@@ -46,7 +46,7 class NewsTest < ActiveSupport::TestCase | |||||
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def test_should_not_include_news_for_projects_with_news_disabled |
|
48 | def test_should_not_include_news_for_projects_with_news_disabled | |
49 |
EnabledModule. |
|
49 | EnabledModule.where(["project_id = ? AND name = ?", 2, 'news']).delete_all | |
50 | project = Project.find(2) |
|
50 | project = Project.find(2) | |
51 |
|
51 | |||
52 | # Add a piece of news to the project |
|
52 | # Add a piece of news to the project |
@@ -1051,7 +1051,7 class UserTest < ActiveSupport::TestCase | |||||
1051 | end |
|
1051 | end | |
1052 |
|
1052 | |||
1053 | def test_own_account_deletable_should_be_false_for_a_single_admin |
|
1053 | def test_own_account_deletable_should_be_false_for_a_single_admin | |
1054 |
User. |
|
1054 | User.where(["admin = ? AND id <> ?", true, 1]).delete_all | |
1055 |
|
1055 | |||
1056 | with_settings :unsubscribe => '1' do |
|
1056 | with_settings :unsubscribe => '1' do | |
1057 | assert_equal false, User.find(1).own_account_deletable? |
|
1057 | assert_equal false, User.find(1).own_account_deletable? |
@@ -150,7 +150,7 class WatcherTest < ActiveSupport::TestCase | |||||
150 | end |
|
150 | end | |
151 |
|
151 | |||
152 | def test_prune_with_user |
|
152 | def test_prune_with_user | |
153 |
Watcher. |
|
153 | Watcher.where("user_id = 9").delete_all | |
154 | user = User.find(9) |
|
154 | user = User.find(9) | |
155 |
|
155 | |||
156 | # public |
|
156 | # public |
General Comments 0
You need to be logged in to leave comments.
Login now