invoicing 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -0
  3. data/README.md +57 -0
  4. data/Rakefile +16 -37
  5. data/lib/invoicing.rb +20 -10
  6. data/lib/invoicing/cached_record.rb +9 -6
  7. data/lib/invoicing/class_info.rb +34 -34
  8. data/lib/invoicing/connection_adapter_ext.rb +4 -4
  9. data/lib/invoicing/countries/uk.rb +6 -6
  10. data/lib/invoicing/currency_value.rb +39 -32
  11. data/lib/invoicing/find_subclasses.rb +40 -15
  12. data/lib/invoicing/ledger_item.rb +166 -145
  13. data/lib/invoicing/ledger_item/pdf_generator.rb +108 -0
  14. data/lib/invoicing/ledger_item/render_html.rb +76 -73
  15. data/lib/invoicing/ledger_item/render_ubl.rb +37 -35
  16. data/lib/invoicing/line_item.rb +43 -38
  17. data/lib/invoicing/price.rb +1 -1
  18. data/lib/invoicing/tax_rate.rb +3 -6
  19. data/lib/invoicing/taxable.rb +37 -32
  20. data/lib/invoicing/time_dependent.rb +40 -40
  21. data/lib/invoicing/version.rb +4 -4
  22. data/lib/rails/generators/invoicing/invoicing_generator.rb +14 -0
  23. data/lib/rails/generators/invoicing/ledger_item/ledger_item_generator.rb +17 -0
  24. data/lib/rails/generators/invoicing/ledger_item/templates/migration.rb +25 -0
  25. data/lib/rails/generators/invoicing/ledger_item/templates/model.rb +5 -0
  26. data/lib/rails/generators/invoicing/line_item/line_item_generator.rb +17 -0
  27. data/lib/rails/generators/invoicing/line_item/templates/migration.rb +20 -0
  28. data/lib/rails/generators/invoicing/line_item/templates/model.rb +5 -0
  29. data/lib/rails/generators/invoicing/tax_rate/tax_rate_generator.rb +17 -0
  30. data/lib/rails/generators/invoicing/tax_rate/templates/migration.rb +14 -0
  31. data/lib/rails/generators/invoicing/tax_rate/templates/model.rb +3 -0
  32. metadata +110 -153
  33. data.tar.gz.sig +0 -1
  34. data/History.txt +0 -31
  35. data/Manifest.txt +0 -62
  36. data/PostInstall.txt +0 -10
  37. data/README.rdoc +0 -58
  38. data/script/console +0 -10
  39. data/script/destroy +0 -14
  40. data/script/generate +0 -14
  41. data/tasks/rcov.rake +0 -4
  42. data/test/cached_record_test.rb +0 -100
  43. data/test/class_info_test.rb +0 -253
  44. data/test/connection_adapter_ext_test.rb +0 -79
  45. data/test/currency_value_test.rb +0 -209
  46. data/test/find_subclasses_test.rb +0 -120
  47. data/test/fixtures/README +0 -7
  48. data/test/fixtures/cached_record.sql +0 -22
  49. data/test/fixtures/class_info.sql +0 -28
  50. data/test/fixtures/currency_value.sql +0 -29
  51. data/test/fixtures/find_subclasses.sql +0 -43
  52. data/test/fixtures/ledger_item.sql +0 -39
  53. data/test/fixtures/line_item.sql +0 -33
  54. data/test/fixtures/price.sql +0 -4
  55. data/test/fixtures/tax_rate.sql +0 -4
  56. data/test/fixtures/taxable.sql +0 -14
  57. data/test/fixtures/time_dependent.sql +0 -35
  58. data/test/ledger_item_test.rb +0 -444
  59. data/test/line_item_test.rb +0 -139
  60. data/test/models/README +0 -4
  61. data/test/models/test_subclass_in_another_file.rb +0 -3
  62. data/test/models/test_subclass_not_in_database.rb +0 -6
  63. data/test/price_test.rb +0 -9
  64. data/test/ref-output/creditnote3.html +0 -82
  65. data/test/ref-output/creditnote3.xml +0 -89
  66. data/test/ref-output/invoice1.html +0 -93
  67. data/test/ref-output/invoice1.xml +0 -111
  68. data/test/ref-output/invoice2.html +0 -86
  69. data/test/ref-output/invoice2.xml +0 -98
  70. data/test/ref-output/invoice_null.html +0 -36
  71. data/test/render_html_test.rb +0 -70
  72. data/test/render_ubl_test.rb +0 -44
  73. data/test/setup.rb +0 -37
  74. data/test/tax_rate_test.rb +0 -9
  75. data/test/taxable_test.rb +0 -180
  76. data/test/test_helper.rb +0 -72
  77. data/test/time_dependent_test.rb +0 -180
  78. metadata.gz.sig +0 -4
