lolita 3.3.6 → 3.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/lolita/PIE-custom.htc +87 -87
  3. data/app/assets/stylesheets/lolita/PIE.htc +81 -81
  4. data/app/assets/stylesheets/lolita/application.css +6 -6
  5. data/app/assets/stylesheets/lolita/default.css.erb +169 -169
  6. data/app/assets/stylesheets/lolita/jquery-ui-1.8.16.lolita.css.erb +567 -567
  7. data/app/controllers/lolita/field_data_controller.rb +4 -0
  8. data/app/controllers/lolita/field_data_controller.rb~ +40 -0
  9. data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
  10. data/app/views/components/lolita/configuration/column/_first.html.haml +1 -1
  11. data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -1
  12. data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -6
  13. data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -5
  14. data/app/views/components/lolita/configuration/field/array/autocomplete/_display.html.haml~ +16 -0
  15. data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +7 -7
  16. data/app/views/components/lolita/configuration/filter/_display.html.haml~ +9 -0
  17. data/app/views/components/lolita/configuration/search/_display.html.haml +2 -2
  18. data/app/views/kaminari/lolita/_first_page.html.erb +11 -11
  19. data/app/views/kaminari/lolita/_gap.html.erb +8 -8
  20. data/app/views/kaminari/lolita/_last_page.html.erb +11 -11
  21. data/app/views/kaminari/lolita/_next_page.html.erb +11 -11
  22. data/app/views/kaminari/lolita/_page.html.erb +12 -12
  23. data/app/views/kaminari/lolita/_paginator.html.erb +23 -23
  24. data/app/views/kaminari/lolita/_prev_page.html.erb +11 -11
  25. data/app/views/lolita/info/index.html.erb +232 -232
  26. data/lib/lolita/adapter/field_helper.rb +18 -18
  27. data/lib/lolita/configuration/field/big_decimal.rb +12 -12
  28. data/lib/lolita/configuration/field/boolean.rb +12 -12
  29. data/lib/lolita/configuration/field/date.rb +12 -12
  30. data/lib/lolita/configuration/field/hidden.rb +12 -12
  31. data/lib/lolita/configuration/field/integer.rb +11 -11
  32. data/lib/lolita/configuration/field/string.rb +16 -16
  33. data/lib/lolita/configuration/field/time.rb +13 -13
  34. data/lib/lolita/configuration/field_set.rb +25 -25
  35. data/lib/lolita/configuration/filter.rb~ +122 -0
  36. data/lib/lolita/configuration/nested_form.rb +104 -104
  37. data/lib/lolita/configuration/search.rb +104 -104
  38. data/lib/lolita/controllers/internal_helpers.rb +4 -3
  39. data/lib/lolita/controllers/internal_helpers.rb~ +75 -0
  40. data/lib/lolita/dbi/base.rb +56 -56
  41. data/lib/lolita/hooks/named_hook.rb +125 -125
  42. data/lib/lolita/lazy_loader.rb +54 -54
  43. data/lib/lolita/navigation/tree.rb +132 -132
  44. data/lib/lolita/ruby_ext/accessors.rb +26 -26
  45. data/lib/lolita/search/simple.rb +75 -75
  46. data/lib/lolita/support/formatter.rb +62 -62
  47. data/lib/lolita/support/formatter/rails.rb +56 -56
  48. data/lib/lolita/test/matchers.rb +77 -77
  49. data/lib/lolita/version.rb +1 -1
  50. data/lib/lolita/version.rb~ +30 -0
  51. data/spec/builder_spec.rb +120 -120
  52. data/spec/configuration/filter_spec.rb~ +167 -0
  53. data/spec/rails_app/app/controllers/application_controller.rb +3 -3
  54. data/spec/rails_app/app/helpers/application_helper.rb +3 -3
  55. data/spec/rails_app/app/mongoid/address.rb +7 -7
  56. data/spec/rails_app/app/mongoid/comment.rb +5 -5
  57. data/spec/rails_app/app/mongoid/preference.rb +5 -5
  58. data/spec/rails_app/app/mongoid/profile.rb +13 -13
  59. data/spec/rails_app/app/mongoid/tag.rb +3 -3
  60. data/spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb +1 -1
  61. data/spec/rails_app/config/environment.rb +5 -5
  62. data/spec/rails_app/config/environments/production.rb +37 -37
  63. data/spec/rails_app/config/environments/test.rb +37 -37
  64. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -7
  65. data/spec/rails_app/config/initializers/inflections.rb +2 -2
  66. data/spec/rails_app/config/initializers/secret_token.rb +1 -1
  67. data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +13 -13
  68. data/spec/rails_app/log/development.log +753 -14313
  69. data/spec/rails_app/public/javascripts/jquery-1.5.1.min.js +15 -15
  70. data/spec/rails_app/public/javascripts/lolita/main.js +6 -6
  71. data/spec/rails_app/public/javascripts/modernizr-1.7.min.js +1 -1
  72. data/spec/rails_app/public/javascripts/rails.js +137 -137
  73. data/spec/rails_app/public/javascripts/tinymce/langs/en.js +221 -221
  74. data/spec/rails_app/public/javascripts/tinymce/license.txt +504 -504
  75. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/about.htm +52 -52
  76. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -26
  77. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/charmap.htm +51 -51
  78. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/color_picker.htm +74 -74
  79. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1328 -1328
  80. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/image.htm +80 -80
  81. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/about.js +73 -73
  82. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/anchor.js +42 -42
  83. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/charmap.js +354 -354
  84. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/color_picker.js +329 -329
  85. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/image.js +247 -247
  86. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/link.js +153 -153
  87. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -56
  88. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en.js +68 -68
  89. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +53 -53
  90. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/link.htm +57 -57
  91. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -47
  92. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
  93. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
  94. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
  95. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -25
  96. data/spec/rails_app/public/javascripts/tinymce/tiny_mce_popup.js +4 -4
  97. data/spec/rails_app/public/stylesheets/lolita/default.css +169 -169
  98. data/spec/rails_app/public/stylesheets/lolita/style.css +214 -214
  99. data/vendor/assets/javascripts/jquery-numeric.js +279 -279
  100. data/vendor/assets/javascripts/modernizr_1_7_min.js +1 -1
  101. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
  102. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
  103. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
  104. data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +567 -567
  105. metadata +349 -341
