clevic 0.12.0 → 0.13.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Manifest.txt +209 -30
- data/README.txt +16 -20
- data/Rakefile +8 -8
- data/TODO +6 -7
- data/bin/clevic +12 -73
- data/lib/clevic/action_builder.rb +168 -0
- data/lib/clevic/ar_methods.rb +120 -0
- data/lib/clevic/attribute_list.rb +56 -0
- data/lib/clevic/cache_table.rb +60 -37
- data/lib/clevic/default_view.rb +3 -16
- data/lib/clevic/delegate.rb +46 -0
- data/lib/clevic/emitter.rb +38 -0
- data/lib/clevic/extensions.rb +61 -114
- data/lib/clevic/field.rb +159 -228
- data/lib/clevic/field_valuer.rb +165 -0
- data/lib/clevic/filter_command.rb +2 -6
- data/lib/clevic/generic_format.rb +52 -0
- data/lib/clevic/{ui → icons}/icon.png +0 -0
- data/lib/clevic/many_field.rb +7 -0
- data/lib/clevic/model_builder.rb +234 -146
- data/lib/clevic/model_column.rb +61 -13
- data/lib/clevic/order_attribute.rb +10 -0
- data/lib/clevic/qt.rb +35 -0
- data/lib/clevic/qt/action_builder.rb +47 -0
- data/lib/clevic/qt/boolean_delegate.rb +8 -0
- data/lib/clevic/{browser.rb → qt/browser.rb} +35 -14
- data/lib/clevic/qt/clipboard.rb +35 -0
- data/lib/clevic/qt/combo_delegate.rb +198 -0
- data/lib/clevic/qt/delegates.rb +1 -0
- data/lib/clevic/qt/distinct_delegate.rb +35 -0
- data/lib/clevic/qt/extensions.rb +52 -0
- data/lib/clevic/qt/field.rb +18 -0
- data/lib/clevic/{item_delegate.rb → qt/item_delegate.rb} +8 -4
- data/lib/clevic/qt/relational_delegate.rb +87 -0
- data/lib/clevic/{search_dialog.rb → qt/search_dialog.rb} +1 -11
- data/lib/clevic/qt/set_delegate.rb +44 -0
- data/lib/clevic/qt/table_model.rb +331 -0
- data/lib/clevic/qt/table_view.rb +344 -0
- data/lib/clevic/qt/text_area_delegate.rb +8 -0
- data/lib/clevic/{text_delegate.rb → qt/text_delegate.rb} +6 -4
- data/lib/clevic/{ui → qt/ui}/.gitignore +0 -0
- data/lib/clevic/{ui → qt/ui}/browser.ui +0 -0
- data/lib/clevic/{ui → qt/ui}/search_dialog.ui +0 -0
- data/lib/clevic/rails_models_loaders.rb +56 -0
- data/lib/clevic/record.rb +2 -17
- data/lib/clevic/sampler.rb +81 -0
- data/lib/clevic/sequel_ar_adapter.rb +215 -0
- data/lib/clevic/sequel_length_validation.rb +23 -0
- data/lib/clevic/sequel_meta.rb +65 -0
- data/lib/clevic/sequel_naked.rb +30 -0
- data/lib/clevic/swing.rb +38 -0
- data/lib/clevic/swing/action.rb +125 -0
- data/lib/clevic/swing/action_builder.rb +47 -0
- data/lib/clevic/swing/boolean_delegate.rb +26 -0
- data/lib/clevic/swing/browser.rb +282 -0
- data/lib/clevic/swing/cell_editor.rb +95 -0
- data/lib/clevic/swing/cell_renderer.rb +44 -0
- data/lib/clevic/swing/clipboard.rb +135 -0
- data/lib/clevic/swing/combo_delegate.rb +336 -0
- data/lib/clevic/swing/confirm_dialog.rb +57 -0
- data/lib/clevic/swing/delegate.rb +40 -0
- data/lib/clevic/swing/distinct_delegate.rb +30 -0
- data/lib/clevic/swing/extensions.rb +274 -0
- data/lib/clevic/swing/field.rb +35 -0
- data/lib/clevic/swing/relational_delegate.rb +48 -0
- data/lib/clevic/swing/row_header.rb +210 -0
- data/lib/clevic/swing/search_dialog.rb +230 -0
- data/lib/clevic/swing/selection_model.rb +90 -0
- data/lib/clevic/swing/set_delegate.rb +41 -0
- data/lib/clevic/swing/swing_table_index.rb +43 -0
- data/lib/clevic/swing/table_model.rb +200 -0
- data/lib/clevic/swing/table_view.rb +385 -0
- data/lib/clevic/swing/table_view_focus.rb +47 -0
- data/lib/clevic/swing/tag_delegate.rb +127 -0
- data/lib/clevic/swing/tag_editor.rb +101 -0
- data/lib/clevic/swing/text_area_delegate.rb +46 -0
- data/lib/clevic/swing/text_delegate.rb +31 -0
- data/lib/clevic/swing/ui/build.xml +74 -0
- data/lib/clevic/swing/ui/dist/README.TXT +33 -0
- data/lib/clevic/swing/ui/dist/lib/swing-layout-1.0.3.jar +0 -0
- data/lib/clevic/swing/ui/manifest.mf +3 -0
- data/lib/clevic/swing/ui/nbproject/build-impl.xml +731 -0
- data/lib/clevic/swing/ui/nbproject/genfiles.properties +8 -0
- data/lib/clevic/swing/ui/nbproject/private/config.properties +0 -0
- data/lib/clevic/swing/ui/nbproject/private/private.properties +6 -0
- data/lib/clevic/swing/ui/nbproject/private/private.xml +4 -0
- data/lib/clevic/swing/ui/nbproject/project.properties +70 -0
- data/lib/clevic/swing/ui/nbproject/project.xml +14 -0
- data/lib/clevic/swing/ui/src/SearchDialog.form +158 -0
- data/lib/clevic/swing/ui/src/SearchDialog.java +163 -0
- data/lib/clevic/swing/ui/src/TagEditor.form +106 -0
- data/lib/clevic/swing/ui/src/TagEditor.java +108 -0
- data/lib/clevic/swing/ui/src/resources/SearchDialog.properties +0 -0
- data/lib/clevic/table_index.rb +100 -0
- data/lib/clevic/table_model.rb +54 -425
- data/lib/clevic/table_searcher.rb +113 -116
- data/lib/clevic/table_view.rb +171 -399
- data/lib/clevic/table_view_paste.rb +199 -0
- data/lib/clevic/version.rb +3 -2
- data/lib/clevic/view.rb +94 -43
- data/models/accounts_models.rb +13 -13
- data/models/minimal_models.rb +5 -9
- data/models/times_models.rb +19 -14
- data/models/times_psql_models.rb +10 -0
- data/models/times_sqlite_models.rb +1 -8
- data/models/values_models.rb +2 -8
- data/tasks/clevic.rake +1 -1
- data/tasks/rdoc.rake +1 -5
- data/tasks/website.rake +1 -1
- data/test/test_cache_table.rb +15 -29
- data/test/test_helper.rb +14 -83
- data/test/test_order_attribute.rb +1 -1
- data/test/test_table_model.rb +0 -21
- data/test/test_table_searcher.rb +67 -61
- metadata +262 -78
- data/lib/clevic.rb +0 -4
- data/lib/clevic/db_options.rb +0 -112
- data/lib/clevic/delegates.rb +0 -386
data/models/minimal_models.rb
CHANGED
@@ -3,21 +3,17 @@ require 'clevic.rb'
|
|
3
3
|
# see sql/accounts.sql for schema
|
4
4
|
|
5
5
|
# db connection
|
6
|
-
|
7
|
-
database 'accounts_test'
|
8
|
-
adapter :postgresql
|
9
|
-
username 'accounts'
|
10
|
-
end
|
6
|
+
Sequel.connect( "postgres://#{host}/accounts_test?user=#{$options[:username] || 'accounts'}&password=#{$options[:password]}" )
|
11
7
|
|
12
8
|
# minimal definition to get combo boxes to show up
|
13
|
-
class Entry <
|
9
|
+
class Entry < Sequel::Model
|
14
10
|
include Clevic::Record
|
15
|
-
|
16
|
-
|
11
|
+
many_to_one :debit, :class_name => 'Account', :foreign_key => 'debit_id'
|
12
|
+
many_to_one :credit, :class_name => 'Account', :foreign_key => 'credit_id'
|
17
13
|
end
|
18
14
|
|
19
15
|
# minimal definition to get sensible values in combo boxes
|
20
|
-
class Account <
|
16
|
+
class Account < Sequel::Model
|
21
17
|
include Clevic::Record
|
22
18
|
def to_s; name; end
|
23
19
|
end
|
data/models/times_models.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
|
-
require 'clevic.rb'
|
2
|
-
|
3
1
|
# model definitions
|
4
|
-
class Entry <
|
2
|
+
class Entry < Sequel::Model
|
5
3
|
belongs_to :invoice
|
6
4
|
belongs_to :activity
|
7
5
|
belongs_to :project
|
8
6
|
|
9
7
|
include Clevic::Record
|
8
|
+
|
9
|
+
# spans of time more than 8 ours are coloured violet
|
10
|
+
# because they're often the result of typos.
|
10
11
|
def time_color
|
11
12
|
return if self.end.nil? || start.nil?
|
12
13
|
'darkviolet' if self.end - start > 8.hours
|
13
14
|
end
|
14
15
|
|
16
|
+
# tooltip for spans of time > 8 hours
|
15
17
|
def time_tooltip
|
16
18
|
return if self.end.nil? || start.nil?
|
17
19
|
'Time interval greater than 8 hours' if self.end - start > 8.hours
|
18
20
|
end
|
19
21
|
|
20
22
|
define_ui do
|
21
|
-
plain :date, :sample => '28-
|
23
|
+
plain :date, :sample => '28-WWW-08'
|
22
24
|
|
23
25
|
# The project field
|
24
|
-
relational
|
25
|
-
field.display =
|
26
|
+
relational :project do |field|
|
27
|
+
field.display = :project
|
26
28
|
field.conditions = 'active = true'
|
27
29
|
field.order = 'lower(project)'
|
28
30
|
|
@@ -32,7 +34,7 @@ class Entry < ActiveRecord::Base
|
|
32
34
|
if model_index.entity.invoice.nil?
|
33
35
|
entity_view.invoice_from_project( table_view, model_index ) do
|
34
36
|
# move here next if the invoice was changed
|
35
|
-
table_view.
|
37
|
+
table_view.next_index = model_index.choppy( :column => :start )
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -149,10 +151,11 @@ class Entry < ActiveRecord::Base
|
|
149
151
|
|
150
152
|
end
|
151
153
|
|
152
|
-
class Invoice <
|
153
|
-
include Clevic::Record
|
154
|
+
class Invoice < Sequel::Model
|
154
155
|
has_many :entries
|
155
156
|
|
157
|
+
include Clevic::Record
|
158
|
+
|
156
159
|
define_ui do
|
157
160
|
plain :date
|
158
161
|
distinct :client
|
@@ -167,10 +170,11 @@ class Invoice < ActiveRecord::Base
|
|
167
170
|
end
|
168
171
|
end
|
169
172
|
|
170
|
-
class Project <
|
171
|
-
include Clevic::Record
|
173
|
+
class Project < Sequel::Model
|
172
174
|
has_many :entries
|
173
175
|
|
176
|
+
include Clevic::Record
|
177
|
+
|
174
178
|
define_ui do
|
175
179
|
plain :project
|
176
180
|
plain :description
|
@@ -184,7 +188,7 @@ class Project < ActiveRecord::Base
|
|
184
188
|
# Return the latest invoice for this project
|
185
189
|
# Not part of the UI.
|
186
190
|
def latest_invoice
|
187
|
-
Invoice.find(
|
191
|
+
Invoice.adaptor.find(
|
188
192
|
:first,
|
189
193
|
:conditions => ["client = ? and status = 'not sent'", self.client],
|
190
194
|
:order => 'invoice_number desc'
|
@@ -193,10 +197,11 @@ class Project < ActiveRecord::Base
|
|
193
197
|
|
194
198
|
end
|
195
199
|
|
196
|
-
class Activity <
|
197
|
-
include Clevic::Record
|
200
|
+
class Activity < Sequel::Model
|
198
201
|
has_many :entries
|
199
202
|
|
203
|
+
include Clevic::Record
|
204
|
+
|
200
205
|
# define how fields are displayed
|
201
206
|
define_ui do
|
202
207
|
plain :activity
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$options ||= {}
|
2
|
+
|
3
|
+
require 'clevic.rb'
|
4
|
+
require 'sequel'
|
5
|
+
host = ENV['PGHOST'] || 'localhost'
|
6
|
+
constring = "jdbc:postgresql://#{host}/times_test?user=#{$options[:username] || 'times'}&password=general"
|
7
|
+
puts "constring: #{constring.inspect}"
|
8
|
+
Sequel.connect( constring )
|
9
|
+
|
10
|
+
require 'times_models.rb'
|
data/models/values_models.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
require 'clevic.rb'
|
2
2
|
|
3
3
|
# db connection
|
4
|
-
|
5
|
-
database :accounts_test
|
6
|
-
adapter :postgresql
|
7
|
-
username 'accounts'
|
8
|
-
end
|
4
|
+
Sequel.connect( "postgres://#{host}/accounts_test?user=#{$options[:username] || 'accounts'}&password=#{$options[:password]}" )
|
9
5
|
|
10
6
|
# This is a read-only view, which is currently not implemented
|
11
|
-
class Value <
|
7
|
+
class Value < Sequel::Model
|
12
8
|
set_table_name 'values'
|
13
|
-
#~ has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
|
14
|
-
#~ has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
|
15
9
|
|
16
10
|
include Clevic::Record
|
17
11
|
define_ui do
|
data/tasks/clevic.rake
CHANGED
@@ -12,7 +12,7 @@ def ui_rb_file( ui_file )
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# list of .ui files
|
15
|
-
UI_FILES = FileList.new( 'lib/clevic/ui/*.ui' )
|
15
|
+
UI_FILES = FileList.new( 'lib/clevic/qt/ui/*.ui' )
|
16
16
|
CLEAN.include( 'ChangeLog', 'coverage', 'profiling' )
|
17
17
|
CLOBBER.include( 'ChangeLog', 'pkg', 'lib/clevic/ui/*_ui.rb' )
|
18
18
|
|
data/tasks/rdoc.rake
CHANGED
@@ -8,9 +8,5 @@ Rake::RDocTask.new do |rdoc|
|
|
8
8
|
rdoc.main = 'README.txt'
|
9
9
|
rdoc.rdoc_dir = 'doc'
|
10
10
|
rdoc.rdoc_files.include %w{History.txt lib/**/*.rb README.txt TODO}
|
11
|
-
rdoc.options += [
|
12
|
-
'-SHN',
|
13
|
-
'-A', 'property=Property',
|
14
|
-
"--opname=index.html",
|
15
|
-
]
|
11
|
+
rdoc.options += [ '-SHN' ]
|
16
12
|
end
|
data/tasks/website.rake
CHANGED
@@ -14,7 +14,7 @@ task :website_generate => :ruby_env do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Upload website files to rubyforge'
|
17
|
-
task :
|
17
|
+
task :upload_website do
|
18
18
|
host = "#{rubyforge_username}@rubyforge.org"
|
19
19
|
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
20
20
|
local_dir = 'website'
|
data/test/test_cache_table.rb
CHANGED
@@ -1,28 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
|
-
class PopulateCachePassengers < ActiveRecord::Migration
|
4
|
-
def self.up
|
5
|
-
Passenger.create :name => 'John Anderson', :flight => Flight.find_by_number('EK211'), :row => 36, :seat => 'A', :nationality => 'UAE'
|
6
|
-
Passenger.create :name => 'Genie', :flight => Flight.find_by_number('CA001'), :row => 1, :seat => 'A', :nationality => 'Canada'
|
7
|
-
Passenger.create :name => 'Aladdin', :flight => Flight.find_by_number('CA001'), :row => 2, :seat => 'A', :nationality => 'Canada'
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
Passenger.delete :all
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
3
|
# need to set up a test DB, and test data for this
|
16
4
|
class TestCacheTable < Test::Unit::TestCase
|
17
|
-
def self.startup
|
18
|
-
PopulateCachePassengers.up
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.shutdown
|
22
|
-
PopulateCachePassengers.down
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
5
|
def setup
|
27
6
|
@cache_table = CacheTable.new( Passenger )
|
28
7
|
end
|
@@ -49,8 +28,8 @@ class TestCacheTable < Test::Unit::TestCase
|
|
49
28
|
end
|
50
29
|
|
51
30
|
# test cache retrieval
|
52
|
-
(0...Passenger.count).each do |
|
53
|
-
assert @cache_table[
|
31
|
+
(0...Passenger.count).each do |offset|
|
32
|
+
assert @cache_table[offset] == Passenger.limit(1,offset).first, "#{offset}th cached record is not #{offset}th db record"
|
54
33
|
end
|
55
34
|
end
|
56
35
|
|
@@ -68,15 +47,18 @@ class TestCacheTable < Test::Unit::TestCase
|
|
68
47
|
(0...Passenger.count).each do |i|
|
69
48
|
assert !@cache_table.cached_at?(i), "record #{i} should not be cached yet"
|
70
49
|
end
|
50
|
+
|
51
|
+
# force retrieval
|
71
52
|
@cache_table[0]
|
53
|
+
|
72
54
|
(0...Passenger.count).each do |i|
|
73
55
|
assert @cache_table.cached_at?(i), "#{i}th object should not be nil"
|
74
56
|
end
|
75
57
|
end
|
76
58
|
|
77
59
|
should 'have id as a default order attribute' do
|
78
|
-
oa = OrderAttribute.new( Passenger,
|
79
|
-
assert_equal oa, @cache_table.order_attributes
|
60
|
+
oa = OrderAttribute.new( Passenger, :id )
|
61
|
+
assert_equal oa, @cache_table.order_attributes.first
|
80
62
|
end
|
81
63
|
|
82
64
|
def test_parse_order_attributes
|
@@ -93,23 +75,27 @@ class TestCacheTable < Test::Unit::TestCase
|
|
93
75
|
|
94
76
|
should 'return nil for an empty set' do
|
95
77
|
cache_table = @cache_table.renew( :conditions => "nationality = 'nothing'" )
|
96
|
-
assert_nil cache_table.index_for_entity( Passenger.
|
78
|
+
assert_nil cache_table.index_for_entity( Passenger.first )
|
79
|
+
end
|
80
|
+
|
81
|
+
should "filter with related objects" do
|
82
|
+
@cache_table = @cache_table.renew( :conditions => { :flight => Flight.first} )
|
97
83
|
end
|
98
84
|
|
99
85
|
def test_index_for_entity
|
100
86
|
# test in ascending order
|
101
|
-
first_passenger = Passenger.
|
87
|
+
first_passenger = Passenger.first
|
102
88
|
index = @cache_table.index_for_entity( first_passenger )
|
103
89
|
assert_equal 0, index, 'first passenger should have an index of 0'
|
104
90
|
|
105
91
|
# test in descending order
|
106
92
|
@cache_table = @cache_table.renew( :order => 'id desc' )
|
107
|
-
last_passenger = Passenger.
|
93
|
+
last_passenger = Passenger.order( :id.desc ).first
|
108
94
|
assert_equal 0, @cache_table.index_for_entity( last_passenger ), "last passenger in reverse order should have an index of 0"
|
109
95
|
|
110
96
|
# test with two order fields
|
111
97
|
@cache_table = @cache_table.renew( :order => 'nationality, row' )
|
112
|
-
passenger = Passenger.
|
98
|
+
passenger = Passenger.order( :nationality, :row ).first
|
113
99
|
assert_equal 0, @cache_table.index_for_entity( passenger ), "passenger in (nationality, row) order should have an index of 0"
|
114
100
|
end
|
115
101
|
end
|
data/test/test_helper.rb
CHANGED
@@ -2,103 +2,34 @@ require 'test/unit'
|
|
2
2
|
require 'shoulda'
|
3
3
|
|
4
4
|
require File.dirname(__FILE__) + '/../lib/clevic'
|
5
|
-
|
6
|
-
require 'activerecord'
|
7
|
-
require 'sqlite3'
|
8
|
-
require 'faker'
|
9
|
-
require 'generator'
|
10
|
-
|
11
|
-
|
12
|
-
class Flight < ActiveRecord::Base
|
13
|
-
has_many :passengers
|
14
|
-
end
|
15
|
-
|
16
|
-
class Passenger < ActiveRecord::Base
|
17
|
-
belongs_to :flight
|
18
|
-
end
|
19
|
-
|
20
|
-
class CreateFlights < ActiveRecord::Migration
|
21
|
-
def self.up
|
22
|
-
create_table :flights do |t|
|
23
|
-
t.string :number
|
24
|
-
t.string :airline
|
25
|
-
t.string :destination
|
26
|
-
end
|
27
|
-
Flight.reset_column_information
|
28
|
-
Flight.create :number => 'EK211'
|
29
|
-
Flight.create :number => 'EK088'
|
30
|
-
Flight.create :number => 'EK761'
|
31
|
-
Flight.create :number => 'BA264'
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.down
|
35
|
-
Flight.delete_all
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class CreatePassengers < ActiveRecord::Migration
|
40
|
-
def self.up
|
41
|
-
create_table :passengers do |t|
|
42
|
-
t.string :name
|
43
|
-
t.string :nationality
|
44
|
-
t.integer :flight_id
|
45
|
-
t.integer :row
|
46
|
-
t.string :seat
|
47
|
-
end
|
48
|
-
Passenger.reset_column_information
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.down
|
52
|
-
Passenger.delete_all
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Convenience class to create a test DB
|
57
|
-
class OneBase
|
58
|
-
attr_reader :db_name, :adapter
|
59
|
-
|
60
|
-
def initialize
|
61
|
-
@db_name = 'test_cache_table.sqlite3'
|
62
|
-
|
63
|
-
if File.exists? @db_name
|
64
|
-
p 'remove old db'
|
65
|
-
File.unlink @db_name
|
66
|
-
end
|
67
|
-
|
68
|
-
@adapter = :sqlite3
|
69
|
-
@db = SQLite3::Database.new( @db_name )
|
70
|
-
@db_options = Clevic::DbOptions.connect do |dbo|
|
71
|
-
dbo.database @db_name
|
72
|
-
dbo.adapter @adapter
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def feenesh
|
77
|
-
File.unlink @db_name
|
78
|
-
end
|
79
|
-
end
|
5
|
+
require File.dirname(__FILE__) + '/fixtures.rb'
|
80
6
|
|
81
7
|
# Allow running of startup and shutdown things before
|
82
8
|
# an entire suite, instead of just one per test
|
83
9
|
class SuiteWrapper < Test::Unit::TestSuite
|
84
|
-
attr_accessor :tests
|
10
|
+
attr_accessor :tests, :db
|
85
11
|
|
86
12
|
def initialize( name, test_case )
|
87
13
|
super( name )
|
88
14
|
@test_case = test_case
|
15
|
+
|
16
|
+
# define in fixtures.rb
|
17
|
+
@db = $db
|
89
18
|
end
|
90
19
|
|
91
20
|
def startup
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
21
|
+
CreateFlights.new( db ).up
|
22
|
+
CreatePassengers.new( db ).up
|
23
|
+
PopulateCachePassengers.new( db ).up
|
24
|
+
|
25
|
+
Flight.columns
|
26
|
+
Passenger.columns
|
96
27
|
end
|
97
28
|
|
98
29
|
def shutdown
|
99
|
-
|
100
|
-
|
101
|
-
|
30
|
+
PopulateCachePassengers.new( db ).down
|
31
|
+
CreatePassengers.new( db ).down
|
32
|
+
CreateFlights.new( db ).down
|
102
33
|
end
|
103
34
|
|
104
35
|
def run( *args )
|
data/test/test_table_model.rb
CHANGED
@@ -1,29 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
require 'clevic/table_model.rb'
|
3
3
|
|
4
|
-
class PopulateCachePassengers < ActiveRecord::Migration
|
5
|
-
def self.up
|
6
|
-
Passenger.create :name => 'John Anderson', :flight => Flight.find_by_number('EK211'), :row => 36, :seat => 'A', :nationality => 'UAE'
|
7
|
-
Passenger.create :name => 'Genie', :flight => Flight.find_by_number('CA001'), :row => 1, :seat => 'A', :nationality => 'Canada'
|
8
|
-
Passenger.create :name => 'Aladdin', :flight => Flight.find_by_number('CA001'), :row => 2, :seat => 'A', :nationality => 'Canada'
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.down
|
12
|
-
Passenger.delete :all
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
4
|
# need to set up a test DB, and test data for this
|
17
5
|
class TestTableModel < Test::Unit::TestCase
|
18
|
-
def self.startup
|
19
|
-
PopulateCachePassengers.up
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.shutdown
|
23
|
-
PopulateCachePassengers.down
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
6
|
def setup
|
28
7
|
@table_model = Clevic::TableModel.new( )
|
29
8
|
end
|