fusionary-easel_helpers 0.2.4 → 0.2.5
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.
- data/Rakefile +1 -1
- data/easel_helpers.gemspec +2 -2
- data/lib/easel_helpers/helpers/flash_helper.rb +15 -2
- data/lib/easel_helpers/helpers/grid_helper.rb +4 -4
- data/test/flash_helper_test.rb +25 -4
- data/test/grid_helper_test.rb +145 -114
- metadata +2 -2
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
|
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new("easel_helpers", "0.2.
|
6
|
+
Echoe.new("easel_helpers", "0.2.5") do |p|
|
7
7
|
p.description = "Fusionary Rails View Helpers"
|
8
8
|
p.url = "http://github.com/fusionary/easel_helpers"
|
9
9
|
p.author = "Joshua Clayton"
|
data/easel_helpers.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{easel_helpers}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Joshua Clayton"]
|
9
|
-
s.date = %q{2009-05-
|
9
|
+
s.date = %q{2009-05-22}
|
10
10
|
s.description = %q{Fusionary Rails View Helpers}
|
11
11
|
s.email = %q{joshua.clayton@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/flash_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/structure_helper.rb", "lib/easel_helpers/helpers/table_helper.rb", "lib/easel_helpers/helpers.rb", "lib/easel_helpers/rails_partial_caching.rb", "lib/easel_helpers.rb", "README.textile", "tasks/easel_helpers_tasks.rake"]
|
@@ -2,8 +2,21 @@ module EaselHelpers
|
|
2
2
|
module Helpers
|
3
3
|
module FlashHelper
|
4
4
|
|
5
|
-
def render_flash(flash)
|
6
|
-
|
5
|
+
def render_flash(flash, options = {})
|
6
|
+
except_keys = [options[:except]].flatten.compact
|
7
|
+
only_keys = [options[:only]].flatten.compact
|
8
|
+
|
9
|
+
raise ArgumentError, ":only and :except options conflict; use one or the other" if except_keys.any? && only_keys.any?
|
10
|
+
|
11
|
+
keys = if except_keys.any?
|
12
|
+
flash.keys - except_keys
|
13
|
+
elsif only_keys.any?
|
14
|
+
flash.keys & only_keys
|
15
|
+
else
|
16
|
+
flash.keys
|
17
|
+
end
|
18
|
+
|
19
|
+
keys.map do |key|
|
7
20
|
content_tag :p, flash[key], :class => [key, "box", "single-line"].join(" ") unless flash[key].blank?
|
8
21
|
end.join
|
9
22
|
end
|
@@ -34,9 +34,9 @@ module EaselHelpers
|
|
34
34
|
"col-last"
|
35
35
|
end
|
36
36
|
|
37
|
-
def column(
|
37
|
+
def column(*args, &block)
|
38
38
|
@_easel_column_count ||= application_width
|
39
|
-
col(
|
39
|
+
col(*args, &block)
|
40
40
|
end
|
41
41
|
|
42
42
|
def container(size=nil, *args, &block)
|
@@ -107,8 +107,8 @@ module EaselHelpers
|
|
107
107
|
@_easel_current_width.pop
|
108
108
|
end
|
109
109
|
|
110
|
-
def col(
|
111
|
-
size =
|
110
|
+
def col(*args, &block)
|
111
|
+
size = (MULTIPLE_FRACTIONS.include?(args.first.to_s) || args.first.is_a?(Integer)) ? args.shift : :full
|
112
112
|
|
113
113
|
increase_depth(size)
|
114
114
|
output_tag = generate_output_tag(size, *args, &block)
|
data/test/flash_helper_test.rb
CHANGED
@@ -12,18 +12,39 @@ class FlashHelperTest < EaselHelpers::ViewTestCase
|
|
12
12
|
|
13
13
|
should "display all flash messages present" do
|
14
14
|
show_view %(<%= render_flash(:structure => "Flash message", :error => "Warning message") %>) do
|
15
|
-
assert_select "p.structure
|
16
|
-
assert_select "p.error
|
15
|
+
assert_select "p.structure", "Flash message"
|
16
|
+
assert_select "p.error", "Warning message"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
should "not display a flash if it is blank" do
|
21
21
|
show_view %(<%= render_flash(:structure => "", :error => nil) %>) do
|
22
|
-
assert_select "p.structure
|
23
|
-
assert_select "p.error
|
22
|
+
assert_select "p.structure", false
|
23
|
+
assert_select "p.error", false
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
should "filter by the :only option" do
|
28
|
+
show_view %(<%= render_flash({:structure => "Flash message", :error => "Warning message", :notice => "Notice!"}, {:only => [:structure, :error]}) %>) do
|
29
|
+
assert_select "p.structure", "Flash message"
|
30
|
+
assert_select "p.error", "Warning message"
|
31
|
+
assert_select "p.notice", false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
should "filter by the :except option" do
|
36
|
+
show_view %(<%= render_flash({:structure => "Flash message", :error => "Warning message", :notice => "Notice!"}, {:except => [:structure, :error]}) %>) do
|
37
|
+
assert_select "p.structure", false
|
38
|
+
assert_select "p.error", false
|
39
|
+
assert_select "p.notice", "Notice!"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
should "raise an error of :only and :except are both passed" do
|
44
|
+
assert_raise ArgumentError, /conflict/ do
|
45
|
+
show_view %(<%= render_flash({:structure => "Flash message"}, {:except => [:structure, :error], :only => :structure}) %>)
|
46
|
+
end
|
47
|
+
end
|
27
48
|
end
|
28
49
|
|
29
50
|
end
|
data/test/grid_helper_test.rb
CHANGED
@@ -1,148 +1,179 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class GridHelperTest < EaselHelpers::ViewTestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
|
5
|
+
context "advanced grid structures" do
|
6
|
+
|
7
|
+
should "properly assign classes for a simple column layout" do
|
8
|
+
template = %(
|
9
|
+
<% container do %>
|
10
|
+
<% column do %>
|
11
|
+
<% column :half, :id => "primary" do %>
|
12
|
+
<% column :one_third do %>
|
13
|
+
one third of one half of 24 is 4
|
14
|
+
<% end %>
|
15
|
+
<% column :one_third, :last, prepend_one_third do %>
|
16
|
+
one third of one half of 24 is 4 (but prepended 4 as well)
|
17
|
+
<% end %>
|
18
|
+
<hr/>
|
19
|
+
more text
|
11
20
|
<% end %>
|
12
|
-
<% column :
|
13
|
-
|
21
|
+
<% column :half, :last, :id => "secondary" do %>
|
22
|
+
second column
|
14
23
|
<% end %>
|
15
24
|
<hr/>
|
16
|
-
|
17
|
-
<% end %>
|
18
|
-
<% column :half, :last, :id => "secondary" do %>
|
19
|
-
second column
|
25
|
+
text
|
20
26
|
<% end %>
|
21
|
-
<hr/>
|
22
|
-
text
|
23
27
|
<% end %>
|
24
|
-
|
25
|
-
|
28
|
+
)
|
29
|
+
|
30
|
+
show_view template do
|
31
|
+
assert_select ".container", 1
|
32
|
+
assert_select ".col-24", 1
|
33
|
+
assert_select ".col-12", 2
|
34
|
+
assert_select ".col-12#primary", 1
|
35
|
+
assert_select ".col-12#secondary", 1
|
36
|
+
assert_select ".col-4", 2
|
37
|
+
assert_select ".prepend-4", 1
|
38
|
+
assert_select ".col-24.col-last", 0
|
39
|
+
assert_select ".col-12.col-last", 1
|
40
|
+
assert_select ".col-4.col-last", 1
|
41
|
+
assert_select "hr", 2
|
42
|
+
end
|
43
|
+
end
|
26
44
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
should "properly assign classes for generic helpers" do
|
46
|
+
template = %(
|
47
|
+
<% column do %>
|
48
|
+
<% fieldset :hform, :half do %>
|
49
|
+
<% set :one_third do %>text<% end %>
|
50
|
+
<% set :two_thirds, :last do %>more text<% end %>
|
51
|
+
<% end %>
|
52
|
+
<% recordset :half, :last do %>table<% end %>
|
53
|
+
<% end %>
|
54
|
+
)
|
55
|
+
|
56
|
+
show_view template do
|
57
|
+
assert_select "div.col-24" do
|
58
|
+
assert_select "fieldset.hform.col-12" do
|
59
|
+
assert_select "div.col-4", "text"
|
60
|
+
assert_select "div.col-8.col-last", "more text"
|
61
|
+
end
|
62
|
+
assert_select "table.col-12.col-last", "table"
|
63
|
+
end
|
64
|
+
end
|
39
65
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
template = %(
|
44
|
-
<% column do %>
|
66
|
+
|
67
|
+
should "properly assign classes for generic helpers without column wrappers" do
|
68
|
+
template = %(
|
45
69
|
<% fieldset :hform, :half do %>
|
46
70
|
<% set :one_third do %>text<% end %>
|
47
71
|
<% set :two_thirds, :last do %>more text<% end %>
|
72
|
+
<% column do %>
|
73
|
+
<% column :one_third do %>one third<% end %>
|
74
|
+
<% column :two_thirds, :last do %>
|
75
|
+
<% column :half do %>half<% end %>
|
76
|
+
<% column :half, :last do %>last half<% end %>
|
77
|
+
<% end %>
|
78
|
+
<% end %>
|
48
79
|
<% end %>
|
49
|
-
<%
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
80
|
+
<% column :one_third do %>
|
81
|
+
<% column :one_fourth do %>two wide<% end %>
|
82
|
+
<% column :half do %>four wide<% end %>
|
83
|
+
<% column :one_fourth, :last do %>two more wide<% end %>
|
84
|
+
<% end %>
|
85
|
+
<% recordset :one_sixth, :last do %>table<% end %>
|
86
|
+
)
|
87
|
+
|
88
|
+
show_view template do
|
55
89
|
assert_select "fieldset.hform.col-12" do
|
56
90
|
assert_select "div.col-4", "text"
|
57
91
|
assert_select "div.col-8.col-last", "more text"
|
92
|
+
|
93
|
+
assert_select "div.col-12.col-last" do
|
94
|
+
assert_select "div.col-4", "one third"
|
95
|
+
assert_select "div.col-8.col-last" do
|
96
|
+
assert_select "div.col-4", "half"
|
97
|
+
assert_select "div.col-4.col-last", "last half"
|
98
|
+
end
|
99
|
+
end
|
58
100
|
end
|
59
|
-
assert_select "
|
101
|
+
assert_select "div.col-8" do
|
102
|
+
assert_select "div.col-2", "two wide"
|
103
|
+
assert_select "div.col-4", "four wide"
|
104
|
+
assert_select "div.col-2.col-last", "two more wide"
|
105
|
+
end
|
106
|
+
assert_select "table.col-4.col-last", "table"
|
60
107
|
end
|
61
108
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
109
|
+
|
110
|
+
should "properly assign classes for a deeply-nested view" do
|
111
|
+
template = %(
|
112
|
+
<% container do %>
|
113
|
+
<% column :half do %>
|
114
|
+
<% fieldset :hform, :half do %>
|
115
|
+
<% set :one_third do %>text<% end %>
|
116
|
+
<% set :two_thirds, :last do %>more text<% end %>
|
117
|
+
<% end %>
|
118
|
+
<% recordset :half, :last do %>table<% end %>
|
119
|
+
<% end %>
|
120
|
+
<% column :one_third do %>one third!<% end %>
|
121
|
+
<% column :one_sixth, :last do %>
|
122
|
+
<% fieldset :vform, :full do %>
|
123
|
+
<% set do %>text<% end %>
|
124
|
+
<% end %>
|
74
125
|
<% end %>
|
75
126
|
<% end %>
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
assert_select "div.col-4.col-last", "last half"
|
127
|
+
)
|
128
|
+
|
129
|
+
show_view template do
|
130
|
+
assert_select "div.container" do
|
131
|
+
assert_select "div.col-12" do
|
132
|
+
assert_select "fieldset.hform.col-6" do
|
133
|
+
assert_select "div.col-2", "text"
|
134
|
+
assert_select "div.col-4.col-last", "more text"
|
135
|
+
end
|
136
|
+
assert_select "table.col-6.col-last", "table"
|
137
|
+
end
|
138
|
+
|
139
|
+
assert_select "div.col-8", "one third!"
|
140
|
+
|
141
|
+
assert_select "div.col-4.col-last" do
|
142
|
+
assert_select "fieldset.vform.col-4.col-last" do
|
143
|
+
assert_select "div", "text"
|
144
|
+
end
|
95
145
|
end
|
96
146
|
end
|
97
147
|
end
|
98
|
-
assert_select "div.col-8" do
|
99
|
-
assert_select "div.col-2", "two wide"
|
100
|
-
assert_select "div.col-4", "four wide"
|
101
|
-
assert_select "div.col-2.col-last", "two more wide"
|
102
|
-
end
|
103
|
-
assert_select "table.col-4.col-last", "table"
|
104
148
|
end
|
149
|
+
|
105
150
|
end
|
106
151
|
|
107
|
-
|
108
|
-
template = %(
|
109
|
-
<% container do %>
|
110
|
-
<% column :half do %>
|
111
|
-
<% fieldset :hform, :half do %>
|
112
|
-
<% set :one_third do %>text<% end %>
|
113
|
-
<% set :two_thirds, :last do %>more text<% end %>
|
114
|
-
<% end %>
|
115
|
-
<% recordset :half, :last do %>table<% end %>
|
116
|
-
<% end %>
|
117
|
-
<% column :one_third do %>one third!<% end %>
|
118
|
-
<% column :one_sixth, :last do %>
|
119
|
-
<% fieldset :vform, :full do %>
|
120
|
-
<% set do %>text<% end %>
|
121
|
-
<% end %>
|
122
|
-
<% end %>
|
123
|
-
<% end %>
|
124
|
-
)
|
152
|
+
context "column" do
|
125
153
|
|
126
|
-
|
127
|
-
|
128
|
-
assert_select "div.col-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
154
|
+
should "allow assigning options hash without having to define a width" do
|
155
|
+
show_view %(<% column :id => "my-custom-id", :class => "content" do %>words<% end %>) do
|
156
|
+
assert_select "div.col-24.content#my-custom-id", "words"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
should "allow explicit column assignment" do
|
161
|
+
show_view %(
|
162
|
+
<% column 6, :sidebar do %>
|
163
|
+
<% column :id => "main" do %>main sidebar<% end %>
|
164
|
+
<% column :half do %>three<% end %>
|
165
|
+
<% column :one_third do %>two<% end %>
|
166
|
+
<% column 1, :last do %>one<% end %>
|
167
|
+
<% end %>
|
168
|
+
) do
|
169
|
+
assert_select "div.col-6.sidebar" do
|
170
|
+
assert_select "div.col-6.col-last#main", "main sidebar"
|
171
|
+
assert_select "div.col-3", "three"
|
172
|
+
assert_select "div.col-2", "two"
|
173
|
+
assert_select "div.col-1.col-last", "one"
|
142
174
|
end
|
143
|
-
|
144
175
|
end
|
145
176
|
end
|
177
|
+
|
146
178
|
end
|
147
|
-
|
148
179
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fusionary-easel_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Clayton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-22 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|