@@ -0,0 +1,167 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lolita::Configuration::Filter do
4
+
5
+ let(:dbi){Lolita::DBI::Base.new(Post)}
6
+
7
+ it "should create new filter with block" do
8
+ Lolita::Configuration::Filter.new(dbi) do
9
+ end
10
+ end
11
+
12
+ it "should create new filter without block" do
13
+ Lolita::Configuration::Filter.new(dbi)
14
+ end
15
+
16
+ it "should give fields as arguments" do
17
+ list=Lolita::Configuration::List.new(dbi)
18
+ list.filter :name, :is_public
19
+ list.filter.fields.size.should == 2
20
+ end
21
+
22
+ it "should add some fields" do
23
+ filter=Lolita::Configuration::Filter.new(dbi) do
24
+ fields :name, :is_public, :not_public
25
+ end
26
+ filter.fields.size.should == 3
27
+ end
28
+
29
+ it "should add some field with block" do
30
+ filter=Lolita::Configuration::Filter.new(dbi) do
31
+ field :name do
32
+ type :integer
33
+ end
34
+ end
35
+ filter.fields.first.type.should == "integer"
36
+ end
37
+
38
+ it "should add some fields with block" do
39
+ filter=Lolita::Configuration::Filter.new(dbi) do
40
+ fields :name, :is_public do
41
+ type :integer
42
+ end
43
+ field :created_at, :time
44
+ end
45
+ filter.fields.size.should == 3
46
+ filter.fields[0].type.should == "integer"
47
+ filter.fields[1].type.should == "integer"
48
+ filter.fields[2].type.should == "time"
49
+ end
50
+
51
+ it "should filter results for boolean" do
52
+ Fabricate(:post, :is_public => true)
53
+ Fabricate(:post, :is_public => true)
54
+ Fabricate(:post, :is_public => false)
55
+
56
+ filter=Lolita::Configuration::Filter.new(dbi) do
57
+ field :is_public
58
+ end
59
+
60
+ dbi.filter(:is_public => 1).size.should == 2
61
+ dbi.filter(:is_public => 0).size.should == 1
62
+ end
63
+
64
+ it "should filter results for belongs_to" do
65
+ c1 = Fabricate(:category, :name => "Linux")
66
+ c2 = Fabricate(:category, :name => "Android")
67
+ p1=Fabricate(:post, :category => c1)
68
+ p2=Fabricate(:post, :category => c1)
69
+ p3=Fabricate(:post, :category => c2)
70
+
71
+ filter=Lolita::Configuration::Filter.new(dbi) do
72
+ field :tags
73
+ end
74
+ dbi.filter(:category_id => c1.id).size.should == 2
75
+ dbi.filter(:category_id => c2.id).size.should == 1
76
+ end
77
+
78
+ it "should filter results for has_and_belongs_to_many" do
79
+ tag1 = Fabricate(:tag, :name => "Linux")
80
+ tag2 = Fabricate(:tag, :name => "Android")
81
+ p1=Fabricate(:post, :tags => [tag1,tag2])
82
+ p2=Fabricate(:post, :tags => [tag1,tag2])
83
+ p3=Fabricate(:post, :tags => [tag1])
84
+
85
+ filter=Lolita::Configuration::Filter.new(dbi) do
86
+ field :tags
87
+ end
88
+ dbi.filter(:tag_ids => tag1.id).size.should == 3
89
+ dbi.filter(:tag_ids => tag2.id).size.should == 2
90
+ end
91
+
92
+ describe "Filtering list" do
93
+ let(:list){ Lolita::Configuration::List}
94
+
95
+ it "should filter with default filters" do
96
+ tags = %w(Android Linux Windows).map{|name| Fabricate(:tag, :name => name )}
97
+ 3.times {|i| Fabricate(:post,:tags => [tags[i]])}
98
+
99
+ list_conf = list.new(dbi) do
100
+ filter do
101
+ field :tags
102
+ end
103
+ end
104
+ list_conf.paginate(1).should have(3).items
105
+ request = Object.new
106
+ request.class_eval do
107
+ def params
108
+ {:filter => {:tag_ids => Tag.where(:name => 'Android').first.id}}
109
+ end
110
+ end
111
+ list_conf.paginate(1,request).should have(1).items
112
+ end
113
+
114
+ it "should filter with custom search" do
115
+ tags = %w(Android Linux Windows).map{|name| Fabricate(:tag, :name => name )}
116
+ 3.times {|i| Fabricate(:post,:tags => [tags[i]])}
117
+ Post.class_eval do
118
+ def self.custom_filter query,request
119
+ where(:tag_ids.in => Tag.where(:name.in => ['Android','Linux']).map(&:id))
120
+ end
121
+ end
122
+ list_conf = list.new(dbi) do
123
+ filter do
124
+ field :tags
125
+ search :custom_filter
126
+ end
127
+ end
128
+ list_conf.paginate(1).should have(3).items
129
+ request = Object.new
130
+ request.class_eval do
131
+ def params
132
+ {:filter => {:tag_ids => Tag.where(:name => 'Android').first.id}}
133
+ end
134
+ end
135
+ list_conf.paginate(1,request).should have(2).items
136
+ end
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
167
+ end
@@ -1,3 +1,3 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -1,3 +1,3 @@
1
- # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -1,8 +1,8 @@
1
- class Address
2
- include Mongoid::Document
3
- field :street
4
- field :city
5
- field :state
6
- field :post_code
7
- embedded_in :person
1
+ class Address
2
+ include Mongoid::Document
3
+ field :street
4
+ field :city
5
+ field :state
6
+ field :post_code
7
+ embedded_in :person
8
8
  end
