fusionary-easel_helpers 0.2.16 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +2 -0
- data/Rakefile +1 -1
- data/easel_helpers.gemspec +5 -5
- data/lib/easel_helpers/helpers/form_helper.rb +4 -4
- data/lib/easel_helpers/helpers/navigation_helper.rb +29 -0
- data/lib/easel_helpers/helpers.rb +3 -1
- data/test/date_helper_test.rb +13 -13
- data/test/form_helper_test.rb +24 -24
- data/test/jquery_helper_test.rb +8 -8
- data/test/link_helper_test.rb +8 -8
- data/test/message_helper_test.rb +9 -9
- data/test/navigation_helper_test.rb +130 -0
- data/test/rjs_helper_test.rb +7 -7
- data/test/table_helper_test.rb +14 -14
- data/test/test_helper.rb +4 -4
- metadata +6 -2
data/Manifest
CHANGED
@@ -5,6 +5,7 @@ lib/easel_helpers/helpers/grid_helper.rb
|
|
5
5
|
lib/easel_helpers/helpers/jquery_helper.rb
|
6
6
|
lib/easel_helpers/helpers/link_helper.rb
|
7
7
|
lib/easel_helpers/helpers/message_helper.rb
|
8
|
+
lib/easel_helpers/helpers/navigation_helper.rb
|
8
9
|
lib/easel_helpers/helpers/rjs_helper.rb
|
9
10
|
lib/easel_helpers/helpers/structure_helper.rb
|
10
11
|
lib/easel_helpers/helpers/table_helper.rb
|
@@ -23,6 +24,7 @@ test/grid_helper_test.rb
|
|
23
24
|
test/jquery_helper_test.rb
|
24
25
|
test/link_helper_test.rb
|
25
26
|
test/message_helper_test.rb
|
27
|
+
test/navigation_helper_test.rb
|
26
28
|
test/rjs_helper_test.rb
|
27
29
|
test/structure_helper_test.rb
|
28
30
|
test/table_helper_test.rb
|
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.17") 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,15 +2,15 @@
|
|
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.17"
|
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-07-
|
9
|
+
s.date = %q{2009-07-26}
|
10
10
|
s.description = %q{Fusionary Rails View Helpers}
|
11
11
|
s.email = %q{joshua.clayton@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/jquery_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/message_helper.rb", "lib/easel_helpers/helpers/rjs_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"]
|
13
|
-
s.files = ["easel_helpers.gemspec", "lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/jquery_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/message_helper.rb", "lib/easel_helpers/helpers/rjs_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", "Manifest", "MIT-LICENSE", "rails/init.rb", "Rakefile", "README.textile", "tasks/easel_helpers_tasks.rake", "test/date_helper_test.rb", "test/form_helper_test.rb", "test/grid_helper_test.rb", "test/jquery_helper_test.rb", "test/link_helper_test.rb", "test/message_helper_test.rb", "test/rjs_helper_test.rb", "test/structure_helper_test.rb", "test/table_helper_test.rb", "test/test_helper.rb"]
|
12
|
+
s.extra_rdoc_files = ["lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/jquery_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/message_helper.rb", "lib/easel_helpers/helpers/navigation_helper.rb", "lib/easel_helpers/helpers/rjs_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"]
|
13
|
+
s.files = ["easel_helpers.gemspec", "lib/easel_helpers/helpers/date_helper.rb", "lib/easel_helpers/helpers/form_helper.rb", "lib/easel_helpers/helpers/grid_helper.rb", "lib/easel_helpers/helpers/jquery_helper.rb", "lib/easel_helpers/helpers/link_helper.rb", "lib/easel_helpers/helpers/message_helper.rb", "lib/easel_helpers/helpers/navigation_helper.rb", "lib/easel_helpers/helpers/rjs_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", "Manifest", "MIT-LICENSE", "rails/init.rb", "Rakefile", "README.textile", "tasks/easel_helpers_tasks.rake", "test/date_helper_test.rb", "test/form_helper_test.rb", "test/grid_helper_test.rb", "test/jquery_helper_test.rb", "test/link_helper_test.rb", "test/message_helper_test.rb", "test/navigation_helper_test.rb", "test/rjs_helper_test.rb", "test/structure_helper_test.rb", "test/table_helper_test.rb", "test/test_helper.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://github.com/fusionary/easel_helpers}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Easel_helpers", "--main", "README.textile"]
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.rubyforge_project = %q{easel_helpers}
|
19
19
|
s.rubygems_version = %q{1.3.2}
|
20
20
|
s.summary = %q{Fusionary Rails View Helpers}
|
21
|
-
s.test_files = ["test/date_helper_test.rb", "test/form_helper_test.rb", "test/grid_helper_test.rb", "test/jquery_helper_test.rb", "test/link_helper_test.rb", "test/message_helper_test.rb", "test/rjs_helper_test.rb", "test/structure_helper_test.rb", "test/table_helper_test.rb", "test/test_helper.rb"]
|
21
|
+
s.test_files = ["test/date_helper_test.rb", "test/form_helper_test.rb", "test/grid_helper_test.rb", "test/jquery_helper_test.rb", "test/link_helper_test.rb", "test/message_helper_test.rb", "test/navigation_helper_test.rb", "test/rjs_helper_test.rb", "test/structure_helper_test.rb", "test/table_helper_test.rb", "test/test_helper.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -7,7 +7,7 @@ module EaselHelpers
|
|
7
7
|
css_classes = ["btn"] << options.delete(:class) << args
|
8
8
|
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
9
9
|
|
10
|
-
content_tag :button,
|
10
|
+
content_tag :button,
|
11
11
|
"<span>#{value}</span>",
|
12
12
|
{ :value => value,
|
13
13
|
:type => "submit",
|
@@ -24,7 +24,7 @@ module EaselHelpers
|
|
24
24
|
end
|
25
25
|
|
26
26
|
if standardize_css_classes(css_classes).include?("textarea")
|
27
|
-
css_classes << "text"
|
27
|
+
css_classes << "text"
|
28
28
|
end
|
29
29
|
|
30
30
|
css_classes = clean_css_classes(css_classes, {"last" => last_column})
|
@@ -47,8 +47,8 @@ module EaselHelpers
|
|
47
47
|
else
|
48
48
|
legend_opts = options.delete(:legend) || {}
|
49
49
|
legend_classes = clean_css_classes([legend_opts.delete(:class)] << "legend")
|
50
|
-
content_tag :h3,
|
51
|
-
title,
|
50
|
+
content_tag :h3,
|
51
|
+
title,
|
52
52
|
{:class => legend_classes}.merge(legend_opts)
|
53
53
|
end
|
54
54
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module EaselHelpers
|
2
|
+
module Helpers
|
3
|
+
module NavigationHelper
|
4
|
+
def tab(name, path, options = {}, li_options = {})
|
5
|
+
opts = parse_tab_options(name, li_options)
|
6
|
+
|
7
|
+
active = "active" if (opts[:active] == opts[:comparison]) || opts[:compare]
|
8
|
+
css_classes = [] << opts[:li_classes] << active
|
9
|
+
css_classes = clean_css_classes(css_classes)
|
10
|
+
li_options.merge!(:class => css_classes) unless css_classes.blank?
|
11
|
+
|
12
|
+
content_tag :li,
|
13
|
+
link_to(name, path, options),
|
14
|
+
li_options
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_tab_options(name, li_options = {})
|
20
|
+
returning({}) do |result|
|
21
|
+
result[:active] = li_options.delete(:active) || (name.gsub(/\s/, '').tableize || "")
|
22
|
+
result[:comparison] = li_options.delete(:active_compare) || controller.controller_name
|
23
|
+
result[:compare] = li_options.delete(:compare) || false
|
24
|
+
result[:li_classes] = li_options.delete(:class)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -7,6 +7,7 @@ require "easel_helpers/helpers/grid_helper"
|
|
7
7
|
require "easel_helpers/helpers/message_helper"
|
8
8
|
require "easel_helpers/helpers/rjs_helper"
|
9
9
|
require "easel_helpers/helpers/jquery_helper"
|
10
|
+
require "easel_helpers/helpers/navigation_helper"
|
10
11
|
|
11
12
|
module EaselHelpers
|
12
13
|
module Helpers
|
@@ -19,6 +20,7 @@ module EaselHelpers
|
|
19
20
|
include MessageHelper
|
20
21
|
include RjsHelper
|
21
22
|
include JqueryHelper
|
23
|
+
include NavigationHelper
|
22
24
|
|
23
25
|
protected
|
24
26
|
|
@@ -45,7 +47,7 @@ module EaselHelpers
|
|
45
47
|
css_classes.delete(fraction)
|
46
48
|
css_classes << self.send(fraction)
|
47
49
|
if fraction == "full" && @_easel_column_count != application_width
|
48
|
-
css_classes << last_column
|
50
|
+
css_classes << last_column
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
data/test/date_helper_test.rb
CHANGED
@@ -2,58 +2,58 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class DateHelperTest < ActiveSupport::TestCase
|
4
4
|
include EaselHelpers::Helpers::DateHelper
|
5
|
-
|
5
|
+
|
6
6
|
context "datetime helper" do
|
7
7
|
should "default to an empty string if date is not supplied" do
|
8
8
|
assert_equal "", datetime(nil)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
should "default to passed default text if date is not supplied" do
|
12
12
|
assert_equal "default text", datetime(nil, "default text")
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
should "default to :long format for date" do
|
16
16
|
timestamp = Time.now
|
17
17
|
assert_equal timestamp.to_s(:long), datetime(timestamp)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
should "use passed format if applicable" do
|
21
21
|
timestamp = Time.now
|
22
22
|
assert_equal timestamp.to_s(:short), datetime(timestamp, "", :short)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
should "convert passed data to a time" do
|
26
26
|
datestamp = Date.today
|
27
27
|
timestamp = datestamp.to_time
|
28
28
|
assert_equal timestamp.to_s(:long), datetime(datestamp)
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
context "date helper" do
|
33
33
|
should "default to an empty string if date is not supplied" do
|
34
34
|
assert_equal "", date(nil)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
should "default to passed default text if date is not supplied" do
|
38
38
|
assert_equal "default text", date(nil, "default text")
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
should "default to :long format for date" do
|
42
42
|
datestamp = Date.today
|
43
43
|
assert_equal datestamp.to_s(:long), date(datestamp)
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
should "use passed format if applicable" do
|
47
47
|
datestamp = Date.today
|
48
48
|
assert_equal datestamp.to_s(:short), date(datestamp, "", :short)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
should "convert passed data to a time" do
|
52
52
|
timestamp = Time.now
|
53
53
|
datestamp = timestamp.to_date
|
54
|
-
|
54
|
+
|
55
55
|
assert_equal datestamp.to_s(:long), date(timestamp)
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
59
|
-
end
|
58
|
+
|
59
|
+
end
|
data/test/form_helper_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class FormHelperTest < EaselHelpers::ViewTestCase
|
4
|
-
|
4
|
+
|
5
5
|
context "submit_button" do
|
6
|
-
|
6
|
+
|
7
7
|
should "default with the correct structure" do
|
8
8
|
show_view "<%= submit_button 'Create' %>" do
|
9
9
|
assert_select "button.btn[type=submit][value=Create]" do
|
@@ -11,7 +11,7 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
should "allow adding additional classes" do
|
16
16
|
show_view "<%= submit_button 'Create', 'adtl-class', :dumb %>" do
|
17
17
|
assert_select "button.btn.adtl-class.dumb[type=submit][value=Create]" do
|
@@ -19,7 +19,7 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
should "handle additional attributes set" do
|
24
24
|
show_view "<%= submit_button 'Create', :kls, :id => 'my-id', :type => 'image' %>" do
|
25
25
|
assert_select "button.btn.kls#my-id[type=image][value=Create]" do
|
@@ -27,7 +27,7 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
should "allow overriding of value" do
|
32
32
|
show_view "<%= submit_button 'Create', :value => 'override' %>" do
|
33
33
|
assert_select "button.btn[type=submit][value=override]" do
|
@@ -35,63 +35,63 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
context "set" do
|
42
|
-
|
42
|
+
|
43
43
|
should "default with the correct structure" do
|
44
44
|
show_view "<% set do %>words<% end %>" do
|
45
45
|
assert_select "div.text", "words"
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
should "allow adding/overriding classes" do
|
50
50
|
show_view "<% set :checkbox do %>words<% end %>" do
|
51
51
|
assert_select "div.checkbox", "words"
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
should "handle additional attributes set" do
|
56
56
|
show_view "<% set :id => 'custom-id' do %>words<% end %>" do
|
57
57
|
assert_select "div.text#custom-id", "words"
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
should "assign default class if width class is passed as the only class" do
|
62
62
|
show_view "<% set :half do %>words<% end %>" do
|
63
63
|
assert_select "div.text.col-12", "words"
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
should "assign default class if last class is passed as the only class" do
|
68
68
|
show_view "<% set :half, :last do %>words<% end %>" do
|
69
69
|
assert_select "div.col-12.text.col-last", "words"
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
should "assign default class if error class is passed" do
|
74
74
|
show_view "<% set :half, :last, :error do %>words<% end %>" do
|
75
75
|
assert_select "div.col-12.text.col-last.error", "words"
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
should "assign default class if the class textarea is present" do
|
80
80
|
show_view "<% set :textarea do %>words<% end %>" do
|
81
81
|
assert_select "div.textarea.text", "words"
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
context "fieldset" do
|
88
|
-
|
88
|
+
|
89
89
|
should "default with the correct structure" do
|
90
90
|
show_view "<% fieldset do %>words<% end %>" do
|
91
91
|
assert_select "fieldset", "words"
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
should "assign the first argument as the legend if it is a string" do
|
96
96
|
show_view "<% fieldset 'User Information' do %>words<% end %>" do
|
97
97
|
assert_select "fieldset", /words/ do
|
@@ -99,13 +99,13 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
should "allow adding fieldset classes" do
|
104
104
|
show_view "<% fieldset :hform, 'col-last' do %>words<% end %>" do
|
105
105
|
assert_select "fieldset.hform.col-last", "words"
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
should "allow adding fieldset classes and a legend" do
|
110
110
|
show_view "<% fieldset 'User Information', :hform, 'col-last' do %>words<% end %>" do
|
111
111
|
assert_select "fieldset.hform.col-last", /words/ do
|
@@ -113,7 +113,7 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
should "allow assignment of legend attributes" do
|
118
118
|
show_view "<% fieldset 'User Information', :hform, :legend => {:class => 'lgnd', :id => 'legend-id'} do %>words<% end %>" do
|
119
119
|
assert_select "fieldset.hform", /words/ do
|
@@ -121,7 +121,7 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
should "allow assignment of fieldset attributes" do
|
126
126
|
show_view "<% fieldset 'User Information', :hform, :id => 'my-fieldset' do %>words<% end %>" do
|
127
127
|
assert_select "fieldset.hform#my-fieldset", /words/ do
|
@@ -129,7 +129,7 @@ class FormHelperTest < EaselHelpers::ViewTestCase
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
end
|
data/test/jquery_helper_test.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class JqueryHelperTest < EaselHelpers::ViewTestCase
|
4
|
-
|
4
|
+
|
5
5
|
context "document_ready" do
|
6
|
-
|
6
|
+
|
7
7
|
setup do
|
8
8
|
@whitespace = '\s+?'
|
9
9
|
@anything = '(.|\s)+?'
|
10
|
-
|
10
|
+
|
11
11
|
@anon_function_start_regex = Regexp.escape "(function($) {"
|
12
12
|
@document_ready_start_regex = Regexp.escape "$(document).ready(function() {"
|
13
|
-
|
13
|
+
|
14
14
|
@document_ready_end_regex = Regexp.escape "});"
|
15
15
|
@anon_function_end_regex = Regexp.escape "})(jQuery);"
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
should "properly build the document ready script tag" do
|
19
19
|
show_view %(
|
20
20
|
<% document_ready do %>
|
@@ -24,7 +24,7 @@ class JqueryHelperTest < EaselHelpers::ViewTestCase
|
|
24
24
|
assert_select "script[type=?]", "text/javascript", /#{@anon_function_start_regex}#{@whitespace}#{@document_ready_start_regex}#{@whitespace}alert#{@anything}#{@document_ready_end_regex}#{@whitespace}#{@anon_function_end_regex}/
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
end
|
29
|
-
|
30
|
-
end
|
29
|
+
|
30
|
+
end
|
data/test/link_helper_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class LinkHelperTest < EaselHelpers::ViewTestCase
|
4
4
|
context "link_button" do
|
5
|
-
|
5
|
+
|
6
6
|
should "default with the correct structure" do
|
7
7
|
show_view "<%= link_button 'Link Text', '#' %>" do
|
8
8
|
assert_select "a.btn[href=#]" do
|
@@ -10,7 +10,7 @@ class LinkHelperTest < EaselHelpers::ViewTestCase
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
should "allow the same assignment as link_to" do
|
15
15
|
show_view "<%= link_button 'Link Text', '#', :class => 'my-button', :id => 'link-text' %>" do
|
16
16
|
assert_select "a.btn.my-button#link-text[href=#]" do
|
@@ -18,27 +18,27 @@ class LinkHelperTest < EaselHelpers::ViewTestCase
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
context "link_to_email" do
|
25
25
|
should "default with the correct structure" do
|
26
26
|
show_view "<%= link_to_email 'test@example.com' %>" do
|
27
27
|
assert_select "a[href=mailto:test@example.com]", "test@example.com"
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
should "allow override of link text as the first argument after email" do
|
32
32
|
show_view "<%= link_to_email 'test@example.com', 'Send an email to Test User' %>" do
|
33
33
|
assert_select "a[href=mailto:test@example.com]", "Send an email to Test User"
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
should "allow the same assignment as link_to" do
|
38
38
|
show_view "<%= link_to_email 'test@example.com', :class => 'test-user-email', :id => 'user_1_email' %>" do
|
39
39
|
assert_select "a.test-user-email#user_1_email[href=mailto:test@example.com]", "test@example.com"
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
end
|
44
|
-
end
|
44
|
+
end
|
data/test/message_helper_test.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class MessageHelperTest < EaselHelpers::ViewTestCase
|
4
|
-
|
4
|
+
|
5
5
|
context "messages" do
|
6
|
-
|
6
|
+
|
7
7
|
should "default with the correct structure" do
|
8
8
|
show_view %(<%= messages(:structure => "Flash message") %>) do
|
9
9
|
assert_select "p.structure.box.single-line", "Flash message"
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
should "display all flash messages present" do
|
14
14
|
show_view %(<%= messages(:structure => "Flash message", :error => "Warning message") %>) do
|
15
15
|
assert_select "p.structure", "Flash message"
|
16
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 %(<%= messages(:structure => "", :error => nil) %>) do
|
22
22
|
assert_select "p.structure", false
|
23
23
|
assert_select "p.error", false
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
should "filter by the :only option" do
|
28
28
|
show_view %(<%= messages({:structure => "Flash message", :error => "Warning message", :notice => "Notice!"}, {:only => [:structure, :error]}) %>) do
|
29
29
|
assert_select "p.structure", "Flash message"
|
@@ -31,7 +31,7 @@ class MessageHelperTest < EaselHelpers::ViewTestCase
|
|
31
31
|
assert_select "p.notice", false
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
should "filter by the :except option" do
|
36
36
|
show_view %(<%= messages({:structure => "Flash message", :error => "Warning message", :notice => "Notice!"}, {:except => [:structure, :error]}) %>) do
|
37
37
|
assert_select "p.structure", false
|
@@ -39,12 +39,12 @@ class MessageHelperTest < EaselHelpers::ViewTestCase
|
|
39
39
|
assert_select "p.notice", "Notice!"
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
should "raise an error of :only and :except are both passed" do
|
44
44
|
assert_raise ArgumentError, /conflict/ do
|
45
45
|
show_view %(<%= messages({:structure => "Flash message"}, {:except => [:structure, :error], :only => :structure}) %>)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
50
|
-
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class NavigationHelperTest < ActiveSupport::TestCase
|
4
|
+
include EaselHelpers::Helpers::NavigationHelper
|
5
|
+
|
6
|
+
context "tab" do
|
7
|
+
should "parse tab options properly" do
|
8
|
+
expects(:parse_tab_options).with("test", {:b => 2}).returns({})
|
9
|
+
stubs(:link_to)
|
10
|
+
stubs(:content_tag)
|
11
|
+
stubs(:clean_css_classes)
|
12
|
+
tab("test", "/", {:a => 1}, {:b => 2})
|
13
|
+
end
|
14
|
+
|
15
|
+
should "call link_to properly" do
|
16
|
+
stubs(:content_tag)
|
17
|
+
stubs(:clean_css_classes)
|
18
|
+
stubs(:parse_tab_options).returns({})
|
19
|
+
expects(:link_to).with("test", "/path", {:a => 1, :b => 2})
|
20
|
+
tab("test", "/path", {:a => 1, :b => 2})
|
21
|
+
end
|
22
|
+
|
23
|
+
context "compiling li classes" do
|
24
|
+
setup do
|
25
|
+
@result_options = { :active => "1",
|
26
|
+
:comparison => "2",
|
27
|
+
:compare => false,
|
28
|
+
:li_classes => "one two three" }
|
29
|
+
stubs(:link_to).returns("link_to")
|
30
|
+
stubs(:content_tag)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "properly use classes passed in the options" do
|
34
|
+
stubs(:parse_tab_options).returns(@result_options)
|
35
|
+
expects(:clean_css_classes).with(["one two three", nil])
|
36
|
+
tab("test", "/")
|
37
|
+
end
|
38
|
+
|
39
|
+
should "properly compare information" do
|
40
|
+
@result_options[:comparison] = "1"
|
41
|
+
stubs(:parse_tab_options).returns(@result_options)
|
42
|
+
expects(:clean_css_classes).with(["one two three", "active"])
|
43
|
+
tab("test", "/")
|
44
|
+
end
|
45
|
+
|
46
|
+
should "properly use compare value" do
|
47
|
+
@result_options[:compare] = true
|
48
|
+
stubs(:parse_tab_options).returns(@result_options)
|
49
|
+
expects(:clean_css_classes).with(["one two three", "active"])
|
50
|
+
tab("test", "/")
|
51
|
+
end
|
52
|
+
|
53
|
+
should "not assign class if css_classes is blank" do
|
54
|
+
@result_options[:li_classes] = nil
|
55
|
+
stubs(:parse_tab_options).returns({})
|
56
|
+
stubs(:clean_css_classes).returns("")
|
57
|
+
expects(:content_tag).with(:li, "link_to", {})
|
58
|
+
tab("test", "/")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "parse_tab_options" do
|
63
|
+
context "calculating :active" do
|
64
|
+
setup do
|
65
|
+
stubs(:controller).returns(stub_everything)
|
66
|
+
end
|
67
|
+
|
68
|
+
should "be based on option" do
|
69
|
+
result = send(:parse_tab_options, "name", {:active => "words"})
|
70
|
+
assert_equal "words", result[:active]
|
71
|
+
end
|
72
|
+
|
73
|
+
should "be based on name" do
|
74
|
+
name = tableized_name = stub
|
75
|
+
name.expects(:gsub).with(/\s/, '').returns(tableized_name)
|
76
|
+
tableized_name.expects(:tableize).returns("name")
|
77
|
+
|
78
|
+
result = send(:parse_tab_options, name, {})
|
79
|
+
assert_equal "name", result[:active]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "calculating :comparison" do
|
84
|
+
should "be based on option" do
|
85
|
+
result = send(:parse_tab_options, "name", {:active_compare => "active"})
|
86
|
+
assert_equal "active", result[:comparison]
|
87
|
+
end
|
88
|
+
|
89
|
+
should "be based on controller name" do
|
90
|
+
controller = stub(:controller_name => "controller-name")
|
91
|
+
expects(:controller).returns(controller)
|
92
|
+
result = send(:parse_tab_options, "name", {})
|
93
|
+
assert_equal "controller-name", result[:comparison]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "calculating :compare" do
|
98
|
+
setup do
|
99
|
+
stubs(:controller).returns(stub_everything)
|
100
|
+
end
|
101
|
+
|
102
|
+
should "be based on option" do
|
103
|
+
result = send(:parse_tab_options, "name", {:compare => true})
|
104
|
+
assert_equal true, result[:compare]
|
105
|
+
end
|
106
|
+
|
107
|
+
should "have a default value" do
|
108
|
+
result = send(:parse_tab_options, "name")
|
109
|
+
assert_equal false, result[:compare]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "calculating :li_classes" do
|
114
|
+
setup do
|
115
|
+
stubs(:controller).returns(stub_everything)
|
116
|
+
end
|
117
|
+
|
118
|
+
should "be based on option" do
|
119
|
+
result = send(:parse_tab_options, "name", {:class => "custom classes"})
|
120
|
+
assert_equal "custom classes", result[:li_classes]
|
121
|
+
end
|
122
|
+
|
123
|
+
should "be nil if no option is passed" do
|
124
|
+
result = send(:parse_tab_options, "name")
|
125
|
+
assert_nil result[:li_classes]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/test/rjs_helper_test.rb
CHANGED
@@ -3,19 +3,19 @@ require 'test_helper'
|
|
3
3
|
class RjsHelperTest < ActiveSupport::TestCase
|
4
4
|
include EaselHelpers::Helpers::RjsHelper
|
5
5
|
include EaselHelpers::Helpers::MessageHelper
|
6
|
-
|
6
|
+
|
7
7
|
context "inline_flash" do
|
8
8
|
setup do
|
9
9
|
@page = Object.new
|
10
10
|
@flash_hash = {:notice => "Test!"}
|
11
11
|
self.expects(:messages).with({:notice => "Test!"}).returns("string")
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
context "without keeping flash" do
|
15
15
|
setup do
|
16
16
|
@flash_hash.expects(:discard).returns(true)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
should "default to inserting flash within div#flash-container" do
|
20
20
|
@page.expects(:insert_html).with(:top, "flash-container", "string")
|
21
21
|
inline_flash(@page, @flash_hash)
|
@@ -31,17 +31,17 @@ class RjsHelperTest < ActiveSupport::TestCase
|
|
31
31
|
inline_flash(@page, @flash_hash, {:replace => true})
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
context "when keeping flash" do
|
36
36
|
setup do
|
37
37
|
@flash_hash.expects(:discard).never
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
should "default to inserting flash within div#flash-container" do
|
41
41
|
@page.expects(:insert_html).with(:top, "flash-container", "string")
|
42
42
|
inline_flash(@page, @flash_hash, :keep_flash => true)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
|
-
end
|
46
|
+
|
47
|
+
end
|
data/test/table_helper_test.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class TableHelperTest < EaselHelpers::ViewTestCase
|
4
|
-
|
4
|
+
|
5
5
|
context "zebra_row" do
|
6
|
-
|
6
|
+
|
7
7
|
should "default with the correct structure" do
|
8
8
|
show_view "<table><% zebra_row do %>no class<% end %><% zebra_row do %>alt class<% end %></table>" do
|
9
9
|
assert_select "tr:first-child", "no class"
|
10
10
|
assert_select "tr.alt:last-child", "alt class"
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
should "allow override of the cycle list" do
|
15
15
|
show_view %(
|
16
16
|
<table>
|
@@ -24,23 +24,23 @@ class TableHelperTest < EaselHelpers::ViewTestCase
|
|
24
24
|
assert_select "tr.blue:last-child", "the color blue"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
should "allow option assignment" do
|
29
29
|
show_view "<% zebra_row :id => 'my-id', :class => 'custom-class' do %>user 1<% end %>" do
|
30
30
|
assert_select "tr#my-id.custom-class", "user 1"
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
context "recordset" do
|
37
|
-
|
37
|
+
|
38
38
|
should "default with the correct structure" do
|
39
39
|
show_view %(<% recordset do %>rows<% end %>) do
|
40
40
|
assert_select "table.recordset[cellspacing=0]", "rows"
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
should "allow headers be set" do
|
45
45
|
show_view %(<% recordset :headers => ["Header 1", "Header 2", "Header 3"] do %><tbody>rows</tbody><% end %>) do
|
46
46
|
assert_select "table.recordset[cellspacing=0]" do
|
@@ -55,7 +55,7 @@ class TableHelperTest < EaselHelpers::ViewTestCase
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
should "allow headers to have attributes set" do
|
60
60
|
show_view %(
|
61
61
|
<% recordset :headers => [["Header 1", {:class => "mine", :id => "over"}]] do %>
|
@@ -72,13 +72,13 @@ class TableHelperTest < EaselHelpers::ViewTestCase
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
should "allow classes be assigned in a comma-delimited manner" do
|
77
77
|
show_view %(<% recordset "my-recordset", "car-list" do %><% end %>) do
|
78
78
|
assert_select "table.recordset.my-recordset.car-list[cellspacing=0]"
|
79
79
|
end
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
should "allow additional attributes be set on the recordset" do
|
83
83
|
show_view %(<% recordset :headers => %w(One Two Three), :table => {:id => "my-id", :class => "my-recordset"} do %><% end %>) do
|
84
84
|
assert_select "table#my-id.recordset.my-recordset[cellspacing=0]" do
|
@@ -92,7 +92,7 @@ class TableHelperTest < EaselHelpers::ViewTestCase
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
should "reset cycles for zebra_rows" do
|
97
97
|
show_view %(
|
98
98
|
<% recordset do %>
|
@@ -106,7 +106,7 @@ class TableHelperTest < EaselHelpers::ViewTestCase
|
|
106
106
|
assert_select "tr.alt", 0
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
end
|
111
111
|
end
|
112
|
-
end
|
112
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -14,20 +14,20 @@ ActionController::Base.send :include, EaselHelpers::PartialCaching
|
|
14
14
|
|
15
15
|
class EaselHelpers::ViewTestCase < ActiveSupport::TestCase
|
16
16
|
include ActionController::Assertions::SelectorAssertions
|
17
|
-
|
17
|
+
|
18
18
|
def setup
|
19
19
|
super
|
20
20
|
@view = ActionView::Base.new
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
protected
|
24
|
-
|
24
|
+
|
25
25
|
def show_view(template)
|
26
26
|
@html_result = ActionView::InlineTemplate.new(template).render(@view, {})
|
27
27
|
@html_document = HTML::Document.new(@html_result, true, false)
|
28
28
|
yield if block_given?
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def response_from_page_or_rjs
|
32
32
|
@html_document.root
|
33
33
|
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.17
|
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-07-
|
12
|
+
date: 2009-07-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ extra_rdoc_files:
|
|
64
64
|
- lib/easel_helpers/helpers/jquery_helper.rb
|
65
65
|
- lib/easel_helpers/helpers/link_helper.rb
|
66
66
|
- lib/easel_helpers/helpers/message_helper.rb
|
67
|
+
- lib/easel_helpers/helpers/navigation_helper.rb
|
67
68
|
- lib/easel_helpers/helpers/rjs_helper.rb
|
68
69
|
- lib/easel_helpers/helpers/structure_helper.rb
|
69
70
|
- lib/easel_helpers/helpers/table_helper.rb
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- lib/easel_helpers/helpers/jquery_helper.rb
|
81
82
|
- lib/easel_helpers/helpers/link_helper.rb
|
82
83
|
- lib/easel_helpers/helpers/message_helper.rb
|
84
|
+
- lib/easel_helpers/helpers/navigation_helper.rb
|
83
85
|
- lib/easel_helpers/helpers/rjs_helper.rb
|
84
86
|
- lib/easel_helpers/helpers/structure_helper.rb
|
85
87
|
- lib/easel_helpers/helpers/table_helper.rb
|
@@ -98,6 +100,7 @@ files:
|
|
98
100
|
- test/jquery_helper_test.rb
|
99
101
|
- test/link_helper_test.rb
|
100
102
|
- test/message_helper_test.rb
|
103
|
+
- test/navigation_helper_test.rb
|
101
104
|
- test/rjs_helper_test.rb
|
102
105
|
- test/structure_helper_test.rb
|
103
106
|
- test/table_helper_test.rb
|
@@ -140,6 +143,7 @@ test_files:
|
|
140
143
|
- test/jquery_helper_test.rb
|
141
144
|
- test/link_helper_test.rb
|
142
145
|
- test/message_helper_test.rb
|
146
|
+
- test/navigation_helper_test.rb
|
143
147
|
- test/rjs_helper_test.rb
|
144
148
|
- test/structure_helper_test.rb
|
145
149
|
- test/table_helper_test.rb
|