lolita 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/{GUIDELINE → GUIDELINES} +0 -0
  2. data/History.rdoc +70 -0
  3. data/LICENSE.txt +3 -1
  4. data/README.rdoc +5 -1
  5. data/Rakefile +2 -2
  6. data/VERSION +1 -1
  7. data/app/controllers/lolita/rest_controller.rb +1 -1
  8. data/app/views/components/lolita/configuration/field/array/filter/_display.html.erb +1 -0
  9. data/app/views/components/lolita/configuration/field/boolean/filter/_display.html.erb +2 -0
  10. data/app/views/components/lolita/configuration/field/date_time/_display.html.erb +1 -0
  11. data/app/views/components/lolita/configuration/field/date_time/date/_display.html.erb +1 -0
  12. data/app/views/components/lolita/configuration/field/date_time/time/_display.html.erb +1 -0
  13. data/app/views/components/lolita/configuration/field/time/_display.html.erb +1 -1
  14. data/app/views/components/lolita/configuration/list/_filter.html.erb +2 -2
  15. data/config/locales/en.yml +4 -1
  16. data/lib/lolita.rb +18 -11
  17. data/lib/lolita/adapter/abstract_adapter.rb +1 -1
  18. data/lib/lolita/adapter/active_record.rb +28 -1
  19. data/lib/lolita/adapter/mongoid.rb +25 -2
  20. data/lib/lolita/configuration/field/array.rb +1 -0
  21. data/lib/lolita/configuration/field/date.rb +1 -1
  22. data/lib/lolita/configuration/field/date_time.rb +13 -0
  23. data/lib/lolita/configuration/filter.rb +24 -0
  24. data/lib/lolita/configuration/list.rb +4 -1
  25. data/lib/lolita/configuration/page.rb +18 -2
  26. data/lib/lolita/controllers/internal_helpers.rb +1 -0
  27. data/lib/lolita/hooks.rb +22 -22
  28. data/lib/lolita/hooks/named_hook.rb +7 -3
  29. data/lib/lolita/navigation/branch.rb +7 -0
  30. data/lib/lolita/navigation/tree.rb +7 -0
  31. data/lolita.gemspec +22 -12
  32. data/public/stylesheets/lolita/style.css +16 -0
  33. data/spec/adapter_helper.rb +1 -1
  34. data/spec/configuration/filter_spec.rb +63 -1
  35. data/spec/controllers/internal_helpers_spec.rb +7 -0
  36. data/spec/controllers/lolita_rest_spec.rb +1 -0
  37. data/spec/hooks_spec.rb +16 -15
  38. data/spec/navigation/tree_spec.rb +41 -18
  39. data/spec/orm/mongoid.rb +4 -7
  40. data/spec/rails_app/app/mongoid/address.rb +1 -1
  41. data/spec/rails_app/app/mongoid/category.rb +6 -0
  42. data/spec/rails_app/app/mongoid/comment.rb +2 -2
  43. data/spec/rails_app/app/mongoid/post.rb +10 -6
  44. data/spec/rails_app/app/mongoid/preference.rb +1 -1
  45. data/spec/rails_app/app/mongoid/profile.rb +3 -3
  46. data/spec/rails_app/app/mongoid/tag.rb +4 -0
  47. data/spec/support/factories/category.rb +3 -0
  48. data/spec/support/factories/post.rb +1 -0
  49. data/spec/support/factories/tag.rb +3 -0
  50. metadata +23 -14
  51. data/.project +0 -17
  52. data/lib/lolita/navigation.rb +0 -48
  53. data/log/development.log +0 -0
  54. data/test/cells/form_cell_test.rb +0 -15
  55. data/test/test_helper.rb +0 -2
@@ -2,6 +2,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../simple_spec_helper')
2
2
 
3
3
  describe Lolita::Navigation::Tree do
4
4
 
5
+ let(:tree){Lolita::Navigation::Tree.new("test")}
6
+
5
7
  context "#new" do
6
8
  it "should create new navigation tree with name" do