@@ -1,6 +1,6 @@
1
- class Comment
2
- include Mongoid::Document
3
- field :body
4
- belongs_to :post
5
- belongs_to :profile
1
+ class Comment
2
+ include Mongoid::Document
3
+ field :body
4
+ belongs_to :post
5
+ belongs_to :profile
6
6
  end
@@ -1,6 +1,6 @@
1
- class Preference
2
- include Mongoid::Document
3
- include Lolita::Configuration
4
- field :name
5
- has_and_belongs_to_many :profiles
1
+ class Preference
2
+ include Mongoid::Document
3
+ include Lolita::Configuration
4
+ field :name
5
+ has_and_belongs_to_many :profiles
6
6
  end
@@ -1,14 +1,14 @@
1
- class Profile
2
- include Mongoid::Document
3
- include Lolita::Configuration
4
- field :name, :type=>String
5
- field :age
6
- field :genere
7
- has_many :posts
8
- has_many :comments
9
- has_and_belongs_to_many :preferences
10
- embeds_one :address
11
- lolita do
12
-
13
- end
1
+ class Profile
2
+ include Mongoid::Document
3
+ include Lolita::Configuration
4
+ field :name, :type=>String
5
+ field :age
6
+ field :genere
7
+ has_many :posts
8
+ has_many :comments
9
+ has_and_belongs_to_many :preferences
10
+ embeds_one :address
11
+ lolita do
12
+
13
+ end
14
14
  end
@@ -1,4 +1,4 @@
1
- class Tag
2
- include Mongoid::Document
3
- field :name
1
+ class Tag
2
+ include Mongoid::Document
3
+ field :name
4
4
  end
@@ -1 +1 @@
1
- <td>overwritten cell</td>
1
+ <td>overwritten cell</td>
@@ -1,5 +1,5 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- RailsApp::Application.initialize!
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -1,37 +1,37 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/environment.rb
3
- # Do not compress assets
4
- config.assets.compress = false
5
-
6
- # Expands the lines which load the assets
7
- config.assets.debug = true
8
- # The production environment is meant for finished, "live" apps.
9
- # Code is not reloaded between requests
10
- config.cache_classes = true
11
-
12
- # Full error reports are disabled and caching is turned on
13
- config.consider_all_requests_local = false
14
- config.action_controller.perform_caching = true
15
-
16
- # See everything in the log (default is :info)
17
- # config.log_level = :debug
18
-
19
- # Use a different logger for distributed setups
20
- # config.logger = SyslogLogger.new
21
-
22
- # Use a different cache store in production
23
- # config.cache_store = :mem_cache_store
24
-
25
- # Disable Rails's static asset server
26
- # In production, Apache or nginx will already do this
27
- config.serve_static_assets = false
28
-
29
- # Enable serving of images, stylesheets, and javascripts from an asset server
30
- # config.action_controller.asset_host = "http://assets.example.com"
31
-
32
- # Disable delivery errors, bad email addresses will be ignored
33
- # config.action_mailer.raise_delivery_errors = false
34
-
35
- # Enable threaded mode
36
- # config.threadsafe!
37
- end
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+ # Do not compress assets
4
+ config.assets.compress = false
5
+
6
+ # Expands the lines which load the assets
7
+ config.assets.debug = true
8
+ # The production environment is meant for finished, "live" apps.
9
+ # Code is not reloaded between requests
10
+ config.cache_classes = true
11
+
12
+ # Full error reports are disabled and caching is turned on
13
+ config.consider_all_requests_local = false
14
+ config.action_controller.perform_caching = true
15
+
16
+ # See everything in the log (default is :info)
17
+ # config.log_level = :debug
18
+
19
+ # Use a different logger for distributed setups
20
+ # config.logger = SyslogLogger.new
21
+
22
+ # Use a different cache store in production
23
+ # config.cache_store = :mem_cache_store
24
+
25
+ # Disable Rails's static asset server
26
+ # In production, Apache or nginx will already do this
27
+ config.serve_static_assets = false
28
+
29
+ # Enable serving of images, stylesheets, and javascripts from an asset server
30
+ # config.action_controller.asset_host = "http://assets.example.com"
31
+
32
+ # Disable delivery errors, bad email addresses will be ignored
33
+ # config.action_mailer.raise_delivery_errors = false
34
+
35
+ # Enable threaded mode
36
+ # config.threadsafe!
37
+ end
@@ -1,37 +1,37 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/environment.rb
3
- # Do not compress assets
4
- config.assets.compress = false
5
-
6
- # Expands the lines which load the assets
7
- config.assets.debug = true
8
- # The test environment is used exclusively to run your application's
9
- # test suite. You never need to work with it otherwise. Remember that
10
- # your test database is "scratch space" for the test suite and is wiped
11
- # and recreated between test runs. Don't rely on the data there!
12
- config.cache_classes = true
13
-
14
- # Log error messages when you accidentally call methods on nil.
15
- config.whiny_nils = true
16
-
17
- # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
19
- config.action_controller.perform_caching = false
20
-
21
- # Disable request forgery protection in test environment
22
- config.action_controller.allow_forgery_protection = false
23
-
24
- # Tell Action Mailer not to deliver emails to the real world.
25
- # The :test delivery method accumulates sent emails in the
26
- # ActionMailer::Base.deliveries array.
27
- config.action_mailer.delivery_method = :test
28
-
29
- # Use SQL instead of Active Record's schema dumper when creating the test database.
30
- # This is necessary if your schema can't be completely dumped by the schema dumper,
31
- # like if you have constraints or database-specific column types
32
- # config.active_record.schema_format = :sql
33
-
34
- config.action_dispatch.show_exceptions = false
35
-
36
- config.active_support.deprecation = :stderr
37
- end
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+ # Do not compress assets
4
+ config.assets.compress = false
5
+
6
+ # Expands the lines which load the assets
7
+ config.assets.debug = true
8
+ # The test environment is used exclusively to run your application's
9
+ # test suite. You never need to work with it otherwise. Remember that
10
+ # your test database is "scratch space" for the test suite and is wiped
11
+ # and recreated between test runs. Don't rely on the data there!
12
+ config.cache_classes = true
13
+
14
+ # Log error messages when you accidentally call methods on nil.
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Disable request forgery protection in test environment
22
+ config.action_controller.allow_forgery_protection = false
23
+
24
+ # Tell Action Mailer not to deliver emails to the real world.
25
+ # The :test delivery method accumulates sent emails in the
26
+ # ActionMailer::Base.deliveries array.
27
+ config.action_mailer.delivery_method = :test
28
+
29
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
30
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
31
+ # like if you have constraints or database-specific column types
32
+ # config.active_record.schema_format = :sql
33
+
34
+ config.action_dispatch.show_exceptions = false
35
+
36
+ config.active_support.deprecation = :stderr
37
+ end
@@ -1,7 +1,7 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- Rails.backtrace_cleaner.remove_silencers!
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ Rails.backtrace_cleaner.remove_silencers!