summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-16 10:30:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-16 10:30:45 +0000
commit57afa5345eea60c47b4fc44e86f32e73a202d860 (patch)
treee60a1fc76597f4648fff91c80c0abc9be8da18a6
parentd3d62f4ded2a8c8738451e58d81df27a71a6842f (diff)
downloadredmine-57afa5345eea60c47b4fc44e86f32e73a202d860.tar.gz
redmine-57afa5345eea60c47b4fc44e86f32e73a202d860.zip
Don't pass conditions to #delete_all.
git-svn-id: http://svn.redmine.org/redmine/trunk@15675 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/models/issue_status.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--db/migrate/098_set_topic_authors_as_watchers.rb2
-rw-r--r--db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb2
-rw-r--r--db/migrate/20101104182107_add_unique_index_on_members.rb4
-rw-r--r--db/migrate/20111201201315_add_unique_index_to_issue_relations.rb2
-rw-r--r--lib/tasks/migrate_from_mantis.rake2
-rw-r--r--test/functional/admin_controller_test.rb2
-rw-r--r--test/functional/issues_controller_test.rb12
-rw-r--r--test/unit/default_data_test.rb4
-rw-r--r--test/unit/news_test.rb2
-rw-r--r--test/unit/user_test.rb2
-rw-r--r--test/unit/watcher_test.rb2
14 files changed, 22 insertions, 22 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 848965ce1..4f5f03336 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -169,8 +169,8 @@ class ApplicationController < ActionController::Base
def logout_user
if User.current.logged?
cookies.delete(autologin_cookie_name)
- Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
- Token.delete_all(["user_id = ? AND action = ? AND value = ?", User.current.id, 'session', session[:tk]])
+ Token.where(["user_id = ? AND action = ?", User.current.id, 'autologin']).delete_all
+ Token.where(["user_id = ? AND action = ? AND value = ?", User.current.id, 'session', session[:tk]]).delete_all
self.logged_user = nil
end
end
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index 553c46bc5..69f81bf96 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -108,6 +108,6 @@ class IssueStatus < ActiveRecord::Base
# Deletes associated workflows
def delete_workflow_rules
- WorkflowRule.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
+ WorkflowRule.where(["old_status_id = :id OR new_status_id = :id", {:id => id}]).delete_all
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index ac204ebc1..d5c826523 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -508,7 +508,7 @@ class Project < ActiveRecord::Base
def delete_all_members
me, mr = Member.table_name, MemberRole.table_name
self.class.connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})")
- Member.delete_all(['project_id = ?', id])
+ Member.where(:project_id => id).delete_all
end
# Return a Principal scope of users/groups issues can be assigned to
diff --git a/db/migrate/098_set_topic_authors_as_watchers.rb b/db/migrate/098_set_topic_authors_as_watchers.rb
index 92a53f4a1..1a1529561 100644
--- a/db/migrate/098_set_topic_authors_as_watchers.rb
+++ b/db/migrate/098_set_topic_authors_as_watchers.rb
@@ -10,6 +10,6 @@ class SetTopicAuthorsAsWatchers < ActiveRecord::Migration
def self.down
# Removes all message watchers
- Watcher.delete_all("watchable_type = 'Message'")
+ Watcher.where("watchable_type = 'Message'").delete_all
end
end
diff --git a/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb b/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb
index 5bee50e3a..6071adf52 100644
--- a/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb
+++ b/db/migrate/20100819172912_enable_calendar_and_gantt_modules_where_appropriate.rb
@@ -7,6 +7,6 @@ class EnableCalendarAndGanttModulesWhereAppropriate < ActiveRecord::Migration
end
def self.down
- EnabledModule.delete_all("name = 'calendar' OR name = 'gantt'")
+ EnabledModule.where("name = 'calendar' OR name = 'gantt'").delete_all
end
end
diff --git a/db/migrate/20101104182107_add_unique_index_on_members.rb b/db/migrate/20101104182107_add_unique_index_on_members.rb
index 14d1585f7..eabdad86b 100644
--- a/db/migrate/20101104182107_add_unique_index_on_members.rb
+++ b/db/migrate/20101104182107_add_unique_index_on_members.rb
@@ -1,7 +1,7 @@
class AddUniqueIndexOnMembers < ActiveRecord::Migration
def self.up
# Clean and reassign MemberRole rows if needed
- MemberRole.delete_all("member_id NOT IN (SELECT id FROM #{Member.table_name})")
+ MemberRole.where("member_id NOT IN (SELECT id FROM #{Member.table_name})").delete_all
MemberRole.update_all("member_id =" +
" (SELECT min(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" +
" WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" +
@@ -9,7 +9,7 @@ class AddUniqueIndexOnMembers < ActiveRecord::Migration
# Remove duplicates
Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" +
" 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|
- Member.delete_all(["id = ?", i])
+ Member.where(["id = ?", i]).delete_all
end
# Then add a unique index
diff --git a/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb b/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb
index c27158c13..1bee49ab0 100644
--- a/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb
+++ b/db/migrate/20111201201315_add_unique_index_to_issue_relations.rb
@@ -4,7 +4,7 @@ class AddUniqueIndexToIssueRelations < ActiveRecord::Migration
# Remove duplicates
IssueRelation.connection.select_values("SELECT r.id FROM #{IssueRelation.table_name} r" +
" 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|
- IssueRelation.delete_all(["id = ?", i])
+ IssueRelation.where(["id = ?", i]).delete_all
end
add_index :issue_relations, [:issue_from_id, :issue_to_id], :unique => true
diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake
index dba77ef45..acbdd5bbb 100644
--- a/lib/tasks/migrate_from_mantis.rake
+++ b/lib/tasks/migrate_from_mantis.rake
@@ -237,7 +237,7 @@ task :migrate_from_mantis => :environment do
# Users
print "Migrating users"
- User.delete_all "login <> 'admin'"
+ User.where("login <> 'admin'").delete_all
users_map = {}
users_migrated = 0
MantisUser.all.each do |user|
diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb
index a713ddfdb..4752fb389 100644
--- a/test/functional/admin_controller_test.rb
+++ b/test/functional/admin_controller_test.rb
@@ -160,7 +160,7 @@ class AdminControllerTest < Redmine::ControllerTest
private
def delete_configuration_data
- Role.delete_all('builtin = 0')
+ Role.where('builtin = 0').delete_all
Tracker.delete_all
IssueStatus.delete_all
Enumeration.delete_all
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index af43b5012..bf84302b8 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -71,7 +71,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_index_should_not_list_issues_when_module_disabled
- EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
+ EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all
get :index
assert_response :success
assert_template 'index'
@@ -1231,7 +1231,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_show_should_display_update_form_with_minimal_permissions
Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
- WorkflowTransition.delete_all :role_id => 1
+ WorkflowTransition.where(:role_id => 1).delete_all
@request.session[:user_id] = 2
get :show, :id => 1
@@ -1796,7 +1796,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_get_new_with_minimal_permissions
Role.find(1).update_attribute :permissions, [:add_issues]
- WorkflowTransition.delete_all :role_id => 1
+ WorkflowTransition.where(:role_id => 1).delete_all
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
@@ -2833,7 +2833,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def setup_without_workflow_privilege
- WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
+ WorkflowTransition.where(["role_id = ?", Role.anonymous.id]).delete_all
Role.anonymous.add_permission! :add_issues, :add_issue_notes
end
private :setup_without_workflow_privilege
@@ -2900,7 +2900,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def setup_with_workflow_privilege
- WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
+ WorkflowTransition.where(["role_id = ?", Role.anonymous.id]).delete_all
WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1,
:old_status_id => 1, :new_status_id => 3)
WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1,
@@ -4531,7 +4531,7 @@ class IssuesControllerTest < Redmine::ControllerTest
# Fixes random test failure with Mysql
# where Issue.where(:project_id => 2).limit(2).order('id desc')
# doesn't return the expected results
- Issue.delete_all("project_id=2")
+ Issue.where("project_id=2").delete_all
@request.session[:user_id] = 2
assert_difference 'Issue.count', 2 do
diff --git a/test/unit/default_data_test.rb b/test/unit/default_data_test.rb
index 60dee7ad7..c22e9341f 100644
--- a/test/unit/default_data_test.rb
+++ b/test/unit/default_data_test.rb
@@ -23,7 +23,7 @@ class DefaultDataTest < ActiveSupport::TestCase
def test_no_data
assert !Redmine::DefaultData::Loader::no_data?
- Role.delete_all("builtin = 0")
+ Role.where("builtin = 0").delete_all
Tracker.delete_all
IssueStatus.delete_all
Enumeration.delete_all
@@ -33,7 +33,7 @@ class DefaultDataTest < ActiveSupport::TestCase
def test_load
valid_languages.each do |lang|
begin
- Role.delete_all("builtin = 0")
+ Role.where("builtin = 0").delete_all
Tracker.delete_all
IssueStatus.delete_all
Enumeration.delete_all
diff --git a/test/unit/news_test.rb b/test/unit/news_test.rb
index d97233be5..825a47260 100644
--- a/test/unit/news_test.rb
+++ b/test/unit/news_test.rb
@@ -46,7 +46,7 @@ class NewsTest < ActiveSupport::TestCase
end
def test_should_not_include_news_for_projects_with_news_disabled
- EnabledModule.delete_all(["project_id = ? AND name = ?", 2, 'news'])
+ EnabledModule.where(["project_id = ? AND name = ?", 2, 'news']).delete_all
project = Project.find(2)
# Add a piece of news to the project
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index ef23e397c..ff513a276 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -1051,7 +1051,7 @@ class UserTest < ActiveSupport::TestCase
end
def test_own_account_deletable_should_be_false_for_a_single_admin
- User.delete_all(["admin = ? AND id <> ?", true, 1])
+ User.where(["admin = ? AND id <> ?", true, 1]).delete_all
with_settings :unsubscribe => '1' do
assert_equal false, User.find(1).own_account_deletable?
diff --git a/test/unit/watcher_test.rb b/test/unit/watcher_test.rb
index 8ffca148a..e44857dfb 100644
--- a/test/unit/watcher_test.rb
+++ b/test/unit/watcher_test.rb
@@ -150,7 +150,7 @@ class WatcherTest < ActiveSupport::TestCase
end
def test_prune_with_user
- Watcher.delete_all("user_id = 9")
+ Watcher.where("user_id = 9").delete_all
user = User.find(9)
# public