data.tar.gz.sig DELETED
@@ -1 +0,0 @@
1
- ���G�*���%0<N�t��^��2�$�P����3xő�����0�d�&k�U�t;2����k�ߚp���aP$V#�=@���` �f%m|��MaM,�SQ�g�.$� 8�7Ҥ,<�,��&��Y��u����GM8@���(b�nG�"���RuS��� �]�xK���PU�������.h�t�޿�3��{(���y�~��)�kgI��dz���T#�ر �UC5ےּ0� �=�v� hE�G��
@@ -1,31 +0,0 @@
1
- == 0.2.1
2
-
3
- * 2 minor enhancements:
4
- * Added option to LedgerItem#account_summary which enables inclusion of open/pending
5
- ledger items in the summary
6
- * Improved robustness and documentation for test suite
7
- * 2 bugfixes:
8
- * Compatibility with recent versions of ActiveRecord
9
- * Cleaned up unnecessary gem dependencies (mocha, uuid)
10
-
11
- == 0.2.0 2009-04-20
12
-
13
- * 4 major enhancements:
14
- * New associated gem invoicing_generator for generating an invoicing component in a Rails project
15
- (script/generate invoicing_ledger)
16
- * Generated controller and views for rendering statements and ledger
17
- * Comes with a nice default stylesheet out of the box
18
- * More flexible formatting of currency values
19
- * 1 bugfix:
20
- * Accidental overwriting of total_amount value on payment LedgerItems without LineItems
21
-
22
- == 0.1.0 2009-02-10
23
-
24
- * 2 major enhancements:
25
- * Core API is now usable
26
- * RCov reports 100% test coverage
27
-
28
- == 0.0.1 2009-01-05
29
-
30
- * 1 major enhancement:
31
- * Initial public release
@@ -1,62 +0,0 @@
1
- History.txt
2
- LICENSE
3
- Manifest.txt
4
- PostInstall.txt
5
- README.rdoc
6
- Rakefile
7
- lib/invoicing.rb
8
- lib/invoicing/cached_record.rb
9
- lib/invoicing/class_info.rb
10
- lib/invoicing/connection_adapter_ext.rb
11
- lib/invoicing/countries/uk.rb
12
- lib/invoicing/currency_value.rb
13
- lib/invoicing/find_subclasses.rb
14
- lib/invoicing/ledger_item.rb
15
- lib/invoicing/ledger_item/render_html.rb
16
- lib/invoicing/ledger_item/render_ubl.rb
17
- lib/invoicing/line_item.rb
18
- lib/invoicing/price.rb
19
- lib/invoicing/tax_rate.rb
20
- lib/invoicing/taxable.rb
21
- lib/invoicing/time_dependent.rb
22
- lib/invoicing/version.rb
23
- script/console
24
- script/destroy
25
- script/generate
26
- tasks/rcov.rake
27
- test/cached_record_test.rb
28
- test/class_info_test.rb
29
- test/connection_adapter_ext_test.rb
30
- test/currency_value_test.rb
31
- test/find_subclasses_test.rb
32
- test/fixtures/README
33
- test/fixtures/cached_record.sql
34
- test/fixtures/class_info.sql
35
- test/fixtures/currency_value.sql
36
- test/fixtures/find_subclasses.sql
37
- test/fixtures/ledger_item.sql
38
- test/fixtures/line_item.sql
39
- test/fixtures/price.sql
40
- test/fixtures/tax_rate.sql
41
- test/fixtures/taxable.sql
42
- test/fixtures/time_dependent.sql
43
- test/ledger_item_test.rb
44
- test/line_item_test.rb
45
- test/models/README
46
- test/models/test_subclass_in_another_file.rb
47
- test/models/test_subclass_not_in_database.rb
48
- test/price_test.rb
49
- test/ref-output/creditnote3.html
50
- test/ref-output/creditnote3.xml
51
- test/ref-output/invoice1.html
52
- test/ref-output/invoice1.xml
53
- test/ref-output/invoice2.html
54
- test/ref-output/invoice2.xml
55
- test/ref-output/invoice_null.html
56
- test/render_html_test.rb
57
- test/render_ubl_test.rb
58
- test/setup.rb
59
- test/tax_rate_test.rb
60
- test/taxable_test.rb
61
- test/test_helper.rb
62
- test/time_dependent_test.rb
@@ -1,10 +0,0 @@
1
-
2
- Thanks for trying the Ruby Invoicing Gem. Hope you find it useful.
3
- Do please blog and tweet about it (tag your posts with #invgem).
4
-
5
- Now please go to the root of your Rails project and type:
6
- script/generate invoicing_ledger billing --currency=GBP
7
- (replace GBP with your currency if you do not use Pounds Sterling).
8
- For more information please go to http://ept.github.com/invoicing/
9
-
10
-
@@ -1,58 +0,0 @@
1
- = Ruby Invoicing Framework
2
-
3
- * {Ruby Invoicing Framework website}[http://ept.github.com/invoicing/]
4
- * {API Reference Docs}[http://invoicing.rubyforge.org/doc/]
5
- * {Browse the code on GitHub}[http://github.com/ept/invoicing/]
6
- * {RubyForge project}[http://rubyforge.org/projects/invoicing/]
7
- * Email: Martin Kleppmann <ept@rubyforge.org>
8
-
9
- == DESCRIPTION
10
-
11
- This is a framework for generating and displaying invoices (ideal for
12
- commercial Rails apps). It allows for flexible business logic; provides tools
13
- for tax handling, commission calculation etc. It aims to be both
14
- developer-friendly and accountant-friendly.
15
-
16
- The Ruby Invoicing Framework is based on
17
- {ActiveRecord}[http://api.rubyonrails.org/classes/ActiveRecord/Base.html].
18
-
19
- Please see {the website}[http://ept.github.com/invoicing/] for an introduction
20
- to using Invoicing, and check the
21
- {API reference}[http://invoicing.rubyforge.org/doc/] for in-depth details.
22
-
23
- If you're interested in contributing to the invoicing gem itself, please see the file
24
- {HACKING.md}[http://github.com/ept/invoicing/blob/master/HACKING.md].
25
-
26
- == FEATURES
27
-
28
- * TODO
29
-
30
- == REQUIREMENTS
31
-
32
- * ActiveRecord >= 2.1
33
- * Only MySQL and PostgreSQL databases are currently supported
34
-
35
- == INSTALL
36
-
37
- sudo gem install invoicing
38
-
39
- == STATUS
40
-
41
- So far, the Ruby Invoicing Framework has been tested with ActiveRecord 2.2.2,
42
- MySQL 5.0.67 and PostgreSQL 8.3.5. We will be testing it across a wider
43
- variety of versions soon.
44
-
45
- == CREDITS
46
-
47
- The Ruby invoicing framework originated as part of the website
48
- {Bid for Wine}[http://www.bidforwine.co.uk], developed by Patrick Dietrich,
49
- Conrad Irwin, Michael Arnold and Martin Kleppmann for Ept Computing Ltd.
50
- It was extracted from the Bid for Wine codebase and substantially extended
51
- by Martin Kleppmann.
52
-
53
- == LICENSE
54
-
55
- Copyright (c) 2009 Martin Kleppmann, Ept Computing Limited.
56
-
57
- This gem is made publicly available under the terms of the MIT license.
58
- See LICENSE and/or COPYING for details.
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/invoicing.rb'}"
9
- puts "Loading invoicing gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,4 +0,0 @@
1
- desc "Run tests in rcov to analyse code coverage"
2
- task :coverage do
3
- exec "rcov -x '/Library/' -T test/*_test.rb"
4
- end
@@ -1,100 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper.rb')
2
-
3
- class CachedRecordTest < Test::Unit::TestCase
4
-
5
- class CachedRecord < ActiveRecord::Base
6
- set_primary_key 'id2'
7
- acts_as_cached_record :id => 'id2'
8
- has_many :referrers, :class_name => 'RefersToCachedRecord', :foreign_key => 'cached_record_id'
9
- end
10
-
11
- class RefersToCachedRecord < ActiveRecord::Base
12
- belongs_to :cached_record
13
- end
14
-
15
- class CachedRecordMockDatabase < ActiveRecord::Base
16
- set_table_name 'cached_records'
17
- set_primary_key 'id2'
18
- acts_as_cached_record :id => 'id2'
19
-
20
- def self.connection
21
- @connection_mock ||= FlexMock.new('connection')
22
- end
23
- end
24
-
25
-
26
- def test_find_with_valid_id_should_return_record
27
- record = CachedRecord.find(1)
28
- assert_not_nil record
29
- assert record.kind_of?(CachedRecord)
30
- end
31
-
32
- def test_find_with_invalid_id_should_raise_exception
33
- assert_raise ActiveRecord::RecordNotFound do
34
- CachedRecord.find(99)
35
- end
36
- end
37
-
38
- def test_find_with_valid_id_should_not_access_database
39
- CachedRecordMockDatabase.connection.should_receive(:select).and_throw('should not access database')
40
- assert_not_nil CachedRecordMockDatabase.find(1)
41
- end
42
-
43
- def test_find_with_invalid_id_should_not_access_database
44
- CachedRecordMockDatabase.connection.should_receive(:select).and_throw('should not access database')
45
- assert_raise ActiveRecord::RecordNotFound do
46
- CachedRecordMockDatabase.find(99)
47
- end
48
- end
49
-
50
- def test_find_with_conditions_should_still_work
51
- assert_equal CachedRecord.find_by_value('Two'), CachedRecord.find(2)
52
- end
53
-
54
- def test_find_with_conditions_should_not_use_the_cache
55
- assert !CachedRecord.find_by_value('Two').equal?(CachedRecord.find(2))
56
- end
57
-
58
- def test_find_without_ids_should_raise_exception
59
- assert_raise ActiveRecord::RecordNotFound do
60
- CachedRecord.find
61
- end
62
- end
63
-
64
- def test_find_with_empty_list_of_ids_should_raise_exception
65
- assert_raise ActiveRecord::RecordNotFound do
66
- CachedRecord.find(:conditions => {:id => []})
67
- end
68
- end
69
-
70
- def test_find_with_list_of_ids_should_return_list_of_objects
71
- expected = CachedRecord.cached_record_list.sort{|r1, r2| r1.id - r2.id}
72
- assert_equal expected, CachedRecord.find([1,2])
73
- end
74
-
75
- def test_cached_record_associations_should_still_work
76
- assert_equal 2, CachedRecord.find(1).referrers.length
77
- end
78
-
79
- def test_foreign_key_to_cached_record_should_use_cache
80
- assert RefersToCachedRecord.find(1).cached_record.equal?(CachedRecord.find(1))
81
- end
82
-
83
- def test_cached_record_list_should_return_all_objects
84
- assert_equal 2, CachedRecord.cached_record_list.length
85
- end
86
-
87
- def test_cached_record_list_should_not_access_database
88
- CachedRecordMockDatabase.connection.should_receive(:select).and_throw('should not access database')
89
- assert_not_nil CachedRecordMockDatabase.cached_record_list
90
- end
91
-
92
- def test_reload_cache_should_do_what_it_says_on_the_tin
93
- CachedRecord.connection.execute "insert into cached_records (id2, value) values(3, 'Three')"
94
- CachedRecord.reload_cache
95
- record = CachedRecord.find(3)
96
- assert_not_nil record
97
- assert record.kind_of?(CachedRecord)
98
- assert_equal 3, CachedRecord.cached_record_list.length
99
- end
100
- end
@@ -1,253 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper.rb')
2
-
3
- # Mini implementation of the ClassInfo pattern, at which we can fire our tests
4
-
5
- module MyNamespace
6
- module ClassInfoTestModule
7
- module ActMethods
8
- def acts_as_class_info_test(*args)
9
- Invoicing::ClassInfo.acts_as(MyNamespace::ClassInfoTestModule, self, args)
10
- end
11
- end
12
-
13
- def get_class_info
14
- class_info_test_module_class_info
15
- end
16
-
17
- def my_instance_method
18
- class_info_test_module_class_info.the_answer / value
19
- end
20
-
21
- def my_other_instance_method
22
- class_info_test_module_class_info.not_the_answer / value
23
- end
24
-
25
- module ClassMethods
26
- def my_class_method(number)
27
- class_info_test_module_class_info.the_answer / number
28
- end
29
-
30
- def my_other_class_method(number)
31
- class_info_test_module_class_info.not_the_answer / number
32
- end
33
-
34
- def get_class_info
35
- class_info_test_module_class_info
36
- end
37
- end
38
-
39
- class ClassInfo < Invoicing::ClassInfo::Base
40
- def foo
41
- 'foo'
42
- end
43
-
44
- def the_answer
45
- all_args.first
46
- end
47
-
48
- def not_the_answer
49
- all_args.last
50
- end
51
-
52
- def option_defaults
53
- {:option1 => :baa, :option2 => :blah}
54
- end
55
- end
56
- end
57
-
58
-
59
- module ClassInfoTest2
60
- module ActMethods
61
- def acts_as_class_info_test2(*args)
62
- Invoicing::ClassInfo.acts_as(MyNamespace::ClassInfoTest2, self, args)
63
- end
64
- end
65
-
66
- module ClassMethods
67
- def test2_class_info
68
- class_info_test2_class_info
69
- end
70
- end
71
-
72
- class ClassInfo < Invoicing::ClassInfo::Base
73
- end
74
- end
75
- end
76
-
77
- ActiveRecord::Base.send(:extend, MyNamespace::ClassInfoTestModule::ActMethods)
78
- ActiveRecord::Base.send(:extend, MyNamespace::ClassInfoTest2::ActMethods)
79
-
80
-
81
- # Model objects which use the acts_as feature defined above
82
-
83
- class ClassInfoTestRecord < ActiveRecord::Base
84
- acts_as_class_info_test 42, :option1 => :moo
85
- acts_as_class_info_test 84, 42, 168, :option3 => :asdf
86
-
87
- def self.class_foo
88
- class_info_test_module_class_info.foo
89
- end
90
-
91
- def instance_foo
92
- class_info_test_module_class_info.foo
93
- end
94
- end
95
-
96
- class ClassInfoTestSubclass < ClassInfoTestRecord
97
- acts_as_class_info_test 336, :option1 => :quack, :option4 => :fdsa
98
- end
99
-
100
- class ClassInfoTestSubclass2 < ClassInfoTestRecord
101
- acts_as_class_info_test2 :option1 => :badger
102
- end
103
-
104
- class ClassInfoTestSubSubclass < ClassInfoTestSubclass2
105
- acts_as_class_info_test 112, :option3 => 1234
106
- end
107
-
108
- class ClassInfoTestEmptySubclass < ClassInfoTestRecord
109
- end
110
-
111
- class ClassInfoTest2Record < ActiveRecord::Base
112
- acts_as_class_info_test2 :option1 => :okapi, :option3 => :kangaroo
113
-
114
- def option1; 'this is option1'; end
115
- def option2; 'this is option2'; end
116
- def kangaroo; 'bounce'; end
117
- end
118
-
119
-
120
- #######################################################################################
121
-
122
- class ClassInfoTest < Test::Unit::TestCase
123
-
124
- def test_call_into_class_info_via_class
125
- assert_equal 'foo', ClassInfoTestRecord.class_foo
126
- end
127
-
128
- def test_call_into_class_info_via_instance
129
- assert_equal 'foo', ClassInfoTestRecord.new.instance_foo
130
- end
131
-
132
- def test_mixin_superclass_instance_methods
133
- assert_equal 21, ClassInfoTestRecord.find(1).my_instance_method
134
- assert_equal 84, ClassInfoTestRecord.find(1).my_other_instance_method
135
- end
136
-
137
- def test_mixin_superclass_class_methods
138
- assert_equal 14, ClassInfoTestRecord.my_class_method(3)
139
- assert_equal 28, ClassInfoTestRecord.my_other_class_method(6)
140
- end
141
-
142
- def test_mixin_subclass_instance_methods
143
- assert_equal 14, ClassInfoTestRecord.find(2).my_instance_method
144
- assert_equal 112, ClassInfoTestRecord.find(2).my_other_instance_method
145
- end
146
-
147
- def test_mixin_subclass_class_methods
148
- assert_equal 14, ClassInfoTestSubclass.my_class_method(3)
149
- assert_equal 56, ClassInfoTestSubclass.my_other_class_method(6)
150
- end
151
-
152
- def test_all_args_in_superclass
153
- assert_equal [42, 84, 168], ClassInfoTestRecord.get_class_info.all_args
154
- end
155
-
156
- def test_all_args_in_subclass
157
- assert_equal [42, 84, 168, 336], ClassInfoTestSubclass.get_class_info.all_args
158
- end
159
-
160
- def test_all_args_in_sub_subclass
161
- assert_equal [42, 84, 168, 112], ClassInfoTestSubSubclass.get_class_info.all_args
162
- end
163
-
164
- def test_current_args_in_superclass
165
- assert_equal [84, 42, 168], ClassInfoTestRecord.get_class_info.current_args
166
- end
167
-
168
- def test_current_args_in_subclass
169
- assert_equal [336], ClassInfoTestSubclass.get_class_info.current_args
170
- end
171
-
172
- def test_current_args_in_sub_subclass
173
- assert_equal [112], ClassInfoTestSubSubclass.get_class_info.current_args
174
- end
175
-
176
- def test_new_args_in_superclass
177
- assert_equal [84, 168], ClassInfoTestRecord.get_class_info.new_args
178
- end
179
-
180
- def test_new_args_in_subclass
181
- assert_equal [336], ClassInfoTestSubclass.get_class_info.new_args
182
- end
183
-
184
- def test_new_args_in_sub_subclass
185
- assert_equal [112], ClassInfoTestSubSubclass.get_class_info.new_args
186
- end
187
-
188
- def test_all_options_in_superclass
189
- assert_equal :moo, ClassInfoTestRecord.get_class_info.all_options[:option1]
190
- assert_equal :blah, ClassInfoTestRecord.get_class_info.all_options[:option2]
191
- assert_equal :asdf, ClassInfoTestRecord.get_class_info.all_options[:option3]
192
- assert_nil ClassInfoTestRecord.get_class_info.all_options[:option4]
193
- end
194
-
195
- def test_all_options_in_subclass
196
- assert_equal :quack, ClassInfoTestSubclass.get_class_info.all_options[:option1]
197
- assert_equal :blah, ClassInfoTestSubclass.get_class_info.all_options[:option2]
198
- assert_equal :asdf, ClassInfoTestSubclass.get_class_info.all_options[:option3]
199
- assert_equal :fdsa, ClassInfoTestSubclass.get_class_info.all_options[:option4]
200
- end
201
-
202
- def test_all_options_in_sub_subclass
203
- assert_equal :moo, ClassInfoTestSubSubclass.get_class_info.all_options[:option1]
204
- assert_equal :blah, ClassInfoTestSubSubclass.get_class_info.all_options[:option2]
205
- assert_equal 1234, ClassInfoTestSubSubclass.get_class_info.all_options[:option3]
206
- assert_nil ClassInfoTestSubSubclass.get_class_info.all_options[:option4]
207
- end
208
-
209
- def test_current_options_in_superclass
210
- assert_equal({:option3 => :asdf}, ClassInfoTestRecord.get_class_info.current_options)
211
- end
212
-
213
- def test_current_options_in_subclass
214
- assert_equal({:option1 => :quack, :option4 => :fdsa}, ClassInfoTestSubclass.get_class_info.current_options)
215
- end
216
-
217
- def test_two_features_in_the_same_model
218
- assert_equal({:option1 => :badger}, ClassInfoTestSubclass2.test2_class_info.all_options)
219
- assert_equal({:option1 => :badger}, ClassInfoTestSubSubclass.test2_class_info.all_options)
220
- end
221
-
222
- def test_the_same_feature_in_two_models
223
- assert_equal({:option1 => :okapi, :option3 => :kangaroo}, ClassInfoTest2Record.test2_class_info.all_options)
224
- end
225
-
226
- def test_method_renamed
227
- assert_equal 'kangaroo', ClassInfoTest2Record.test2_class_info.method(:option3)
228
- assert_equal 'bounce', ClassInfoTest2Record.test2_class_info.get(ClassInfoTest2Record.find(1), :option3)
229
- end
230
-
231
- def test_database_column_renamed
232
- assert_equal 'okapi', ClassInfoTest2Record.test2_class_info.method(:option1)
233
- assert_equal 'OKAPI!', ClassInfoTest2Record.test2_class_info.get(ClassInfoTest2Record.find(1), :option1)
234
- end
235
-
236
- def test_method_not_renamed
237
- assert_equal 'option2', ClassInfoTest2Record.test2_class_info.method(:option2)
238
- assert_equal 'this is option2', ClassInfoTest2Record.test2_class_info.get(ClassInfoTest2Record.find(1), :option2)
239
- end
240
-
241
- def test_method_on_nil_object
242
- assert_nil ClassInfoTest2Record.test2_class_info.get(nil, :option2)
243
- end
244
-
245
- def test_method_not_found_via_class_info
246
- assert_nil ClassInfoTest2Record.test2_class_info.get(ClassInfoTest2Record.find(1), :this_method_does_not_exist)
247
- end
248
-
249
- def test_inherited_to_empty_subclass
250
- assert_not_nil ClassInfoTestEmptySubclass.new.get_class_info
251
- assert_equal ClassInfoTestEmptySubclass.new.get_class_info, ClassInfoTestRecord.new.get_class_info
252
- end
253
- end