7
9
  tree=Lolita::Navigation::Tree.new("Test tree")
@@ -16,7 +18,12 @@ describe Lolita::Navigation::Tree do
16
18
 
17
19
  end
18
20
 
19
- let(:tree){Lolita::Navigation::Tree.new("test")}
21
+ describe "work with nodes" do
22
+ it "should have root branch with level 0" do
23
+ tree.root.should_not be_nil
24
+ tree.root.level.should == 0
25
+ end
26
+ end
20
27
 
21
28
  context "#add" do
22
29
  it "should accept object, position and options" do
@@ -26,34 +33,50 @@ describe Lolita::Navigation::Tree do
26
33
  end
27
34
 
28
35
  context "#each" do
29
- let(:populated_tree){
30
- p_tree=Lolita::Navigation::Tre.new("populated tree")
31
- 0.upto(3){|i|
32
- p_tree.add(Object,:append,:url=>"/#{i}",:name=>"branch#{i}")
33
- }
34
- p_tree
35
- }
36
+
37
+ let(:empty_branch){Lolita::Navigation::Branch.new(Object,:url=>"/")}
36
38
 
37
39
  it "should iterate through all branches" do
38
- populated_tree.each_with_index do |branch,index|
40
+ 0.upto(3){|i|
41
+ tree.add(Object,:append,:url=>"/#{i}",:name=>"branch#{i}")
42
+ }
43
+ tree.each_with_index do |branch,index|
39
44
  branch.name.should == "branch#{index}"
40
45
  end
41
46
  end
42
- end
43
47
 
44
- context "callbacks" do
45
- it "should respond to callback #before_load" do
46
- Lolita::Hooks.tree("test").before_load
48
+ it "should itereate in each level" do
49
+ parent_branch=tree.root
50
+ branch=empty_branch
51
+ 0.upto(5){|i|
52
+ parent_branch.append(branch)
53
+ parent_branch=branch
54
+ branch=Lolita::Navigation::Branch.new(Object,:url=>"/")
55
+ }
56
+ level_counter=1
57
+ tree.each_level do |branches,level|
58
+ branches.should have(1).item
59
+ level.should == level_counter
60
+ level_counter+=1
61
+ end
47
62
  end
48
63
  end
49
64
 
50
- it "should add new branch when other branches meet some criteria " do
51
- tree.add(Object,:append,:url=>"/mypath")
52
- tree.each_branch do |branch|
53
- if branch.resource.is_a?(Object)
54
- tree.append(Object,:url=>"/mypath2")
65
+ it "should have callbacks" do
66
+ Lolita::Navigation::Tree.should respond_to(:hooks)
67
+ hook_names=[:before_load,:after_load,:before_branch_added,:after_branch_added]
68
+ (Lolita::Navigation::Tree.hooks - hook_names).should be_empty
69
+ end
70
+
71
+ it "should have way to add branches based on earlier added branches" do
72
+ tree.after_branch_added do
73
+ self.each do |branch|
74
+ if branch.resources.is_a?(Object)
75
+ branch.append(Object,:url=>"/")
76
+ end
55
77
  end
56
78
  end
79
+ tree.add(Object,:append,:url=>"/mypath")
57
80
  tree.should have(2).branches
58
81
  end
59
82
  end
@@ -4,12 +4,9 @@ Mongoid.configure do |config|
4
4
  config.master = Mongo::Connection.new('127.0.0.1', 27017).db("lolita3-test")
5
5
  end
6
6
 
7
- class ActiveSupport::TestCase
8
- setup do
9
- Post.delete_all
10
- Comment.delete_all
11
- Address.delete_all
12
- Preference.delete_all
13
- Profile.delete_all
7
+ # truncate data
8
+ Mongoid.database.collections.each do |collection|
9
+ unless collection.name =~ /^system\./
10
+ collection.remove
14
11
  end
15
12
  end
@@ -4,5 +4,5 @@ class Address
4
4
  field :city
5
5
  field :state
6
6
  field :post_code
