Skip to content

Commit

Permalink
Fix deprecation warning for set_table_name
Browse files Browse the repository at this point in the history
ActiveRecord 3.2.x uses `self.table_name = …` instead
  • Loading branch information
boosty committed Dec 27, 2011
1 parent da6dd8a commit a8aff4e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/flag_shih_tzu_test.rb
@@ -1,7 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')

class Spaceship < ActiveRecord::Base
set_table_name 'spaceships'
self.table_name = 'spaceships'
include FlagShihTzu

has_flags 1 => :warpdrive,
Expand All @@ -10,43 +10,43 @@ class Spaceship < ActiveRecord::Base
end

class SpaceshipWithoutNamedScopes < ActiveRecord::Base
set_table_name 'spaceships'
self.table_name = 'spaceships'
include FlagShihTzu

has_flags(1 => :warpdrive, :named_scopes => false)
end

class SpaceshipWithoutNamedScopesOldStyle < ActiveRecord::Base
set_table_name 'spaceships'
self.table_name = 'spaceships'
include FlagShihTzu

has_flags({1 => :warpdrive}, :named_scopes => false)
end

class SpaceshipWithCustomFlagsColumn < ActiveRecord::Base
set_table_name 'spaceships_with_custom_flags_column'
self.table_name = 'spaceships_with_custom_flags_column'
include FlagShihTzu

has_flags(1 => :warpdrive, 2 => :hyperspace, :column => 'bits')
end

class SpaceshipWithColumnNameAsSymol < ActiveRecord::Base
set_table_name 'spaceships_with_custom_flags_column'
self.table_name = 'spaceships_with_custom_flags_column'
include FlagShihTzu

has_flags(1 => :warpdrive, 2 => :hyperspace, :column => :bits)
end

class SpaceshipWith2CustomFlagsColumn < ActiveRecord::Base
set_table_name 'spaceships_with_2_custom_flags_column'
self.table_name = 'spaceships_with_2_custom_flags_column'
include FlagShihTzu

has_flags({ 1 => :warpdrive, 2 => :hyperspace }, :column => 'bits')
has_flags({ 1 => :jeanlucpicard, 2 => :dajanatroj }, :column => 'commanders')
end

class SpaceshipWithBitOperatorQueryMode < ActiveRecord::Base
set_table_name 'spaceships'
self.table_name = 'spaceships'
include FlagShihTzu

has_flags(1 => :warpdrive, 2 => :shields, :flag_query_mode => :bit_operator)
Expand All @@ -69,7 +69,7 @@ def test_has_flags_should_raise_an_exception_when_flag_key_is_negative
assert_raises ArgumentError do
eval(<<-EOF
class SpaceshipWithInvalidFlagKey < ActiveRecord::Base
set_table_name 'spaceships'
self.table_name = 'spaceships'
include FlagShihTzu
has_flags({ -1 => :error })
Expand All @@ -83,7 +83,7 @@ def test_has_flags_should_raise_an_exception_when_flag_name_already_used
assert_raises ArgumentError do
eval(<<-EOF
class SpaceshipWithAlreadyUsedFlag < ActiveRecord::Base
set_table_name 'spaceships_with_2_custom_flags_column'
self.table_name = 'spaceships_with_2_custom_flags_column'
include FlagShihTzu
has_flags({ 1 => :jeanluckpicard }, :column => 'bits')
Expand All @@ -98,7 +98,7 @@ def test_has_flags_should_raise_an_exception_when_desired_flag_name_method_alrea
assert_raises ArgumentError do
eval(<<-EOF
class SpaceshipWithAlreadyUsedMethod < ActiveRecord::Base
set_table_name 'spaceships_with_2_custom_flags_column'
self.table_name = 'spaceships_with_2_custom_flags_column'
include FlagShihTzu
def jeanluckpicard; end
Expand All @@ -114,7 +114,7 @@ def test_has_flags_should_not_raise_an_exception_when_flag_name_method_defined_b
assert_nothing_raised ArgumentError do
eval(<<-EOF
class SpaceshipWithAlreadyUsedMethodByFlagshitzu < ActiveRecord::Base
set_table_name 'spaceships_with_2_custom_flags_column'
self.table_name = 'spaceships_with_2_custom_flags_column'
include FlagShihTzu
has_flags({ 1 => :jeanluckpicard }, :column => 'bits')
Expand All @@ -129,7 +129,7 @@ def test_has_flags_should_raise_an_exception_when_flag_name_is_not_a_symbol
assert_raises ArgumentError do
eval(<<-EOF
class SpaceshipWithInvalidFlagName < ActiveRecord::Base
set_table_name 'spaceships'
self.table_name = 'spaceships'
include FlagShihTzu
has_flags({ 1 => 'error' })
Expand Down Expand Up @@ -422,7 +422,7 @@ def test_should_ignore_has_flags_call_if_column_does_not_exist_yet
assert_nothing_raised do
eval(<<-EOF
class SpaceshipWithoutFlagsColumn < ActiveRecord::Base
set_table_name 'spaceships_without_flags_column'
self.table_name = 'spaceships_without_flags_column'
include FlagShihTzu
has_flags 1 => :warpdrive,
Expand All @@ -440,7 +440,7 @@ def test_should_ignore_has_flags_call_if_column_not_integer
assert_raises FlagShihTzu::IncorrectFlagColumnException do
eval(<<-EOF
class SpaceshipWithNonIntegerColumn < ActiveRecord::Base
set_table_name 'spaceships_with_non_integer_column'
self.table_name ='spaceships_with_non_integer_column'
include FlagShihTzu
has_flags 1 => :warpdrive,
Expand Down

0 comments on commit a8aff4e

Please sign in to comment.