adva_cells 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/adva_cells.gemspec +20 -0
- data/app/cells/base_cell.rb +83 -0
- data/app/controllers/admin/cells_controller.rb +10 -0
- data/app/helpers/contact_mailer_helper.rb +7 -0
- data/config/routes.rb +6 -0
- data/lib/adva_cells.rb +13 -0
- data/lib/adva_cells/version.rb +3 -0
- data/lib/cells_ext.rb +18 -0
- data/lib/contact_mail_form_builder.rb +178 -0
- data/lib/output_filter/cells.rb +48 -0
- data/test/integration/article_with_contact_mailer_test.rb +81 -0
- data/test/test_helper.rb +11 -0
- data/test/unit/album_cell_test.rb +48 -0
- data/test/unit/base_cell_test.rb +83 -0
- data/test/unit/blog_cell_test.rb +27 -0
- data/test/unit/contact_mailer_cell_test.rb +43 -0
- data/test/unit/content_cell_test.rb +33 -0
- data/test/unit/helpers/contact_mail_helper_test.rb +84 -0
- data/test/unit/lib/contact_mail_form_builder_test.rb +288 -0
- data/test/unit/lib/output_filter/cells_test.rb +46 -0
- data/test/unit/section_cell_test.rb +30 -0
- data/test/unit/user_cell_test.rb +27 -0
- metadata +110 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
class CellsOutputFilterTest < ActionController::TestCase
|
4
|
+
tests BaseController
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@html = <<-html
|
9
|
+
<html>
|
10
|
+
<body>
|
11
|
+
<cell name="blog/best_articles" section_id="1" count="10" />
|
12
|
+
<cell name="blog/recent_articles" section_id="1" count="5" />
|
13
|
+
<cell name="blog/related_articles" count="5"><section>Company blog</section></cell>
|
14
|
+
something>invalid
|
15
|
+
</body>
|
16
|
+
</html>
|
17
|
+
html
|
18
|
+
|
19
|
+
@cells = {
|
20
|
+
'<cell name="blog/best_articles" section_id="1" count="10" />' =>
|
21
|
+
['blog', 'best_articles', {'section_id' => '1', 'count' => '10'}],
|
22
|
+
'<cell name="blog/recent_articles" section_id="1" count="5" />' =>
|
23
|
+
['blog', 'recent_articles', {'section_id' => '1', 'count' => '5'}],
|
24
|
+
'<cell name="blog/related_articles" count="5"><section>Company blog</section></cell>' =>
|
25
|
+
['blog', 'related_articles', {'section' => 'Company blog', 'count' => '5'}]
|
26
|
+
}
|
27
|
+
|
28
|
+
@filter = OutputFilter::Cells.new
|
29
|
+
@parser = OutputFilter::Cells::SimpleParser.new
|
30
|
+
|
31
|
+
@controller.response = ActionController::TestResponse.new
|
32
|
+
@controller.response.body = @html
|
33
|
+
end
|
34
|
+
|
35
|
+
test "#after renders the cells and replaces the cell tags with rendering results" do
|
36
|
+
@cells.each do |tag, cell|
|
37
|
+
mock(@controller.response.template).render_cell(*cell).returns 'cell rendered'
|
38
|
+
end
|
39
|
+
@filter.after(@controller)
|
40
|
+
@controller.response.body.scan(/cell rendered/).size.should == 3
|
41
|
+
end
|
42
|
+
|
43
|
+
test "SimpleParser#cells returns an array with cell/state and attributes" do
|
44
|
+
@parser.cells(@html).should == @cells
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class SectionCellTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@controller = CellTestController.new
|
7
|
+
@cell = SectionsCell.new(@controller)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "#recent_articles sets the articles from latest 5 articles, ordered by 'published_at DESC' as a default,
|
11
|
+
scoped by 'with_sections_scope(Article)'" do
|
12
|
+
@cell.recent_articles
|
13
|
+
@cell.instance_variable_get(:@articles).should == recent_articles
|
14
|
+
end
|
15
|
+
|
16
|
+
test "#recent_articles article amount can be altered by @opts[:count]" do
|
17
|
+
@cell.instance_variable_set(:@opts, { :count => 1 })
|
18
|
+
@cell.recent_articles
|
19
|
+
@cell.instance_variable_get(:@articles).should == recent_articles("published_at DESC", 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
# FIXME test the cached_references
|
23
|
+
# FIXME test the has_state option
|
24
|
+
|
25
|
+
def recent_articles(order = "published_at DESC", limit = 5)
|
26
|
+
@cell.send(:with_sections_scope, Article) do
|
27
|
+
Article.order(order).limit(limit)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class UserCellTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
@controller = CellTestController.new
|
7
|
+
@cell = UserCell.new(@controller)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "#recent sets the users from latest 5 users, ordered by 'id DESC' as a default" do
|
11
|
+
@cell.recent
|
12
|
+
@cell.instance_variable_get(:@users).should == recent_users
|
13
|
+
end
|
14
|
+
|
15
|
+
test "#recent user amount can be altered by @opts[:count]" do
|
16
|
+
@cell.instance_variable_set(:@opts, { :count => 1 })
|
17
|
+
@cell.recent
|
18
|
+
@cell.instance_variable_get(:@users).should == recent_users("id DESC", 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
# FIXME test the cached_references
|
22
|
+
# FIXME test the has_state option
|
23
|
+
|
24
|
+
def recent_users(order = "id DESC", limit = 5)
|
25
|
+
User.order(order).limit(limit)
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adva_cells
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Micah Geisel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cells
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tilt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Adva Cells
|
42
|
+
email:
|
43
|
+
- micah@botandrose.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- adva_cells.gemspec
|
54
|
+
- app/cells/base_cell.rb
|
55
|
+
- app/controllers/admin/cells_controller.rb
|
56
|
+
- app/helpers/contact_mailer_helper.rb
|
57
|
+
- config/routes.rb
|
58
|
+
- lib/adva_cells.rb
|
59
|
+
- lib/adva_cells/version.rb
|
60
|
+
- lib/cells_ext.rb
|
61
|
+
- lib/contact_mail_form_builder.rb
|
62
|
+
- lib/output_filter/cells.rb
|
63
|
+
- test/integration/article_with_contact_mailer_test.rb
|
64
|
+
- test/test_helper.rb
|
65
|
+
- test/unit/album_cell_test.rb
|
66
|
+
- test/unit/base_cell_test.rb
|
67
|
+
- test/unit/blog_cell_test.rb
|
68
|
+
- test/unit/contact_mailer_cell_test.rb
|
69
|
+
- test/unit/content_cell_test.rb
|
70
|
+
- test/unit/helpers/contact_mail_helper_test.rb
|
71
|
+
- test/unit/lib/contact_mail_form_builder_test.rb
|
72
|
+
- test/unit/lib/output_filter/cells_test.rb
|
73
|
+
- test/unit/section_cell_test.rb
|
74
|
+
- test/unit/user_cell_test.rb
|
75
|
+
homepage: ''
|
76
|
+
licenses: []
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Engine for Adva CMS embedable cells
|
98
|
+
test_files:
|
99
|
+
- test/integration/article_with_contact_mailer_test.rb
|
100
|
+
- test/test_helper.rb
|
101
|
+
- test/unit/album_cell_test.rb
|
102
|
+
- test/unit/base_cell_test.rb
|
103
|
+
- test/unit/blog_cell_test.rb
|
104
|
+
- test/unit/contact_mailer_cell_test.rb
|
105
|
+
- test/unit/content_cell_test.rb
|
106
|
+
- test/unit/helpers/contact_mail_helper_test.rb
|
107
|
+
- test/unit/lib/contact_mail_form_builder_test.rb
|
108
|
+
- test/unit/lib/output_filter/cells_test.rb
|
109
|
+
- test/unit/section_cell_test.rb
|
110
|
+
- test/unit/user_cell_test.rb
|