This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

change to the way this plugin is enabled and disabled

git-svn-id: https://svn.thoughtbot.com/plugins/mile_marker/trunk@153 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
cpytel
cpytel committed Aug 1, 2007
1 parent e3396f2 commit 8b3a41225bc84fb956d4f723842b925ff161cebe
Showing with 33 additions and 1 deletion.
  1. +9 −1 README
  2. +8 −0 lib/mile_marker.rb
  3. +16 −0 test/mile_marker_test.rb
View
10 README
@@ -26,7 +26,15 @@ If you happen to not call your milestones, "milestones", or for any other reason
And that will still result in the marker being labeled with "Next Week" instead.
-By default, the milestone markers will be only appear in the Rails development environment. To customize this, add the following to environment.rb
+By default, the milestone markers will be only appear in the Rails development environment. To customize this, add the following to the config file of the other environments you want the markers to appear:
+
+Thoughtbot::MileMarker.enable
+
+If you prefer not to have it on in development, add the following to development.rb
+
+Thoughtbot::MileMarker.disable
+
+Or, if you prefer, add something like the following to environment.rb:
Thoughtbot::MileMarker.environments = %w(development staging production)
View
@@ -28,6 +28,14 @@ def self.enabled?
environments.include?(ENV['RAILS_ENV'])
end
+ def self.enable
+ environments.push ENV['RAILS_ENV']
+ end
+
+ def self.disable
+ environments.delete ENV['RAILS_ENV']
+ end
+
def self.initialize_mile_marker()
%Q~
<script type="text/javascript">
View
@@ -31,6 +31,22 @@ def test_mile_helper_should_include_no_detail_when_supplied_no_detail
assert_equal "mile=\"\"", output
end
+ def test_calling_enabled_should_add_current_environment_to_environments
+ Thoughtbot::MileMarker.environments = []
+ ENV['RAILS_ENV']="test_environment"
+ Thoughtbot::MileMarker.enable
+ assert Thoughtbot::MileMarker.environments.include?(ENV['RAILS_ENV'])
+ end
+
+ def test_calling_disabled_should_remove_current_environment_from_environments
+ Thoughtbot::MileMarker.environments = []
+ ENV['RAILS_ENV']="test_environment"
+ Thoughtbot::MileMarker.enable
+ assert Thoughtbot::MileMarker.environments.include?(ENV['RAILS_ENV'])
+ Thoughtbot::MileMarker.disable
+ assert !Thoughtbot::MileMarker.environments.include?(ENV['RAILS_ENV'])
+ end
+
def test_initialize_mile_should_return_nothing_if_not_enabled
ENV['RAILS_ENV']="test_environment"
output = initialize_mile_marker

0 comments on commit 8b3a412

Please sign in to comment.