7
- embedded_in :person, :inverse_of => :address
7
+ embedded_in :person
8
8
  end
@@ -0,0 +1,6 @@
1
+ class Category
2
+ include Mongoid::Document
3
+ include Lolita::Configuration
4
+ field :name, type: String
5
+ has_many :post
6
+ end
@@ -1,6 +1,6 @@
1
1
  class Comment
2
2
  include Mongoid::Document
3
3
  field :body
4
- referenced_in :post
5
- referenced_in :profile
4
+ belongs_to :post
5
+ belongs_to :profile
6
6
  end
@@ -1,12 +1,16 @@
1
1
  class Post
2
2
  include Mongoid::Document
3
3
  include Lolita::Configuration
4
- field :title, :type => String
5
- field :body, :type => String
6
- field :is_public, :type => Boolean
7
- field :price, :type => BigDecimal
8
- references_many :comments,:class_name=>"Comment"
9
- referenced_in :profile
4
+ field :title, type: String
5
+ field :body, type: String
6
+ field :is_public, type: Boolean
7
+ field :price, type: BigDecimal
8
+ field :published_at, type: DateTime, default: -> { Time.now }
9
+ field :expire_date, type: Date
10
+ belongs_to :category
11
+ has_and_belongs_to_many :tags
12
+ has_many :comments
13
+ belongs_to :profile
10
14
  validates_presence_of :title
11
15
  lolita
12
16
  end
@@ -2,5 +2,5 @@ class Preference
2
2
  include Mongoid::Document
3
3
  include Lolita::Configuration
4
4
  field :name
5
- references_and_referenced_in_many :profiles, :inverse_of=>:preferences
5
+ has_and_belongs_to_many :profiles
6
6
  end
@@ -4,9 +4,9 @@ class Profile
4
4
  field :name, :type=>String
5
5
  field :age
6
6
  field :genere
7
- references_many :posts
8
- references_many :comments
9
- references_and_referenced_in_many :preferences, :inverse_of=>:profiles
7
+ has_many :posts
8
+ has_many :comments
9
+ has_and_belongs_to_many :preferences
10
10
  embeds_one :address
11
11
  lolita do
12
12
 
@@ -0,0 +1,4 @@
1
+ class Tag
2
+ include Mongoid::Document
3
+ field :name
4
+ end
@@ -0,0 +1,3 @@
1
+ Factory.define(:category, :class=>Category) do |f|
2
+ f.name Faker::Name.name
3
+ end
@@ -1,3 +1,4 @@
1
1
  Factory.define(:post, :class=>Post) do |f|
2
2
  f.title Faker::Lorem.sentence
3
+ f.association :category
3
4
  end
@@ -0,0 +1,3 @@
1
+ Factory.define(:tag) do |f|
2
+ f.name Faker::Name.name
3
+ end
metadata CHANGED
@@ -2,16 +2,15 @@
2
2
  name: lolita
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.1.0
5
+ version: 3.1.1
6
6
  platform: ruby
7
7
  authors:
8
- - ITHouse
9
- - Arturs Meisters
8
+ - ITHouse (Latvia) and Arturs Meisters
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
12
 
14
- date: 2011-04-12 00:00:00 +03:00
13
+ date: 2011-04-13 00:00:00 +03:00
15
14
  default_executable:
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
@@ -168,7 +167,7 @@ dependencies:
168
167
  type: :development
169
168
  prerelease: false
170
169
  version_requirements: *id014
171
- description: Great Rails CMS that allow you to start working with models right when you add this to your project.
170
+ description: "Great Rails CMS, that turns your business logic into good-looking, fully functional workspace. "
172
171
  email: support@ithouse.lv
173
172
  executables: []
174
173
 
@@ -179,10 +178,10 @@ extra_rdoc_files:
179
178
  - README.rdoc
180
179
  files:
181
180
  - .document
182
- - .project
183
181
  - .rspec
184
- - GUIDELINE
182
+ - GUIDELINES
185
183
  - Gemfile
184
+ - History.rdoc
186
185
  - IDEA
