Skip to content

Instantly share code, notes, and snippets.

@atonse
Created September 14, 2011 21:37
Show Gist options
  • Save atonse/1217868 to your computer and use it in GitHub Desktop.
Save atonse/1217868 to your computer and use it in GitHub Desktop.
Undefine certain task so there is no chance of running this by mistake in a more important environment
def undefine_task(*names)
app = Rake.application
tasks = app.instance_variable_get('@tasks')
names.flatten.each { |name| tasks.delete(name) }
end
if %W{production staging integration}.include?(Rails.env)
undefine_task %w(
db:bootstrap
db:bootstrap:reset
db:reset
db:drop
db:drop:all
db:data:load_dump
db:fixtures:load
db:migrate:down
db:migrate:reset
db:setup
db:nuke_and_pave
db:dev_nuke_and_pave
db:uat_nuke_and_pave
spec
spec:rcov
spec_html
test
test:benchmark
test:coverage
test:coverage_minimum_met
test:functionals
test:integration
test:plugins
test:profile
test:recent
test:uncommitted
test:units
testing:invoke_rake_task
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment