has_phone_numbers 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  == master
2
2
 
3
+ == 0.1.0 / 2008-12-14
4
+
5
+ * Remove the PluginAWeek namespace
6
+
3
7
  == 0.0.5 / 2008-10-26
4
8
 
5
9
  * Change how the base module is included to prevent namespacing conflicts
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = 'has_phone_numbers'
8
- s.version = '0.0.5'
8
+ s.version = '0.1.0'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = 'Demonstrates a reference implementation for handling phone numbers.'
11
11
 
@@ -1,17 +1,15 @@
1
- module PluginAWeek #:nodoc:
2
- # Adds a generic implementation for dealing with phone numbers
3
- module HasPhoneNumbers
4
- module MacroMethods
5
- # Creates the following association:
6
- # * +phone_number+ - All phone numbers associated with the current record.
7
- def has_phone_numbers
8
- has_many :phone_numbers,
9
- :as => :phoneable
10
- end
1
+ # Adds a generic implementation for dealing with phone numbers
2
+ module HasPhoneNumbers
3
+ module MacroMethods
4
+ # Creates the following association:
5
+ # * +phone_number+ - All phone numbers associated with the current record.
6
+ def has_phone_numbers
7
+ has_many :phone_numbers,
8
+ :as => :phoneable
11
9
  end
12
10
  end
13
11
  end
14
12
 
15
13
  ActiveRecord::Base.class_eval do
16
- extend PluginAWeek::HasPhoneNumbers::MacroMethods
14
+ extend HasPhoneNumbers::MacroMethods
17
15
  end
@@ -33,33 +33,33 @@ class PhoneNumberTest < Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  def test_should_require_a_phoneable_id
36
- phone_number = new_phone_number(:phoneable_id => nil)
36
+ phone_number = new_phone_number(:phoneable => nil, :phoneable_id => nil)
37
37
  assert !phone_number.valid?
38
- assert_equal 1, Array(phone_number.errors.on(:phoneable_id)).size
38
+ assert phone_number.errors.invalid?(:phoneable_id)
39
39
  end
40
40
 
41
41
  def test_should_require_a_phoneable_type
42
- phone_number = new_phone_number(:phoneable_type => nil)
42
+ phone_number = new_phone_number(:phoneable => nil, :phoneable_type => nil)
43
43
  assert !phone_number.valid?
44
- assert_equal 1, Array(phone_number.errors.on(:phoneable_type)).size
44
+ assert phone_number.errors.invalid?(:phoneable_type)
45
45
  end
46
46
 
47
47
  def test_should_require_a_country_code
48
48
  phone_number = new_phone_number(:country_code => nil)
49
49
  assert !phone_number.valid?
50
- assert_equal 3, Array(phone_number.errors.on(:country_code)).size
50
+ assert phone_number.errors.invalid?(:country_code)
51
51
  end
52
52
 
53
53
  def test_should_require_country_code_be_a_number
54
54
  phone_number = new_phone_number(:country_code => 'a')
55
55
  assert !phone_number.valid?
56
- assert_equal 1, Array(phone_number.errors.on(:country_code)).size
56
+ assert phone_number.errors.invalid?(:country_code)
57
57
  end
58
58
 
59
59
  def test_should_require_country_codes_be_between_1_and_3_numbers
60
60
  phone_number = new_phone_number(:country_code => '')
61
61
  assert !phone_number.valid?
62
- assert_equal 3, Array(phone_number.errors.on(:country_code)).size
62
+ assert phone_number.errors.invalid?(:country_code)
63
63
 
64
64
  phone_number.country_code += '1'
65
65
  assert phone_number.valid?
@@ -69,32 +69,32 @@ class PhoneNumberTest < Test::Unit::TestCase
69
69
 
70
70
  phone_number.country_code += '1'
71
71
  assert !phone_number.valid?
72
- assert_equal 1, Array(phone_number.errors.on(:country_code)).size
72
+ assert phone_number.errors.invalid?(:country_code)
73
73
  end
74
74
 
75
75
  def test_should_require_a_number
76
76
  phone_number = new_phone_number(:number => nil)
77
77
  assert !phone_number.valid?
78
- assert_equal 3, Array(phone_number.errors.on(:number)).size
78
+ assert phone_number.errors.invalid?(:number)
79
79
  end
80
80
 
81
81
  def test_should_require_number_be_a_number
82
82
  phone_number = new_phone_number(:number => 'a' * 10)
83
83
  assert !phone_number.valid?
84
- assert_equal 1, Array(phone_number.errors.on(:number)).size
84
+ assert phone_number.errors.invalid?(:number)
85
85
  end
86
86
 
87
87
  def test_should_require_number_be_exactly_10_numbers
88
88
  phone_number = new_phone_number(:number => '1' * 9)
89
89
  assert !phone_number.valid?
90
- assert_equal 1, Array(phone_number.errors.on(:number)).size
90
+ assert phone_number.errors.invalid?(:number)
91
91
 
92
92
  phone_number.number += '1'
93
93
  assert phone_number.valid?
94
94
 
95
95
  phone_number.number += '1'
96
96
  assert !phone_number.valid?
97
- assert_equal 1, Array(phone_number.errors.on(:number)).size
97
+ assert phone_number.errors.invalid?(:number)
98
98
  end
99
99
 
100
100
  def test_should_not_require_an_extension
@@ -111,7 +111,7 @@ class PhoneNumberTest < Test::Unit::TestCase
111
111
 
112
112
  phone_number.extension += '1'
113
113
  assert !phone_number.valid?
114
- assert_equal 1, Array(phone_number.errors.on(:extension)).size
114
+ assert phone_number.errors.invalid?(:extension)
115
115
  end
116
116
 
117
117
  def test_should_protect_attributes_from_mass_assignment
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_phone_numbers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-26 00:00:00 -04:00
12
+ date: 2008-12-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -27,22 +27,22 @@ files:
27
27
  - db/migrate
28
28
  - db/migrate/001_create_phone_numbers.rb
29
29
  - lib/has_phone_numbers.rb
30
- - test/app_root
31
- - test/app_root/app
32
- - test/app_root/app/models
33
- - test/app_root/app/models/person.rb
34
- - test/app_root/config
35
- - test/app_root/config/environment.rb
36
- - test/app_root/db
37
- - test/app_root/db/migrate
38
- - test/app_root/db/migrate/001_create_people.rb
39
- - test/app_root/db/migrate/002_migrate_has_phone_numbers_to_version_1.rb
30
+ - test/factory.rb
31
+ - test/test_helper.rb
40
32
  - test/functional
41
33
  - test/functional/has_phone_numbers_test.rb
42
- - test/test_helper.rb
43
- - test/factory.rb
44
34
  - test/unit
45
35
  - test/unit/phone_number_test.rb
36
+ - test/app_root
37
+ - test/app_root/db
38
+ - test/app_root/db/migrate
39
+ - test/app_root/db/migrate/002_migrate_has_phone_numbers_to_version_1.rb
40
+ - test/app_root/db/migrate/001_create_people.rb
41
+ - test/app_root/config
42
+ - test/app_root/config/environment.rb
43
+ - test/app_root/app
44
+ - test/app_root/app/models
45
+ - test/app_root/app/models/person.rb
46
46
  - CHANGELOG.rdoc
47
47
  - init.rb
48
48
  - LICENSE