187
186
  - LICENSE.txt
188
187
  - README.rdoc
@@ -195,11 +194,16 @@ files:
195
194
  - app/views/components/lolita/configuration/field/_label.html.erb
196
195
  - app/views/components/lolita/configuration/field/_object.html.erb
197
196
  - app/views/components/lolita/configuration/field/array/_display.html.erb
197
+ - app/views/components/lolita/configuration/field/array/filter/_display.html.erb
198
198
  - app/views/components/lolita/configuration/field/array/habtm/_display.html.erb
199
199
  - app/views/components/lolita/configuration/field/array/select/_display.html.erb
200
200
  - app/views/components/lolita/configuration/field/big_decimal/_display.html.erb
201
201
  - app/views/components/lolita/configuration/field/boolean/_display.html.erb
202
+ - app/views/components/lolita/configuration/field/boolean/filter/_display.html.erb
202
203
  - app/views/components/lolita/configuration/field/date/_display.html.erb
204
+ - app/views/components/lolita/configuration/field/date_time/_display.html.erb
205
+ - app/views/components/lolita/configuration/field/date_time/date/_display.html.erb
206
+ - app/views/components/lolita/configuration/field/date_time/time/_display.html.erb
203
207
  - app/views/components/lolita/configuration/field/float/_display.html.erb
204
208
  - app/views/components/lolita/configuration/field/integer/_display.html.erb
205
209
  - app/views/components/lolita/configuration/field/string/_display.html.erb
@@ -262,6 +266,7 @@ files:
262
266
  - lib/lolita/configuration/field/big_decimal.rb
263
267
  - lib/lolita/configuration/field/boolean.rb
264
268
  - lib/lolita/configuration/field/date.rb
269
+ - lib/lolita/configuration/field/date_time.rb
265
270
  - lib/lolita/configuration/field/integer.rb
266
271
  - lib/lolita/configuration/field/string.rb
267
272
  - lib/lolita/configuration/field/time.rb
@@ -287,14 +292,14 @@ files:
287
292
  - lib/lolita/mapping.rb
288
293
  - lib/lolita/modules.rb
289
294
  - lib/lolita/modules/rest.rb
290
- - lib/lolita/navigation.rb
295
+ - lib/lolita/navigation/branch.rb
296
+ - lib/lolita/navigation/tree.rb
291
297
  - lib/lolita/observed_array.rb
292
298
  - lib/lolita/rails.rb
293
299
  - lib/lolita/rails/all.rb
294
300
  - lib/lolita/rails/routes.rb
295
301
  - lib/lolita/ruby_ext/accessors.rb
296
302
  - lib/lolita/test/matchers.rb
297
- - log/development.log
298
303
  - lolita.gemspec
299
304
  - public/images/lolita/plus.png
300
305
  - public/javascripts/jquery-1.5.1.min.js
@@ -377,10 +382,12 @@ files:
377
382
  - spec/rails_app/app/controllers/application_controller.rb
378
383
  - spec/rails_app/app/helpers/application_helper.rb
379
384
  - spec/rails_app/app/mongoid/address.rb
385
+ - spec/rails_app/app/mongoid/category.rb
380
386
  - spec/rails_app/app/mongoid/comment.rb
381
387
  - spec/rails_app/app/mongoid/post.rb
382
388
  - spec/rails_app/app/mongoid/preference.rb
383
389
  - spec/rails_app/app/mongoid/profile.rb
390
+ - spec/rails_app/app/mongoid/tag.rb
384
391
  - spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb
385
392
  - spec/rails_app/config/application.rb
386
393
  - spec/rails_app/config/boot.rb
@@ -456,9 +463,9 @@ files:
456
463
  - spec/routing/routes_spec.rb
457
464
  - spec/simple_spec_helper.rb
458
465
  - spec/spec_helper.rb
466
+ - spec/support/factories/category.rb
459
467
  - spec/support/factories/post.rb
460
- - test/cells/form_cell_test.rb
461
- - test/test_helper.rb
468
+ - spec/support/factories/tag.rb
462
469
  has_rdoc: true
