lolita 3.2.0.rc.7 → 3.2.0.rc.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +31 -0
- data/Gemfile +15 -36
- data/History.rdoc +9 -3
- data/README.md +57 -30
- data/Rakefile +1 -44
- data/app/assets/javascripts/lolita/list.js +28 -0
- data/app/assets/javascripts/lolita/main.js +81 -12
- data/app/assets/javascripts/lolita/tab.js +37 -32
- data/app/assets/stylesheets/lolita/style.css.erb +58 -18
- data/app/controllers/lolita/field_data_controller.rb +13 -9
- data/app/controllers/lolita/info_controller.rb +3 -5
- data/app/controllers/lolita/rest_controller.rb +53 -24
- data/app/helpers/components/lolita/configuration_component.rb +1 -1
- data/app/views/components/lolita/configuration/action/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/column/_display.html.haml +4 -0
- data/app/views/components/lolita/configuration/column/_first.html.haml +2 -0
- data/app/views/components/lolita/configuration/column/_last.html.haml +5 -0
- data/app/views/components/lolita/configuration/column/header/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -0
- data/app/views/components/lolita/configuration/column/header/_last.html.haml +1 -0
- data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -0
- data/app/views/components/lolita/configuration/columns/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/columns/body/_display.html.haml +3 -0
- data/app/views/components/lolita/configuration/columns/body/row/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/field/_display.html.haml +7 -0
- data/app/views/components/lolita/configuration/field/_label.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/_object.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/array/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/field/array/autocomplete/_display.html.haml +1 -1
- data/app/views/components/lolita/configuration/field/array/autocomplete/_input.html.haml +2 -2
- data/app/views/components/lolita/configuration/field/array/polymorphic/_display.html.haml +3 -3
- data/app/views/components/lolita/configuration/field/array/select/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/big_decimal/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/boolean/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/date/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/date_time/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/field/date_time/date/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/date_time/time/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/float/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/integer/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/disabled/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/field/string/hidden/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/password/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/text/_display.html.haml +7 -0
- data/app/views/components/lolita/configuration/field/time/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field_set/_display.html.haml +3 -0
- data/app/views/components/lolita/configuration/filter/_display.html.haml +9 -0
- data/app/views/components/lolita/configuration/list/_display.html.haml +9 -0
- data/app/views/components/lolita/configuration/list/_new_resource.html.haml +4 -0
- data/app/views/components/lolita/configuration/list/_paginator.html.haml +1 -0
- data/app/views/components/lolita/configuration/list/_title.html.haml +6 -0
- data/app/views/components/lolita/configuration/nested_form/_display.html.haml +12 -0
- data/app/views/components/lolita/configuration/nested_form/_fields.html.haml +8 -0
- data/app/views/components/lolita/configuration/nested_list/_display.html.haml +7 -0
- data/app/views/components/lolita/configuration/nested_list/_paginator.html.haml +2 -0
- data/app/views/components/lolita/configuration/tab/_display.html.haml +4 -0
- data/app/views/components/lolita/configuration/tab/_error_msg.html.haml +14 -0
- data/app/views/components/lolita/configuration/tab/_fields.html.haml +6 -0
- data/app/views/components/lolita/configuration/tab/_form.html.haml +4 -0
- data/app/views/components/lolita/configuration/tab/_title.html.haml +3 -0
- data/app/views/components/lolita/configuration/tab/content/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/tab/default/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/tabs/_display.html.haml +10 -0
- data/app/views/components/lolita/configuration/tabs/_form.html.haml +7 -0
- data/app/views/components/lolita/navigation/_display.html.haml +2 -0
- data/app/views/components/lolita/navigation/_tree.html.haml +14 -0
- data/app/views/components/lolita/shared/_buttons.html.haml +6 -0
- data/app/views/components/lolita/shared/_flash.html.haml +3 -0
- data/app/views/components/lolita/shared/_header.html.haml +7 -0
- data/app/views/components/lolita/shared/_languages.html.haml +11 -0
- data/app/views/components/lolita/shared/_right_sidebar.html.haml +6 -0
- data/app/views/components/lolita/shared/_save_button.html.haml +1 -0
- data/app/views/layouts/lolita/application.html.haml +36 -0
- data/app/views/lolita/rest/form.html.haml +1 -0
- data/app/views/lolita/rest/index.html.haml +1 -0
- data/app/views/lolita/rest/index.js.erb +1 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/lv.yml +5 -2
- data/lib/generators/lolita/uninstall_generator.rb +76 -0
- data/lib/lolita.rb +104 -170
- data/lib/lolita/adapter/abstract_adapter.rb +1 -0
- data/lib/lolita/adapter/active_record.rb +22 -55
- data/lib/lolita/adapter/common_helper.rb +252 -0
- data/lib/lolita/adapter/mongoid.rb +11 -55
- data/lib/lolita/base.rb +5 -0
- data/lib/lolita/builder.rb +3 -3
- data/lib/lolita/components/base.rb +12 -0
- data/lib/lolita/components/configuration/column_component.rb +31 -0
- data/lib/lolita/components/configuration/list_component.rb +11 -0
- data/lib/lolita/configuration.rb +61 -0
- data/lib/lolita/configuration/action.rb +53 -0
- data/lib/lolita/configuration/base.rb +23 -71
- data/lib/lolita/configuration/column.rb +50 -16
- data/lib/lolita/configuration/columns.rb +51 -23
- data/lib/lolita/configuration/core.rb +80 -0
- data/lib/lolita/configuration/factory/field.rb +8 -3
- data/lib/lolita/configuration/factory/tab.rb +12 -6
- data/lib/lolita/configuration/field.rb +8 -11
- data/lib/lolita/configuration/field/array.rb +7 -9
- data/lib/lolita/configuration/fields.rb +1 -1
- data/lib/lolita/configuration/filter.rb +26 -19
- data/lib/lolita/configuration/list.rb +143 -80
- data/lib/lolita/configuration/nested_list.rb +102 -0
- data/lib/lolita/configuration/search.rb +14 -0
- data/lib/lolita/configuration/tab.rb +13 -9
- data/lib/lolita/configuration/tab/content.rb +6 -0
- data/lib/lolita/configuration/tab/default.rb +2 -2
- data/lib/lolita/configuration/tabs.rb +35 -82
- data/lib/lolita/controller_additions.rb +4 -3
- data/lib/lolita/controllers.rb +13 -0
- data/lib/lolita/controllers/authentication_helpers.rb +17 -0
- data/lib/lolita/controllers/component_helpers.rb +9 -5
- data/lib/lolita/controllers/internal_helpers.rb +22 -97
- data/lib/lolita/controllers/rails_helpers.rb +132 -0
- data/lib/lolita/controllers/url_helpers.rb +1 -1
- data/lib/lolita/errors.rb +3 -0
- data/lib/lolita/extensions/authentication/default_adapter.rb +24 -0
- data/lib/lolita/extensions/authentication/devise_adapter.rb +58 -0
- data/lib/lolita/extensions/authentication/proxy.rb +60 -0
- data/lib/lolita/extensions/authorization/cancan_adapter.rb +45 -0
- data/lib/lolita/extensions/authorization/default_adapter.rb +29 -0
- data/lib/lolita/extensions/authorization/proxy.rb +48 -0
- data/lib/lolita/extensions/extensions.rb +66 -0
- data/lib/lolita/helpers.rb +12 -0
- data/lib/lolita/lazy_loader.rb +15 -10
- data/lib/lolita/mapping.rb +25 -19
- data/lib/lolita/navigation/branch.rb +29 -2
- data/lib/lolita/navigation/tree.rb +6 -0
- data/lib/lolita/observed_array.rb +1 -1
- data/lib/lolita/orm.rb +7 -0
- data/lib/lolita/processors/request_processor.rb +38 -0
- data/lib/lolita/rails/engine.rb +24 -0
- data/lib/lolita/{modules/rest.rb → rails/railtie.rb} +8 -2
- data/lib/lolita/rails/routes.rb +26 -29
- data/lib/lolita/register.rb +48 -0
- data/lib/lolita/ruby_ext/lolita_model_name.rb +37 -0
- data/lib/lolita/system_configuration/application.rb +1 -0
- data/lib/lolita/system_configuration/base.rb +12 -5
- data/lib/lolita/utils.rb +14 -0
- data/lib/lolita/version.rb +30 -0
- data/lolita.gemspec +26 -398
- data/spec/configuration/base_spec.rb +14 -35
- data/spec/configuration/column_spec.rb +51 -2
- data/spec/configuration/columns_spec.rb +13 -19
- data/spec/configuration/core_spec.rb +89 -0
- data/spec/configuration/field_spec.rb +17 -5
- data/spec/configuration/filter_spec.rb +76 -61
- data/spec/configuration/list_spec.rb +339 -45
- data/spec/configuration/nested_list_spec.rb +111 -0
- data/spec/configuration/search_spec.rb +1 -1
- data/spec/configuration/tabs_spec.rb +89 -74
- data/spec/controllers/configuration_spec.rb +15 -0
- data/spec/controllers/internal_helpers_spec.rb +1 -1
- data/spec/controllers/lolita_rest_spec.rb +31 -2
- data/spec/coverage_helper.rb +33 -0
- data/spec/extensions/authentication/default_adapter_spec.rb +34 -0
- data/spec/extensions/authentication/devise_adapter_spec.rb +94 -0
- data/spec/extensions/authentication/proxy_spec.rb +55 -0
- data/spec/extensions/authorization/cancan_adapter_spec.rb +94 -0
- data/spec/extensions/authorization/default_adapter_spec.rb +43 -0
- data/spec/extensions/authorization/proxy_spec.rb +60 -0
- data/spec/extensions/extensions_spec.rb +45 -0
- data/spec/fabricators/category_fabricator.rb +3 -0
- data/spec/fabricators/post_fabricator.rb +4 -0
- data/spec/fabricators/tag_fabricator.rb +3 -0
- data/spec/lolita_spec.rb +1 -0
- data/spec/orm/mongoid.rb +1 -0
- data/spec/rails_app/app/mongoid/category.rb +14 -1
- data/spec/rails_app/app/mongoid/post.rb +9 -1
- data/spec/rails_app/config/application.rb +0 -4
- data/spec/rails_app/config/boot.rb +1 -2
- data/spec/register_spec.rb +50 -0
- data/spec/search/simple_spec.rb +4 -4
- data/spec/simple_spec_helper.rb +2 -1
- data/spec/spec_helper.rb +22 -35
- data/vendor/assets/javascripts/tinymce_config.js +5 -3
- metadata +202 -180
- data/.document +0 -5
- data/GUIDELINES.rdoc +0 -22
- data/VERSION +0 -1
- data/app/helpers/lolita_helper.rb +0 -23
- data/app/views/components/lolita/configuration/column/_display.html.erb +0 -4
- data/app/views/components/lolita/configuration/column/_header.html.erb +0 -7
- data/app/views/components/lolita/configuration/column/_sort.html.erb +0 -7
- data/app/views/components/lolita/configuration/columns/_body.html.erb +0 -5
- data/app/views/components/lolita/configuration/columns/_display.html.erb +0 -2
- data/app/views/components/lolita/configuration/columns/_first.html.erb +0 -3
- data/app/views/components/lolita/configuration/columns/_first_column_header.html.erb +0 -3
- data/app/views/components/lolita/configuration/columns/_header.html.erb +0 -9
- data/app/views/components/lolita/configuration/columns/_last.html.erb +0 -4
- data/app/views/components/lolita/configuration/columns/_last_column_header.html.erb +0 -3
- data/app/views/components/lolita/configuration/columns/_row.html.erb +0 -7
- data/app/views/components/lolita/configuration/field/_display.html.erb +0 -13
- data/app/views/components/lolita/configuration/field/_label.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/_object.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/array/_display.html.erb +0 -5
- data/app/views/components/lolita/configuration/field/array/filter/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +0 -4
- data/app/views/components/lolita/configuration/field/big_decimal/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/boolean/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/boolean/filter/_display.html.erb +0 -2
- data/app/views/components/lolita/configuration/field/date/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/date_time/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/date_time/date/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/date_time/time/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/float/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/hidden/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/integer/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/string/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/string/disabled/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/string/password/_display.html.erb +0 -3
- data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +0 -11
- data/app/views/components/lolita/configuration/field/time/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field_set/_display.html.erb +0 -5
- data/app/views/components/lolita/configuration/list/_display.html.erb +0 -11
- data/app/views/components/lolita/configuration/list/_filter.html.erb +0 -8
- data/app/views/components/lolita/configuration/list/_new_resource.html.erb +0 -6
- data/app/views/components/lolita/configuration/list/_paginator.html.erb +0 -1
- data/app/views/components/lolita/configuration/list/_title.html.erb +0 -10
- data/app/views/components/lolita/configuration/nested_form/_display.html.erb +0 -15
- data/app/views/components/lolita/configuration/nested_form/_fields.html.erb +0 -13
- data/app/views/components/lolita/configuration/tab/_display.html.erb +0 -8
- data/app/views/components/lolita/configuration/tab/_error_msg.html.erb +0 -20
- data/app/views/components/lolita/configuration/tab/_fields.html.erb +0 -9
- data/app/views/components/lolita/configuration/tab/_form.html.erb +0 -8
- data/app/views/components/lolita/configuration/tab/content/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/tab/default/_display.html.erb +0 -3
- data/app/views/components/lolita/configuration/tabs/_display.html.erb +0 -11
- data/app/views/components/lolita/navigation/_display.html.erb +0 -3
- data/app/views/components/lolita/navigation/_tree.html.erb +0 -32
- data/app/views/components/lolita/shared/_flash.html.erb +0 -5
- data/app/views/components/lolita/shared/_header.html.erb +0 -9
- data/app/views/components/lolita/shared/_right_sidebar.html.erb +0 -9
- data/app/views/components/lolita/shared/_save_button.html.erb +0 -6
- data/app/views/layouts/lolita/application.html.erb +0 -37
- data/app/views/lolita/rest/form.html.erb +0 -1
- data/app/views/lolita/rest/index.html.erb +0 -1
- data/config/locales/default/lv.yml +0 -181
- data/db/seed.rb +0 -1
- data/features/create_page.feature +0 -20
- data/features/step_definitions/lolita_steps.rb +0 -7
- data/features/step_definitions/web_steps.rb +0 -219
- data/features/support/env.rb +0 -73
- data/features/support/paths.rb +0 -35
- data/lib/lolita/controllers/authorization_helpers.rb +0 -56
- data/lib/lolita/controllers/user_helpers.rb +0 -44
- data/lib/lolita/modules.rb +0 -6
- data/lib/lolita/rails.rb +0 -23
- data/lib/lolita/rails/all.rb +0 -11
- data/spec/support/factories/category.rb +0 -3
- data/spec/support/factories/post.rb +0 -4
- data/spec/support/factories/tag.rb +0 -3
@@ -36,7 +36,7 @@ describe Lolita::Configuration::Search do
|
|
36
36
|
describe "#run" do
|
37
37
|
|
38
38
|
it "should run search on custom class" do
|
39
|
-
|
39
|
+
Fabricate(:post, :title => "my_title")
|
40
40
|
search = Lolita::Configuration::Search.new(dbi, :with => CustomSearch)
|
41
41
|
search.run("my_title",Object.new).size.should == 1
|
42
42
|
end
|
@@ -1,106 +1,121 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../
|
2
|
-
|
3
|
-
module Lolita
|
4
|
-
module Configuration
|
5
|
-
module Tab
|
6
|
-
class Images < Lolita::Configuration::Tab::Base
|
7
|
-
end
|
8
|
-
class Translation < Lolita::Configuration::Tab::Base
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../simple_spec_helper')
|
2
|
+
require 'ruby-debug'
|
13
3
|
|
14
4
|
describe Lolita::Configuration::Tabs do
|
15
|
-
|
16
|
-
|
5
|
+
let(:klass){Lolita::Configuration::Tabs}
|
6
|
+
let(:dbp_klass){Lolita::DBI::Base}
|
7
|
+
let(:dbp){ Object.new }
|
8
|
+
let(:tabs){klass.new(dbp)}
|
9
|
+
|
10
|
+
# before(:each) do
|
11
|
+
# dbp_class.stub(:create).with(kind_of(Class)).and_return(dbp)
|
12
|
+
# end
|
13
|
+
|
14
|
+
it "should set attributes from args to tabs" do
|
15
|
+
args = [1,2,3]
|
16
|
+
klass.any_instance.should_receive(:set_attributes).with(*args)
|
17
|
+
klass.new(dbp,*args)
|
17
18
|
end
|
18
19
|
|
19
|
-
it "should
|
20
|
-
|
21
|
-
|
20
|
+
it "should eval block when given" do
|
21
|
+
block = Proc.new{}
|
22
|
+
klass.any_instance.should_receive(:instance_eval).with(&block)
|
23
|
+
klass.new(dbp,&block)
|
22
24
|
end
|
23
25
|
|
24
|
-
it "should
|
25
|
-
tabs=
|
26
|
-
tabs.
|
26
|
+
it "should initialize default attributes when instance is created" do
|
27
|
+
tabs = klass.new(dbp)
|
28
|
+
tabs.should be_empty
|
29
|
+
tabs.tab_types.should eq([:content])
|
27
30
|
end
|
28
31
|
|
29
|
-
it "should
|
30
|
-
tabs
|
31
|
-
|
32
|
+
it "should be enumerable and yield each tab at once" do
|
33
|
+
tabs.instance_variable_set(:@tabs, [1,2,3])
|
34
|
+
tabs.each_with_index do |tab,index|
|
35
|
+
tab.should eq(index+1)
|
32
36
|
end
|
33
|
-
tabs.size.should == 1
|
34
37
|
end
|
35
38
|
|
36
|
-
it "should create
|
37
|
-
tabs
|
38
|
-
tabs.
|
39
|
+
it "should create content tab when accessing any tab and none is given" do
|
40
|
+
tabs.should_receive(:create_content_tab)
|
41
|
+
tabs.any?
|
39
42
|
end
|
40
43
|
|
41
|
-
it "should
|
42
|
-
tabs
|
43
|
-
|
44
|
-
end
|
45
|
-
tabs.size.should > 0
|
44
|
+
it "should accept collection of tabs and iterate through them and assign to itself through builder" do
|
45
|
+
tabs.should_receive(:build_element).twice
|
46
|
+
tabs.tabs= [1,2]
|
46
47
|
end
|
47
48
|
|
48
|
-
it "should
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
tabs.size.should == 0
|
53
|
-
tabs.excluded.size.should > 0
|
49
|
+
it "should raise ArgumentError when assigned tabs is not collection" do
|
50
|
+
expect{
|
51
|
+
tabs.tabs = Object.new
|
52
|
+
}.to raise_error(ArgumentError)
|
54
53
|
end
|
55
54
|
|
56
|
-
it "should
|
57
|
-
|
58
|
-
tabs.
|
59
|
-
tabs.
|
55
|
+
it "should add tab with no args" do
|
56
|
+
klass.any_instance.should_receive(:build_element).twice.and_return(1)
|
57
|
+
tabs.tab
|
58
|
+
tabs.should have(1).item
|
60
59
|
end
|
61
60
|
|
62
|
-
it "should
|
63
|
-
|
64
|
-
tabs
|
65
|
-
tabs
|
66
|
-
tabs.size.should == 2
|
61
|
+
it "should return all field of each tab" do
|
62
|
+
arr = [stub(:fields => [1,2]),stub(:fields => [3,4])]
|
63
|
+
tabs.instance_variable_set(:@tabs,arr)
|
64
|
+
tabs.fields.should eq([1,2,3,4])
|
67
65
|
end
|
68
66
|
|
69
|
-
it "should
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
}.should raise_error Lolita::SameTabTypeError
|
67
|
+
it "should detect tab by type" do
|
68
|
+
arr = [stub(:type => :content),stub(:type => :image)]
|
69
|
+
tabs.instance_variable_set(:@tabs,arr)
|
70
|
+
tabs.by_type(:image).should_not be_nil
|
71
|
+
tabs.by_type(:not_existing).should be_nil
|
76
72
|
end
|
77
73
|
|
78
|
-
it "should
|
79
|
-
|
80
|
-
tabs
|
81
|
-
tabs
|
82
|
-
tabs[tabs.size-2].class.should == Lolita::Configuration::Tab::Images
|
83
|
-
tabs[tabs.size-1].class.should == Lolita::Configuration::Tab::Translation
|
74
|
+
it "should return all tabs names" do
|
75
|
+
arr = [stub(:name => "n1"),stub(:name => "n2")]
|
76
|
+
tabs.instance_variable_set(:@tabs,arr)
|
77
|
+
tabs.names.should eq(["n1","n2"])
|
84
78
|
end
|
85
79
|
|
86
|
-
it "should return all
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
80
|
+
it "should return all associated tabs" do
|
81
|
+
arr = [stub(:dissociate => true),stub(:dissociate => false)]
|
82
|
+
tabs.instance_variable_set(:@tabs,arr)
|
83
|
+
tabs.associated.should have(1).item
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should return all dissociated tabs" do
|
87
|
+
arr = [stub(:dissociate => true),stub(:dissociate => false)]
|
88
|
+
tabs.instance_variable_set(:@tabs,arr)
|
89
|
+
tabs.dissociated.should have(1).item
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should populate self with default tabs" do
|
93
|
+
tabs.stub(:build_element).and_return(stub())
|
94
|
+
tabs.default
|
95
|
+
tabs.should have(1).item
|
91
96
|
end
|
92
97
|
|
93
|
-
context "
|
94
|
-
it "should
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
99
|
-
tab :content
|
100
|
-
end
|
101
|
-
tabs.by_type(:content).should_not be_nil
|
98
|
+
context "adding tabs" do
|
99
|
+
it "should skip factory call when tab is not Hash or Symbol" do
|
100
|
+
tab = stub()
|
101
|
+
tabs.tab(tab)
|
102
|
+
tabs.first.should == tab
|
102
103
|
end
|
103
104
|
|
105
|
+
it "should call factory when tab is Hash" do
|
106
|
+
tab = stub()
|
107
|
+
Lolita::Configuration::Factory::Tab.stub(:add).and_return(tab)
|
108
|
+
tabs.tab({})
|
109
|
+
tabs.first.should == tab
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should call factory when tab is Symbol" do
|
113
|
+
tab = stub()
|
114
|
+
Lolita::Configuration::Factory::Tab.stub(:add).and_return(tab)
|
115
|
+
tabs.tab(:image)
|
116
|
+
tabs.first.should == tab
|
117
|
+
end
|
104
118
|
end
|
119
|
+
|
105
120
|
end
|
106
121
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Lolita::RestController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@controller.request.env["lolita.mapping"]=Lolita.mappings[:post]
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should add custom assets to Lolita" do
|
11
|
+
Lolita.application.assets += ["lolita_js_extensions.js"]
|
12
|
+
get :index
|
13
|
+
response.body.should =~/lolita_js_extensions.js/
|
14
|
+
end
|
15
|
+
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
5
5
|
|
6
6
|
class MyController < ApplicationController
|
7
|
-
include Lolita::Controllers::
|
7
|
+
include Lolita::Controllers::RailsHelpers
|
8
8
|
include Lolita::Hooks
|
9
9
|
add_hook :before_build_resource,:after_build_resource
|
10
10
|
add_hook :before_index
|
@@ -4,7 +4,7 @@ describe Lolita::RestController do
|
|
4
4
|
render_views
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
@
|
7
|
+
@request.env["lolita.mapping"]=Lolita.mappings[:post]
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "hooks" do
|
@@ -25,7 +25,7 @@ describe Lolita::RestController do
|
|
25
25
|
|
26
26
|
it "should overwrite list component body_cell" do
|
27
27
|
pending "Need to be seperated from whole project"
|
28
|
-
|
28
|
+
Fabricate(:post)
|
29
29
|
get :index
|
30
30
|
response.body.should =~/overwritten cell/
|
31
31
|
end
|
@@ -49,5 +49,34 @@ describe Lolita::RestController do
|
|
49
49
|
|
50
50
|
it "should use field.title instead of field.name when displaying all error messages at top of form"
|
51
51
|
|
52
|
+
describe "nested lists" do
|
53
|
+
|
54
|
+
it "should have nested lists for columns" do
|
55
|
+
pending "Need to fix this"
|
56
|
+
get :index
|
57
|
+
response.body.should match(/tr.*class\s*=.*with-nested-list.*data-nested-list-url/)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have nested lists for whole row" do
|
61
|
+
pending "Need to fix this"
|
62
|
+
@request.env["lolita.mapping"]=Lolita.mappings[:category]
|
63
|
+
get :index
|
64
|
+
response.body.should match(/tr.*class.*with-nested-list.*data-nested-list-url/)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have nested list for nested lists" do
|
68
|
+
pending "Need to fix this"
|
69
|
+
categories = (1..5).to_a.map{|i|
|
70
|
+
Fabricate(:category)
|
71
|
+
}
|
72
|
+
2.times{Fabricate(:post, :category => categories.first)}
|
73
|
+
get :index, {:nested => {"category_id" => categories.last}}
|
74
|
+
response.body.should_not match(/tr/)
|
75
|
+
get :index, {:nested => {"category_id" => categories.first}}
|
76
|
+
response.body.scan(/<tr>/).should have(2).items
|
77
|
+
response.body.should match(/td.*class.*with-nested-list/)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
52
81
|
end
|
53
82
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cover_me'
|
2
|
+
require 'ruby-debug'
|
3
|
+
CoverMe.config do |c|
|
4
|
+
# where is your project's root:
|
5
|
+
c.project.root = File.expand_path("../lolita") # => "Rails.root" (default)
|
6
|
+
|
7
|
+
# what files are you interested in coverage for:
|
8
|
+
c.file_pattern = [
|
9
|
+
/(#{CoverMe.config.project.root}\/app\/.+\.rb)/i,
|
10
|
+
/(#{CoverMe.config.project.root}\/lib\/.+\.rb)/i
|
11
|
+
]
|
12
|
+
|
13
|
+
c.formatter = CoverMe::HtmlFormatter
|
14
|
+
# what files do you want to explicitly exclude from coverage
|
15
|
+
#c.exclude_file_patterns # => [] (default)
|
16
|
+
|
17
|
+
# where do you want the HTML generated:
|
18
|
+
#c.html_formatter.output_path # => File.join(CoverMe.config.project.root, 'coverage') (default)
|
19
|
+
|
20
|
+
# what do you want to happen when it finishes:
|
21
|
+
c.at_exit = Proc.new {
|
22
|
+
if CoverMe.config.formatter == CoverMe::HtmlFormatter
|
23
|
+
index = File.join(CoverMe.config.html_formatter.output_path, 'index.html')
|
24
|
+
if File.exists?(index)
|
25
|
+
`open #{index}`
|
26
|
+
end
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
at_exit do
|
32
|
+
CoverMe.complete!
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../simple_spec_helper')
|
2
|
+
|
3
|
+
describe Lolita::Extensions::Authentication::DefaultAdapter do
|
4
|
+
let(:klass){ Lolita::Extensions::Authentication::DefaultAdapter }
|
5
|
+
let(:adapter){ klass.new(Object.new,{}) }
|
6
|
+
|
7
|
+
it "should create new DefaultAdapter" do
|
8
|
+
expect do
|
9
|
+
klass.new(Object.new,{})
|
10
|
+
end.not_to raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should not have current user" do
|
14
|
+
adapter.current_user.should be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not be signed in" do
|
18
|
+
adapter.user_signed_in?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should authenticate user" do
|
22
|
+
adapter.authenticate_user!.should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Integration with proxy' do
|
26
|
+
let(:proxy){ Lolita::Extensions::Authentication::Proxy.new(Object.new,{}) }
|
27
|
+
it "should have the same method results for adapter and proxy" do
|
28
|
+
proxy.adapter = adapter
|
29
|
+
%w(current_user user_signed_in? authenticate_user!).each do |name|
|
30
|
+
proxy.send(name).should eql(adapter.send(name))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../simple_spec_helper')
|
2
|
+
|
3
|
+
module TestActionController
|
4
|
+
class Base
|
5
|
+
|
6
|
+
def current_user
|
7
|
+
"user_1"
|
8
|
+
end
|
9
|
+
|
10
|
+
def authentitcate_test_user!
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit_admin_password_path
|
15
|
+
"/edit_admin"
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy_admin_session_path
|
19
|
+
"/destroy_admin"
|
20
|
+
end
|
21
|
+
|
22
|
+
def current_admin
|
23
|
+
"admin_1"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module Devise
|
29
|
+
def self.sign_out_via
|
30
|
+
"get"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe Lolita::Extensions::Authentication::DeviseAdapter do
|
35
|
+
around(:each){ |example|
|
36
|
+
Lolita.authentication = :authentitcate_test_user!
|
37
|
+
Lolita.user_classes = ["Admin","User"]
|
38
|
+
example.run
|
39
|
+
Lolita.authentication = nil
|
40
|
+
Lolita.user_classes = []
|
41
|
+
}
|
42
|
+
let(:klass){ Lolita::Extensions::Authentication::DeviseAdapter }
|
43
|
+
let(:controller){TestActionController::Base.new}
|
44
|
+
let(:adapter){ klass.new(controller,{}) }
|
45
|
+
|
46
|
+
it "should create new" do
|
47
|
+
expect do
|
48
|
+
klass.new(TestActionController::Base,{})
|
49
|
+
end.not_to raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should raise error without authentication" do
|
53
|
+
expect do
|
54
|
+
Lolita.authentication = nil
|
55
|
+
klass.new(TestActionController::Base,{})
|
56
|
+
end.to raise_error(Lolita::NoAuthenticationDefinedError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not have current user" do
|
60
|
+
Lolita.user_classes = ["User"]
|
61
|
+
adapter.current_user.should == controller.current_user
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should not be signed in" do
|
65
|
+
adapter.user_signed_in?.should be_true
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should authenticate user" do
|
69
|
+
adapter.authenticate_user!.should be_true
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have sign_out_via method" do
|
73
|
+
adapter.sign_out_via.should == "get"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should have edit path" do
|
77
|
+
adapter.edit_path.should == "/edit_admin"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have sign out path" do
|
81
|
+
adapter.sign_out_path.should == "/destroy_admin"
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
describe 'Integration with proxy' do
|
86
|
+
let(:proxy){ Lolita::Extensions::Authentication::Proxy.new(controller,{}) }
|
87
|
+
it "should have the same method results for adapter and proxy" do
|
88
|
+
proxy.adapter = adapter
|
89
|
+
%w(current_user user_signed_in? authenticate_user!).each do |name|
|
90
|
+
proxy.send(name).should eql(adapter.send(name))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|