Skip to content
Browse files

removed #frozen? messages

git-svn-id: https://svn.thoughtbot.com/plugins/when/trunk@328 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent 4944acf commit c44041dfbeb6ab175c7cf0669931eea398db617e jcarroll committed Feb 14, 2008
Showing with 22 additions and 17 deletions.
  1. +12 −12 test/callbacks_test.rb
  2. +3 −3 test/database.yml
  3. +7 −2 test/fixtures/company.rb
View
24 test/callbacks_test.rb
@@ -86,40 +86,40 @@ def setup
end
destroy_callbacks.each do |callback|
- define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
- Company.send callback.to_sym, :change_name, :if => condition
+ define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_true_should_toggle_callback_flag" do
+ Company.send callback.to_sym, :toggle_callback_flag, :if => condition
company = Company.new :name => 'thoughtbot', :callback_flag => true
assert company.save
assert company.destroy
- assert_equal 'new name', company.name unless company.frozen?
+ assert ! company.callback_flag
end
- define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
- Company.send callback.to_sym, :change_name, :if => condition
+ define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_false_should_not_toggle_callback_flag" do
+ Company.send callback.to_sym, :toggle_callback_flag, :if => condition
company = Company.new :name => 'thoughtbot', :callback_flag => false
assert company.save
assert company.destroy
- assert_equal 'thoughtbot', company.name
+ assert ! company.callback_flag
end
- define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
- Company.send callback.to_sym, :change_name, :unless => condition
+ define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_true_should_not_toggle_callback_flag" do
+ Company.send callback.to_sym, :toggle_callback_flag, :unless => condition
company = Company.new :name => 'thoughtbot', :callback_flag => true
assert company.save
assert company.destroy
- assert_equal 'thoughtbot', company.name
+ assert company.callback_flag
end
- define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
- Company.send callback.to_sym, :change_name, :unless => condition
+ define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_false_should_toggle_callback_flag" do
+ Company.send callback.to_sym, :toggle_callback_flag, :unless => condition
company = Company.new :name => 'thoughtbot', :callback_flag => false
assert company.save
assert company.destroy
- assert_equal 'new name', company.name unless company.frozen?
+ assert company.callback_flag
end
end
end
View
6 test/database.yml
@@ -1,6 +1,6 @@
test:
adapter: mysql
- database: ar_callback_conditions
+ database: when_plugin
host: localhost
- username: root
- password:
+ username: when_plugin
+ password: when_plugin
View
9 test/fixtures/company.rb
@@ -3,11 +3,16 @@ class Company < ActiveRecord::Base
attr_accessor :callback_flag
def change_name
- self.name = 'new name' unless frozen?
+ self.name = 'new name'
end
def flag?
callback_flag == true
end
-
+
+ def toggle_callback_flag
+ self.callback_flag = ! callback_flag
+ return true
+ end
+
end

0 comments on commit c44041d

Please sign in to comment.
Something went wrong with that request. Please try again.