463
470
  homepage: http://github.com/ithouse/lolita
464
471
  licenses:
@@ -473,7 +480,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
473
480
  requirements:
474
481
  - - ">="
475
482
  - !ruby/object:Gem::Version
476
- hash: -659089805
483
+ hash: -453610993
477
484
  segments:
478
485
  - 0
479
486
  version: "0"
@@ -514,10 +521,12 @@ test_files:
514
521
  - spec/rails_app/app/controllers/application_controller.rb
515
522
  - spec/rails_app/app/helpers/application_helper.rb
516
523
  - spec/rails_app/app/mongoid/address.rb
524
+ - spec/rails_app/app/mongoid/category.rb
517
525
  - spec/rails_app/app/mongoid/comment.rb
518
526
  - spec/rails_app/app/mongoid/post.rb
519
527
  - spec/rails_app/app/mongoid/preference.rb
520
528
  - spec/rails_app/app/mongoid/profile.rb
529
+ - spec/rails_app/app/mongoid/tag.rb
521
530
  - spec/rails_app/config/application.rb
522
531
  - spec/rails_app/config/boot.rb
523
532
  - spec/rails_app/config/environment.rb
@@ -534,6 +543,6 @@ test_files:
534
543
  - spec/routing/routes_spec.rb
535
544
  - spec/simple_spec_helper.rb
536
545
  - spec/spec_helper.rb
546
+ - spec/support/factories/category.rb
537
547
  - spec/support/factories/post.rb
538
- - test/cells/form_cell_test.rb
539
- - test/test_helper.rb
548
+ - spec/support/factories/tag.rb
data/.project DELETED
@@ -1,17 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>lolita3</name>
4
- <comment></comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- <buildCommand>
9
- <name>com.aptana.ide.core.unifiedBuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
- </buildSpec>
14
- <natures>
15
- <nature>com.aptana.ruby.core.rubynature</nature>
16
- </natures>
17
- </projectDescription>
@@ -1,48 +0,0 @@
1
- module Lolita
2
- module Navigation
3
-
4
- class Tree
5
- include Lolita::ObservedArray
6
-
7
- def initialize
8
- @branches=[]
9
- end
10
-
11
- private
12
-
13
- def collection_variable
14
- @branches
15
- end
16
-
17
- def build_element element,*args
18
- if element.is_a?(Lolita::Navigation::Branch)
19
- element
20
- else
21
- Lolita::Navigation::Branch.new(*args)
22
- end
23
- end
24
- end #base class end
25
-
26
- #
27
- # c_branch=Branch.new(:category)
28
- # c_branch.mapping == Lolita.mappings[:category] #=>true
29
- # c.branch.resource == Lolita.mappings[:category].to #=>true
30
- # Branch.new(:page, :path=>{:action=>:new},:after=>Navigation.by_name(:category,:level=>1))
31
- # Branch.new(:user,:prepend=>Navigation.root || {:level=>0} || 0)
32
- # Branch.new(
33
- # Proc.new{|resource| resource.lolita.reports.by_name("statistic")},
34
- # :append=>Navigation.by_name(:category,:level=>1),
35
- # :path=>{:action=>:report,:plural=>true}
36
- # )
37
- class Branch
38
- attr_reader :name
39
-
40
- def initialize(*args)
41
- options=args.extract_options!
42
- @name=args.first
43
-
44
- end
45
- end #branch class end
46
-
47
- end
48
- end
File without changes
@@ -1,15 +0,0 @@
1
- # To change this template, choose Tools | Templates
2
- # and open the template in the editor.
3
-
4
- $:.unshift File.join(File.dirname(__FILE__),'..','lib')
5
-
6
- require 'test/unit'
7
- require 'form_cell'
8
-
9
- class FormCellTest < Test::Unit::TestCase
10
- def test_foo
11
- #TODO: Write test
12
- flunk "TODO: Write test"
13
- # assert_equal("foo", bar)
14
- end
15
- end
@@ -1,2 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
-