lolita 3.2.0.rc.17 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +22 -17
- data/Rakefile +3 -0
- data/app/assets/javascripts/lolita/list.js +2 -2
- data/app/assets/javascripts/lolita/main.js +2 -2
- data/app/assets/javascripts/lolita/tab.js +7 -7
- data/app/assets/stylesheets/lolita/PIE-custom.htc +87 -87
- data/app/assets/stylesheets/lolita/PIE.htc +81 -81
- data/app/assets/stylesheets/lolita/application.css +6 -6
- data/app/assets/stylesheets/lolita/default.css.erb +169 -169
- data/app/assets/stylesheets/lolita/jquery-ui-1.8.16.lolita.css.erb +567 -567
- data/app/assets/stylesheets/lolita/style.css.erb +4 -1
- data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
- data/app/views/components/lolita/configuration/column/_first.html.haml +1 -1
- data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -1
- data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -6
- data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -5
- data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +7 -7
- data/app/views/components/lolita/configuration/filter/_display.html.haml +2 -2
- data/app/views/components/lolita/configuration/search/_display.html.haml +2 -2
- data/app/views/kaminari/lolita/_first_page.html.erb +11 -11
- data/app/views/kaminari/lolita/_gap.html.erb +8 -8
- data/app/views/kaminari/lolita/_last_page.html.erb +11 -11
- data/app/views/kaminari/lolita/_next_page.html.erb +11 -11
- data/app/views/kaminari/lolita/_page.html.erb +12 -12
- data/app/views/kaminari/lolita/_paginator.html.erb +23 -23
- data/app/views/kaminari/lolita/_prev_page.html.erb +11 -11
- data/app/views/lolita/info/index.html.erb +232 -232
- data/app/views/lolita/rest/index.html.haml +1 -1
- data/config/routes.rb +6 -6
- data/lib/generators/lolita/install_generator.rb +2 -4
- data/lib/generators/lolita/uninstall_generator.rb +3 -8
- data/lib/generators/templates/lolita.rb +13 -16
- data/lib/lolita.rb +4 -5
- data/lib/lolita/adapter/active_record.rb +4 -4
- data/lib/lolita/adapter/common_helper.rb +45 -71
- data/lib/lolita/adapter/field_helper.rb +18 -18
- data/lib/lolita/adapter/mongoid.rb +8 -8
- data/lib/lolita/configuration/field/big_decimal.rb +12 -12
- data/lib/lolita/configuration/field/boolean.rb +12 -12
- data/lib/lolita/configuration/field/date.rb +12 -12
- data/lib/lolita/configuration/field/hidden.rb +12 -12
- data/lib/lolita/configuration/field/integer.rb +11 -11
- data/lib/lolita/configuration/field/string.rb +16 -16
- data/lib/lolita/configuration/field/time.rb +13 -13
- data/lib/lolita/configuration/field_set.rb +25 -25
- data/lib/lolita/configuration/filter.rb +6 -0
- data/lib/lolita/configuration/list.rb +10 -10
- data/lib/lolita/configuration/nested_form.rb +104 -104
- data/lib/lolita/configuration/search.rb +104 -104
- data/lib/lolita/configuration/tab/content.rb +3 -3
- data/lib/lolita/controllers/component_helpers.rb +9 -9
- data/lib/lolita/controllers/rails_helpers.rb +5 -5
- data/lib/lolita/dbi/base.rb +56 -56
- data/lib/lolita/hooks.rb +16 -16
- data/lib/lolita/hooks/named_hook.rb +125 -125
- data/lib/lolita/lazy_loader.rb +54 -54
- data/lib/lolita/navigation/tree.rb +132 -132
- data/lib/lolita/rails/engine.rb +2 -2
- data/lib/lolita/rails/routes.rb +9 -9
- data/lib/lolita/ruby_ext/accessors.rb +26 -26
- data/lib/lolita/ruby_ext/lolita_model_name.rb +10 -2
- data/lib/lolita/search/simple.rb +75 -75
- data/lib/lolita/support/formatter.rb +62 -62
- data/lib/lolita/support/formatter/rails.rb +56 -56
- data/lib/lolita/test/matchers.rb +77 -77
- data/lib/lolita/version.rb +2 -2
- data/spec/adapter/common_helper_spec.rb +96 -0
- data/spec/adapter_helper.rb +3 -4
- data/spec/builder_spec.rb +120 -120
- data/spec/configuration/base_spec.rb +1 -1
- data/spec/configuration/column_spec.rb +1 -1
- data/spec/configuration/columns_spec.rb +1 -1
- data/spec/configuration/core_spec.rb +1 -1
- data/spec/configuration/field_set_spec.rb +1 -1
- data/spec/configuration/field_spec.rb +1 -1
- data/spec/configuration/filter_spec.rb +30 -1
- data/spec/configuration/list_spec.rb +44 -145
- data/spec/configuration/nested_list_spec.rb +1 -1
- data/spec/configuration/search_spec.rb +1 -1
- data/spec/configuration/tab_spec.rb +1 -1
- data/spec/configuration/tabs_spec.rb +1 -2
- data/spec/controllers/component_helpers_spec.rb +1 -1
- data/spec/controllers/configuration_spec.rb +1 -1
- data/spec/controllers/internal_helpers_spec.rb +1 -1
- data/spec/controllers/lolita_rest_nested_resources_spec.rb +1 -1
- data/spec/controllers/lolita_rest_spec.rb +2 -2
- data/spec/dbi/base_spec.rb +1 -4
- data/spec/extensions/authorization/cancan_adapter_spec.rb +4 -4
- data/spec/extensions/extensions_spec.rb +1 -1
- data/spec/generators/lolita/install_generator_spec.rb +55 -0
- data/spec/generators/lolita/uninstall_generator_spec.rb +49 -0
- data/spec/hooks_spec.rb +25 -25
- data/spec/mapping_spec.rb +1 -1
- data/spec/navigation/branch_spec.rb +1 -1
- data/spec/navigation/tree_spec.rb +1 -1
- data/spec/rails_app/app/controllers/application_controller.rb +3 -3
- data/spec/rails_app/app/helpers/application_helper.rb +3 -3
- data/spec/rails_app/app/mongoid/address.rb +7 -7
- data/spec/rails_app/app/mongoid/comment.rb +5 -5
- data/spec/rails_app/app/mongoid/preference.rb +5 -5
- data/spec/rails_app/app/mongoid/profile.rb +13 -13
- data/spec/rails_app/app/mongoid/tag.rb +3 -3
- data/spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb +1 -1
- data/spec/rails_app/config/boot.rb +4 -9
- data/spec/rails_app/config/environment.rb +5 -5
- data/spec/rails_app/config/environments/production.rb +37 -37
- data/spec/rails_app/config/environments/test.rb +37 -37
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/rails_app/config/initializers/inflections.rb +2 -2
- data/spec/rails_app/config/initializers/secret_token.rb +1 -1
- data/spec/rails_app/config/routes.rb +1 -1
- data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +13 -13
- data/spec/rails_app/log/development.log +12940 -43222
- data/spec/rails_app/public/javascripts/jquery-1.5.1.min.js +15 -15
- data/spec/rails_app/public/javascripts/lolita/main.js +6 -6
- data/spec/rails_app/public/javascripts/modernizr-1.7.min.js +1 -1
- data/spec/rails_app/public/javascripts/rails.js +137 -137
- data/spec/rails_app/public/javascripts/tinymce/langs/en.js +221 -221
- data/spec/rails_app/public/javascripts/tinymce/license.txt +504 -504
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/about.htm +52 -52
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -26
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/charmap.htm +51 -51
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/color_picker.htm +74 -74
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1328 -1328
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/image.htm +80 -80
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/about.js +73 -73
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/anchor.js +42 -42
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/charmap.js +354 -354
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/color_picker.js +329 -329
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/image.js +247 -247
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/link.js +153 -153
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -56
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en.js +68 -68
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +53 -53
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/link.htm +57 -57
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -47
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -25
- data/spec/rails_app/public/javascripts/tinymce/tiny_mce_popup.js +4 -4
- data/spec/rails_app/public/stylesheets/lolita/default.css +169 -169
- data/spec/rails_app/public/stylesheets/lolita/style.css +214 -214
- data/spec/routing/routes_spec.rb +1 -1
- data/spec/search/simple_spec.rb +1 -1
- data/spec/simple_spec_helper.rb +1 -1
- data/spec/spec_helper.rb +6 -4
- data/spec/support/formatter_spec.rb +1 -1
- data/spec/tmp/config/routes.rb +0 -0
- data/vendor/assets/javascripts/jquery-numeric.js +279 -279
- data/vendor/assets/javascripts/modernizr_1_7_min.js +1 -1
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
- data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +567 -567
- metadata +380 -395
- data/spec/rails_app/coverage.data +0 -1
- data/spec/rails_app/log/test.log +0 -370
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Lolita::Configuration::Filter do
|
4
4
|
|
@@ -135,4 +135,33 @@ describe Lolita::Configuration::Filter do
|
|
135
135
|
list_conf.paginate(1,request).should have(2).items
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
describe "#resource" do
|
140
|
+
let(:filter){ Lolita::Configuration::Filter.new(dbi, :name ) }
|
141
|
+
let(:params){ {} }
|
142
|
+
subject do
|
143
|
+
tags = %w(Android Linux Windows).map{|name| Fabricate(:tag, :name => name )}
|
144
|
+
filter.resource(params)
|
145
|
+
end
|
146
|
+
|
147
|
+
context "reflections" do
|
148
|
+
let(:params){ {:post => {"tag_ids"=>["", Tag.where(:name => 'Android').first.id]}} }
|
149
|
+
let(:filter){ Lolita::Configuration::Filter.new(dbi, :tag ) }
|
150
|
+
it "recognizes" do
|
151
|
+
subject.tags.should have(1).item
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "simple attributes" do
|
156
|
+
let(:params){ {:post => {"title" => "MyName" }} }
|
157
|
+
let(:filter){ Lolita::Configuration::Filter.new(dbi, :title ) }
|
158
|
+
it "recognizes" do
|
159
|
+
subject.title.should eq("MyName")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should be persisted" do
|
164
|
+
subject.should be_persisted
|
165
|
+
end
|
166
|
+
end
|
138
167
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'simple_spec_helper'
|
2
2
|
|
3
3
|
class SearchEngine
|
4
4
|
def run(*args)
|
@@ -17,53 +17,53 @@ describe Lolita::Configuration::List do
|
|
17
17
|
}.not_to raise_error
|
18
18
|
end
|
19
19
|
|
20
|
-
it "should raise error when no dbp is given" do
|
20
|
+
it "should raise error when no dbp is given" do
|
21
21
|
expect{
|
22
22
|
klass.new nil
|
23
23
|
}.to raise_error(Lolita::UnknownDBPError)
|
24
24
|
end
|
25
25
|
|
26
|
-
describe "lolita accessors" do
|
27
|
-
it "should have lolita acessor for pagination_method" do
|
26
|
+
describe "lolita accessors" do
|
27
|
+
it "should have lolita acessor for pagination_method" do
|
28
28
|
list.should respond_to(:pagination_method)
|
29
29
|
list.should respond_to(:pagination_method=)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "should have per_page acessor" do
|
32
|
+
it "should have per_page acessor" do
|
33
33
|
list.should respond_to(:per_page)
|
34
34
|
list.should respond_to(:per_page=)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "should have actions accessor" do
|
37
|
+
it "should have actions accessor" do
|
38
38
|
list.should respond_to(:actions)
|
39
39
|
list.should respond_to(:actions=)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
it "should accept block and eval it" do
|
43
|
+
it "should accept block and eval it" do
|
44
44
|
block = Proc.new{}
|
45
45
|
klass.any_instance.should_receive(:instance_eval).with(&block)
|
46
46
|
klass.new(dbp,&block)
|
47
47
|
end
|
48
48
|
|
49
|
-
it "should accept options and assign them as attributes" do
|
49
|
+
it "should accept options and assign them as attributes" do
|
50
50
|
klass.any_instance.should_receive(:test_title=).with("test_title")
|
51
51
|
klass.new(dbp,:test_title => "test_title")
|
52
52
|
end
|
53
53
|
|
54
|
-
it "should set default attributes values" do
|
54
|
+
it "should set default attributes values" do
|
55
55
|
list.actions.should_not be_empty
|
56
56
|
list.per_page.should eq(10)
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should populate actions with two default ones" do
|
59
|
+
it "should populate actions with two default ones" do
|
60
60
|
list.actions.should have(2).items
|
61
61
|
end
|
62
62
|
|
63
|
-
it "should initialize attribute and eval block after default attributes is initialized" do
|
63
|
+
it "should initialize attribute and eval block after default attributes is initialized" do
|
64
64
|
actions_before = nil
|
65
65
|
per_page_before = nil
|
66
|
-
klass.new(dbp) do
|
66
|
+
klass.new(dbp) do
|
67
67
|
actions_before = actions.dup
|
68
68
|
per_page_before = per_page
|
69
69
|
end
|
@@ -71,7 +71,7 @@ describe Lolita::Configuration::List do
|
|
71
71
|
actions_before.should be_empty
|
72
72
|
end
|
73
73
|
|
74
|
-
it "should allow to add action with name, options and block" do
|
74
|
+
it "should allow to add action with name, options and block" do
|
75
75
|
action = stub(:name => :name)
|
76
76
|
Lolita::Configuration::Action.stub(:new).and_return(action)
|
77
77
|
block = Proc.new{}
|
@@ -81,24 +81,24 @@ describe Lolita::Configuration::List do
|
|
81
81
|
|
82
82
|
describe "#list" do
|
83
83
|
let(:nested_dbp){double("nested_dbp")}
|
84
|
-
before(:each) do
|
84
|
+
before(:each) do
|
85
85
|
dbp_klass.stub(:create).and_return(nested_dbp)
|
86
86
|
end
|
87
87
|
|
88
|
-
it "should return @list when no args and/or block received" do
|
88
|
+
it "should return @list when no args and/or block received" do
|
89
89
|
dummy_list = stub
|
90
90
|
list.instance_variable_set(:@list, dummy_list)
|
91
91
|
list.list.should eq(dummy_list)
|
92
92
|
end
|
93
93
|
|
94
|
-
it "should check for association and raise error when none is found" do
|
94
|
+
it "should check for association and raise error when none is found" do
|
95
95
|
dbp.stub(:associations).and_return({})
|
96
96
|
expect{
|
97
97
|
list.list :dummy_name
|
98
98
|
}.to raise_error(Lolita::UnknownDBPError)
|
99
99
|
end
|
100
100
|
|
101
|
-
it "should create new dbp object for found assocition class" do
|
101
|
+
it "should create new dbp object for found assocition class" do
|
102
102
|
dummy_association = double("dummy_association")
|
103
103
|
dummy_association.stub(:klass).and_return(Object)
|
104
104
|
dummy_association.stub(:name).and_return("name")
|
@@ -112,41 +112,41 @@ describe Lolita::Configuration::List do
|
|
112
112
|
|
113
113
|
end
|
114
114
|
|
115
|
-
describe "#search" do
|
115
|
+
describe "#search" do
|
116
116
|
let(:dummy_search){double("search")}
|
117
|
-
before(:each) do
|
117
|
+
before(:each) do
|
118
118
|
dummy_search.stub(:update).and_return(true)
|
119
119
|
end
|
120
120
|
|
121
|
-
it "should add search when args and/or block is given" do
|
121
|
+
it "should add search when args and/or block is given" do
|
122
122
|
block = Proc.new{}
|
123
123
|
Lolita::Configuration::Search.should_receive(:new).with(dbp,:some_thing, &block).and_return(dummy_search)
|
124
124
|
list.search :some_thing, &block
|
125
125
|
end
|
126
126
|
|
127
|
-
it "should return @search when nothing is received" do
|
127
|
+
it "should return @search when nothing is received" do
|
128
128
|
Lolita::Configuration::Search.stub(:new).and_return(dummy_search)
|
129
129
|
list.search :some_args
|
130
130
|
list.search.should eq(dummy_search)
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
describe "#paginate" do
|
135
|
-
it "should call dbp#paginate with arguments and #pagination_method" do
|
134
|
+
describe "#paginate" do
|
135
|
+
it "should call dbp#paginate with arguments and #pagination_method" do
|
136
136
|
request = double("request")
|
137
137
|
list.pagination_method = :my_dummy_method
|
138
138
|
dbp.should_receive(:paginate).with(1,list.per_page, :request => request, :pagination_method => :my_dummy_method).and_return([])
|
139
139
|
list.paginate(1, request)
|
140
140
|
end
|
141
141
|
|
142
|
-
it "should return pagination results" do
|
142
|
+
it "should return pagination results" do
|
143
143
|
page = double("page")
|
144
144
|
dbp.should_receive(:paginate).and_return(page)
|
145
145
|
list.paginate(1)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should notify observers with method name, self and request" do
|
149
|
-
request = double("request")
|
149
|
+
request = double("request")
|
150
150
|
dbp.stub(:paginate).and_return(nil)
|
151
151
|
list.should_receive(:changed)
|
152
152
|
list.should_receive(:notify_observers).with(:paginate,list,request)
|
@@ -154,14 +154,14 @@ describe Lolita::Configuration::List do
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
describe "#columns=" do
|
158
|
-
it "should raise error when something else then Enumerable or Lolita::Configuration::Columns is givne" do
|
157
|
+
describe "#columns=" do
|
158
|
+
it "should raise error when something else then Enumerable or Lolita::Configuration::Columns is givne" do
|
159
159
|
expect{
|
160
160
|
list.columns = Object.new
|
161
161
|
}.to raise_error(ArgumentError,"Accepts only Enumerable or Lolita::Configuration::Columns.")
|
162
162
|
end
|
163
163
|
|
164
|
-
it "should assign received values to @columns directly when they are kind of Lolita::Configuration::Columns" do
|
164
|
+
it "should assign received values to @columns directly when they are kind of Lolita::Configuration::Columns" do
|
165
165
|
columns = double("columns")
|
166
166
|
columns.should_receive(:parent=).with(list)
|
167
167
|
columns.stub(:is_a?).with(Lolita::Configuration::Columns).and_return(true)
|
@@ -169,14 +169,14 @@ describe Lolita::Configuration::List do
|
|
169
169
|
list.columns.should eq(columns)
|
170
170
|
end
|
171
171
|
|
172
|
-
it "should iterate through all possible columns and create column with each value" do
|
172
|
+
it "should iterate through all possible columns and create column with each value" do
|
173
173
|
list.should_receive(:column).exactly(3).times.and_return(stub())
|
174
174
|
list.columns= [1,2,3]
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
describe "#columns" do
|
179
|
-
it "should create columns with and/or args, block" do
|
178
|
+
describe "#columns" do
|
179
|
+
it "should create columns with and/or args, block" do
|
180
180
|
block = Proc.new{}
|
181
181
|
columns = double("columns")
|
182
182
|
columns.should_receive(:parent=).with(list)
|
@@ -185,14 +185,14 @@ describe Lolita::Configuration::List do
|
|
185
185
|
list.columns(1,2,3,&block)
|
186
186
|
end
|
187
187
|
|
188
|
-
it "should return columns when no arguments are given" do
|
188
|
+
it "should return columns when no arguments are given" do
|
189
189
|
columns = double("columns")
|
190
190
|
list.instance_variable_set(:@columns,columns)
|
191
191
|
list.columns.should eq(columns)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
it "should create column with args and block" do
|
195
|
+
it "should create column with args and block" do
|
196
196
|
block = Proc.new{}
|
197
197
|
columns = stub("columns")
|
198
198
|
list.stub(:columns).and_return(columns)
|
@@ -200,7 +200,7 @@ describe Lolita::Configuration::List do
|
|
200
200
|
list.column(1,2,3,&block)
|
201
201
|
end
|
202
202
|
|
203
|
-
it "should determine if there is filter defined for list by checking class" do
|
203
|
+
it "should determine if there is filter defined for list by checking class" do
|
204
204
|
list.filter?.should_not be_true
|
205
205
|
filter = double("filter")
|
206
206
|
filter.stub(:is_a?).with(Lolita::Configuration::Filter).and_return(true)
|
@@ -208,41 +208,41 @@ describe Lolita::Configuration::List do
|
|
208
208
|
list.filter?.should be_true
|
209
209
|
end
|
210
210
|
|
211
|
-
describe "#filter" do
|
211
|
+
describe "#filter" do
|
212
212
|
let(:filter){double("filter")}
|
213
|
-
it "should create filter with arguments and/or block" do
|
213
|
+
it "should create filter with arguments and/or block" do
|
214
214
|
block = Proc.new{}
|
215
215
|
list.stub(:add_observer).and_return(true)
|
216
216
|
Lolita::Configuration::Filter.should_receive(:new).with(dbp,1,2,3,&block)
|
217
217
|
list.filter(1,2,3,&block)
|
218
218
|
end
|
219
219
|
|
220
|
-
it "should return @filter when no arguments is given" do
|
220
|
+
it "should return @filter when no arguments is given" do
|
221
221
|
list.stub(:add_observer).and_return(true)
|
222
222
|
Lolita::Configuration::Filter.should_receive(:new).and_return(filter)
|
223
223
|
list.filter(1,2,3)
|
224
224
|
list.filter.should eq(filter)
|
225
225
|
end
|
226
226
|
|
227
|
-
it "should add observer to filter" do
|
227
|
+
it "should add observer to filter" do
|
228
228
|
Lolita::Configuration::Filter.stub(:new).and_return(filter)
|
229
229
|
list.should_receive(:add_observer).with(filter)
|
230
230
|
list.filter 1,2
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
-
describe "#by_path" do
|
235
|
-
it "should return self when path is empty" do
|
234
|
+
describe "#by_path" do
|
235
|
+
it "should return self when path is empty" do
|
236
236
|
list.by_path([]).should eq(list)
|
237
237
|
end
|
238
238
|
|
239
|
-
it "should return object list when path starts with l" do
|
239
|
+
it "should return object list when path starts with l" do
|
240
240
|
nested_list = double("nested_list")
|
241
241
|
list.stub(:list).and_return(nested_list)
|
242
242
|
list.by_path(["l_some_list"]).should eq(nested_list)
|
243
243
|
end
|
244
244
|
|
245
|
-
it "should return column with [column_name] list when c_column_name in path" do
|
245
|
+
it "should return column with [column_name] list when c_column_name in path" do
|
246
246
|
columns = double("columns")
|
247
247
|
column = double("column_with_name")
|
248
248
|
nested_list = double("nested_list")
|
@@ -252,7 +252,7 @@ describe Lolita::Configuration::List do
|
|
252
252
|
list.by_path(["c_column_name"]).should eq(nested_list)
|
253
253
|
end
|
254
254
|
|
255
|
-
it "should go through all path array until last object found" do
|
255
|
+
it "should go through all path array until last object found" do
|
256
256
|
path = ["l_some_list","c_column_name","l_other_list"]
|
257
257
|
nested_list_1 = double("nested_list_1")
|
258
258
|
nested_list_2 = double("nested_list_2")
|
@@ -270,105 +270,4 @@ describe Lolita::Configuration::List do
|
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
# before(:each) do
|
279
|
-
# @dbi=Lolita::DBI::Base.create(Post)
|
280
|
-
# end
|
281
|
-
|
282
|
-
# after(:each) do
|
283
|
-
# @recs||=[]
|
284
|
-
# @recs.each{|r| r.destroy}
|
285
|
-
# end
|
286
|
-
|
287
|
-
# let(:list_class){Lolita::Configuration::List}
|
288
|
-
|
289
|
-
# it "should create new list with block" do
|
290
|
-
# Lolita::Configuration::List.new(@dbi) do
|
291
|
-
|
292
|
-
# end
|
293
|
-
# end
|
294
|
-
|
295
|
-
# it "should create new list without block" do
|
296
|
-
# Lolita::Configuration::List.new(@dbi)
|
297
|
-
# end
|
298
|
-
|
299
|
-
# it "should generate columns if none is given" do
|
300
|
-
# list=Lolita::Configuration::List.new(@dbi)
|
301
|
-
# list.columns.should have(@dbi.fields.reject{|f| f.technical?}.size).items
|
302
|
-
# list=Lolita::Configuration::List.new(@dbi){}
|
303
|
-
# list.columns.should have(@dbi.fields.reject{|f| f.technical?}.size).items
|
304
|
-
# end
|
305
|
-
|
306
|
-
# it "should not generate columns if one or more is given" do
|
307
|
-
# list=list_class.new(@dbi,:columns=>[{:name=>"C1"}])
|
308
|
-
# list.columns.should have(1).item
|
309
|
-
# list=list_class.new(@dbi) do
|
310
|
-
# column :name=>"Col1"
|
311
|
-
# column :name=>"col3"
|
312
|
-
# column do
|
313
|
-
# name "col2"
|
314
|
-
# title "Column two"
|
315
|
-
# end
|
316
|
-
# end
|
317
|
-
# list.columns.should have(3).items
|
318
|
-
# end
|
319
|
-
|
320
|
-
# it "should get records for list page" do
|
321
|
-
# 1.upto(5) { Fabricate(:post)}
|
322
|
-
# list=list_class.new(@dbi,:per_page => 1)
|
323
|
-
# list.paginate(1,Object.new).to_a.size.should == 1
|
324
|
-
# end
|
325
|
-
|
326
|
-
# it "should define columns when Symbols are given as args" do
|
327
|
-
# list = list_class.new(@dbi) do
|
328
|
-
# columns :col1,:col2,:col3
|
329
|
-
# end
|
330
|
-
# list.columns.should have(3).items
|
331
|
-
# end
|
332
|
-
|
333
|
-
# describe "search" do
|
334
|
-
# let(:list){ list_class.new(@dbi,:per_page => 10) }
|
335
|
-
|
336
|
-
# it "should define default search by passing true" do
|
337
|
-
# list.search true
|
338
|
-
# list.search.class.to_s.should match(/Lolita::Configuration::Search/)
|
339
|
-
# end
|
340
|
-
|
341
|
-
# it "should define search with block" do
|
342
|
-
# list.search do
|
343
|
-
# with SearchEngine.new
|
344
|
-
# end
|
345
|
-
# list.search.class.to_s.should match(/Lolita::Configuration::Search/)
|
346
|
-
# end
|
347
|
-
# end
|
348
|
-
|
349
|
-
# describe "sublist" do
|
350
|
-
|
351
|
-
# it "should allow to define sublist with association name" do
|
352
|
-
# list_class.new(@dbi) do
|
353
|
-
# list(:comments){}
|
354
|
-
# end
|
355
|
-
# end
|
356
|
-
|
357
|
-
# it "should raise error when no DBI is given or found through association" do
|
358
|
-
# expect{
|
359
|
-
# list_class.new(@dbi) do
|
360
|
-
# list{}
|
361
|
-
# end
|
362
|
-
# }.to raise_error(Lolita::UnknownDBPError)
|
363
|
-
|
364
|
-
# expect{
|
365
|
-
# list_class.new(@dbi) do
|
366
|
-
# list(:title)
|
367
|
-
# end
|
368
|
-
# }.to raise_error(Lolita::UnknownDBPError)
|
369
|
-
# end
|
370
|
-
|
371
|
-
#end
|
372
|
-
|
373
|
-
end
|
374
|
-
|
273
|
+
end
|