themes_for_rails 0.5.1 → 1.0.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile.lock +82 -60
- data/README.textile +235 -11
- data/Rakefile +31 -11
- data/init.rb +1 -0
- data/lib/generators/themes_for_rails/install_generator.rb +21 -6
- data/lib/generators/themes_for_rails/templates/README +11 -0
- data/lib/generators/themes_for_rails/templates/theme/{images → assets/images}/.gitkeep +0 -0
- data/lib/generators/themes_for_rails/templates/theme/{javascripts → assets/javascripts}/.gitkeep +0 -0
- data/lib/generators/themes_for_rails/templates/theme/assets/javascripts/application.js +9 -0
- data/lib/generators/themes_for_rails/templates/theme/{stylesheets → assets/stylesheets}/.gitkeep +0 -0
- data/lib/generators/themes_for_rails/templates/theme/assets/stylesheets/application.css +7 -0
- data/lib/generators/themes_for_rails/theme_generator.rb +2 -3
- data/lib/themes_for_rails.rb +15 -40
- data/lib/themes_for_rails/assets_finder.rb +44 -0
- data/lib/themes_for_rails/common_methods.rb +26 -34
- data/lib/themes_for_rails/config.rb +8 -59
- data/lib/themes_for_rails/{action_controller.rb → controller_methods.rb} +7 -13
- data/lib/themes_for_rails/logging.rb +14 -0
- data/lib/themes_for_rails/mailer_methods.rb +22 -0
- data/lib/themes_for_rails/railtie.rb +10 -21
- data/lib/themes_for_rails/routes.rb +3 -15
- data/lib/themes_for_rails/version.rb +1 -2
- data/lib/themes_for_rails/view_helpers.rb +52 -0
- data/spec/controllers/my_controller_spec.rb +99 -0
- data/{test/dummy_app → spec/dummy}/.gitignore +2 -1
- data/spec/dummy/Gemfile +35 -0
- data/spec/dummy/Gemfile.lock +127 -0
- data/spec/dummy/README +261 -0
- data/{test/dummy_app → spec/dummy}/Rakefile +1 -1
- data/{test/dummy_app/public → spec/dummy/app/assets}/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/{test/dummy_app → spec/dummy}/app/controllers/application_controller.rb +0 -0
- data/{test/dummy_app → spec/dummy}/app/helpers/application_helper.rb +0 -0
- data/{test/dummy_app/empty_themes → spec/dummy/app/mailers}/.gitkeep +0 -0
- data/{test/dummy_app/lib/tasks → spec/dummy/app/models}/.gitkeep +0 -0
- data/spec/dummy/app/themes/default/assets/images/rails.png +0 -0
- data/spec/dummy/app/themes/default/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/themes/default/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/themes/default/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/{test/dummy_app → spec/dummy}/config.ru +0 -0
- data/{test/dummy_app → spec/dummy}/config/application.rb +12 -6
- data/spec/dummy/config/boot.rb +6 -0
- data/{test/dummy_app → spec/dummy}/config/database.yml +10 -3
- data/{test/dummy_app → spec/dummy}/config/environment.rb +0 -0
- data/{test/dummy_app → spec/dummy}/config/environments/development.rb +8 -4
- data/{test/dummy_app → spec/dummy}/config/environments/production.rb +24 -13
- data/{test/dummy_app → spec/dummy}/config/environments/test.rb +9 -2
- data/{test/dummy_app → spec/dummy}/config/initializers/backtrace_silencers.rb +0 -0
- data/{test/dummy_app → spec/dummy}/config/initializers/inflections.rb +0 -0
- data/{test/dummy_app → spec/dummy}/config/initializers/mime_types.rb +0 -0
- data/{test/dummy_app → spec/dummy}/config/initializers/secret_token.rb +1 -1
- data/{test/dummy_app → spec/dummy}/config/initializers/session_store.rb +2 -2
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/{test/dummy_app → spec/dummy}/config/locales/en.yml +1 -1
- data/spec/dummy/config/routes.rb +3 -0
- data/{test/dummy_app → spec/dummy}/db/seeds.rb +2 -2
- data/spec/dummy/doc/README_FOR_APP +2 -0
- data/{test/dummy_app/public/stylesheets → spec/dummy/lib/assets}/.gitkeep +0 -0
- data/{doc/REVIEW_NOTES → spec/dummy/lib/tasks/.gitkeep} +0 -0
- data/{test/dummy_app/another_themes/another_default/images/logo.png → spec/dummy/log/.gitkeep} +0 -0
- data/{test/dummy_app → spec/dummy}/public/404.html +0 -0
- data/{test/dummy_app → spec/dummy}/public/422.html +0 -0
- data/{test/dummy_app → spec/dummy}/public/500.html +0 -0
- data/{test/dummy_app → spec/dummy}/public/favicon.ico +0 -0
- data/{test/dummy_app → spec/dummy}/public/index.html +10 -8
- data/{test/dummy_app → spec/dummy}/public/robots.txt +0 -0
- data/{test/dummy_app → spec/dummy}/script/rails +0 -0
- data/{test/dummy_app/another_themes/another_default/images/nested/logo.png → spec/dummy/test/fixtures/.gitkeep} +0 -0
- data/{test/dummy_app/another_themes/another_default/stylesheets/style.css → spec/dummy/test/functional/.gitkeep} +0 -0
- data/{test/dummy_app/another_themes/another_default/views/products/index.html.erb → spec/dummy/test/integration/.gitkeep} +0 -0
- data/spec/dummy/test/performance/browsing_test.rb +12 -0
- data/spec/dummy/test/test_helper.rb +13 -0
- data/{test/dummy_app/themes/default/images/logo.png → spec/dummy/test/unit/.gitkeep} +0 -0
- data/{test/dummy_app/themes/default/images/nested/logo.png → spec/dummy/vendor/assets/stylesheets/.gitkeep} +0 -0
- data/{test/dummy_app/themes/default/javascripts/app.min.js → spec/dummy/vendor/plugins/.gitkeep} +0 -0
- data/spec/lib/assets_finder_spec.rb +10 -0
- data/spec/lib/common_methods_spec.rb +30 -0
- data/spec/lib/config_spec.rb +19 -0
- data/spec/lib/controller_methods_spec.rb +19 -0
- data/spec/lib/view_helpers_spec.rb +38 -0
- data/spec/mailers/mailer_methods_spec.rb +39 -0
- data/spec/spec_helper.rb +15 -0
- data/test/dummy_app/Gemfile.lock +91 -0
- data/test/dummy_app/{themes/default/stylesheets/images/logo.png → log/development.log} +0 -0
- data/test/dummy_app/log/test.log +6 -0
- data/themes_for_rails.gemspec +140 -20
- metadata +112 -183
- data/.gitignore +0 -7
- data/.travis.yml +0 -2
- data/LICENSE +0 -21
- data/doc/README.textile +0 -363
- data/doc/RMU_REVIEW +0 -26
- data/doc/TODO.textile +0 -3
- data/lib/themes_for_rails/action_mailer.rb +0 -22
- data/lib/themes_for_rails/action_view.rb +0 -62
- data/lib/themes_for_rails/assets_controller.rb +0 -66
- data/lib/themes_for_rails/interpolation.rb +0 -11
- data/lib/themes_for_rails/url_helpers.rb +0 -27
- data/test/dummy_app/Gemfile +0 -30
- data/test/dummy_app/another_themes/another_default/javascripts/app.js +0 -1
- data/test/dummy_app/another_themes/another_default/stylesheets/style2.css +0 -3
- data/test/dummy_app/another_themes/another_default/views/layouts/default.html.erb +0 -10
- data/test/dummy_app/app/views/layouts/application.html.erb +0 -14
- data/test/dummy_app/config/boot.rb +0 -13
- data/test/dummy_app/config/routes.rb +0 -4
- data/test/dummy_app/public/javascripts/application.js +0 -2
- data/test/dummy_app/public/javascripts/controls.js +0 -965
- data/test/dummy_app/public/javascripts/dragdrop.js +0 -974
- data/test/dummy_app/public/javascripts/effects.js +0 -1123
- data/test/dummy_app/public/javascripts/prototype.js +0 -6001
- data/test/dummy_app/public/javascripts/rails.js +0 -175
- data/test/dummy_app/themes/default/javascripts/app.js +0 -1
- data/test/dummy_app/themes/default/stylesheets/style.css +0 -0
- data/test/dummy_app/themes/default/stylesheets/style2.css +0 -3
- data/test/dummy_app/themes/default/views/layouts/default.html.erb +0 -10
- data/test/dummy_app/themes/default/views/products/index.html.erb +0 -0
- data/test/lib/action_controller_test.rb +0 -170
- data/test/lib/action_mailer_test.rb +0 -35
- data/test/lib/action_view_test.rb +0 -54
- data/test/lib/assets_controller_test.rb +0 -73
- data/test/lib/common_methods_test.rb +0 -28
- data/test/lib/config_test.rb +0 -26
- data/test/lib/integration_test.rb +0 -12
- data/test/lib/routes_test.rb +0 -40
- data/test/lib/themes_for_rails_test.rb +0 -18
- data/test/support/extensions.rb +0 -19
- data/test/test_helper.rb +0 -12
@@ -1,175 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
// Technique from Juriy Zaytsev
|
3
|
-
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
-
function isEventSupported(eventName) {
|
5
|
-
var el = document.createElement('div');
|
6
|
-
eventName = 'on' + eventName;
|
7
|
-
var isSupported = (eventName in el);
|
8
|
-
if (!isSupported) {
|
9
|
-
el.setAttribute(eventName, 'return;');
|
10
|
-
isSupported = typeof el[eventName] == 'function';
|
11
|
-
}
|
12
|
-
el = null;
|
13
|
-
return isSupported;
|
14
|
-
}
|
15
|
-
|
16
|
-
function isForm(element) {
|
17
|
-
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
-
}
|
19
|
-
|
20
|
-
function isInput(element) {
|
21
|
-
if (Object.isElement(element)) {
|
22
|
-
var name = element.nodeName.toUpperCase()
|
23
|
-
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
-
}
|
25
|
-
else return false
|
26
|
-
}
|
27
|
-
|
28
|
-
var submitBubbles = isEventSupported('submit'),
|
29
|
-
changeBubbles = isEventSupported('change')
|
30
|
-
|
31
|
-
if (!submitBubbles || !changeBubbles) {
|
32
|
-
// augment the Event.Handler class to observe custom events when needed
|
33
|
-
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
-
function(init, element, eventName, selector, callback) {
|
35
|
-
init(element, eventName, selector, callback)
|
36
|
-
// is the handler being attached to an element that doesn't support this event?
|
37
|
-
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
-
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
-
// "submit" => "emulated:submit"
|
40
|
-
this.eventName = 'emulated:' + this.eventName
|
41
|
-
}
|
42
|
-
}
|
43
|
-
)
|
44
|
-
}
|
45
|
-
|
46
|
-
if (!submitBubbles) {
|
47
|
-
// discover forms on the page by observing focus events which always bubble
|
48
|
-
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
-
// special handler for the real "submit" event (one-time operation)
|
50
|
-
if (!form.retrieve('emulated:submit')) {
|
51
|
-
form.on('submit', function(submitEvent) {
|
52
|
-
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
-
// if custom event received preventDefault, cancel the real one too
|
54
|
-
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
-
})
|
56
|
-
form.store('emulated:submit', true)
|
57
|
-
}
|
58
|
-
})
|
59
|
-
}
|
60
|
-
|
61
|
-
if (!changeBubbles) {
|
62
|
-
// discover form inputs on the page
|
63
|
-
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
-
// special handler for real "change" events
|
65
|
-
if (!input.retrieve('emulated:change')) {
|
66
|
-
input.on('change', function(changeEvent) {
|
67
|
-
input.fire('emulated:change', changeEvent, true)
|
68
|
-
})
|
69
|
-
input.store('emulated:change', true)
|
70
|
-
}
|
71
|
-
})
|
72
|
-
}
|
73
|
-
|
74
|
-
function handleRemote(element) {
|
75
|
-
var method, url, params;
|
76
|
-
|
77
|
-
var event = element.fire("ajax:before");
|
78
|
-
if (event.stopped) return false;
|
79
|
-
|
80
|
-
if (element.tagName.toLowerCase() === 'form') {
|
81
|
-
method = element.readAttribute('method') || 'post';
|
82
|
-
url = element.readAttribute('action');
|
83
|
-
params = element.serialize();
|
84
|
-
} else {
|
85
|
-
method = element.readAttribute('data-method') || 'get';
|
86
|
-
url = element.readAttribute('href');
|
87
|
-
params = {};
|
88
|
-
}
|
89
|
-
|
90
|
-
new Ajax.Request(url, {
|
91
|
-
method: method,
|
92
|
-
parameters: params,
|
93
|
-
evalScripts: true,
|
94
|
-
|
95
|
-
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
-
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
-
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
-
});
|
99
|
-
|
100
|
-
element.fire("ajax:after");
|
101
|
-
}
|
102
|
-
|
103
|
-
function handleMethod(element) {
|
104
|
-
var method = element.readAttribute('data-method'),
|
105
|
-
url = element.readAttribute('href'),
|
106
|
-
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
-
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
-
|
109
|
-
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
-
element.parentNode.insert(form);
|
111
|
-
|
112
|
-
if (method !== 'post') {
|
113
|
-
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
-
form.insert(field);
|
115
|
-
}
|
116
|
-
|
117
|
-
if (csrf_param) {
|
118
|
-
var param = csrf_param.readAttribute('content'),
|
119
|
-
token = csrf_token.readAttribute('content'),
|
120
|
-
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
-
form.insert(field);
|
122
|
-
}
|
123
|
-
|
124
|
-
form.submit();
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
-
var message = element.readAttribute('data-confirm');
|
130
|
-
if (!confirm(message)) event.stop();
|
131
|
-
});
|
132
|
-
|
133
|
-
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
-
if (event.stopped) return;
|
135
|
-
handleRemote(element);
|
136
|
-
event.stop();
|
137
|
-
});
|
138
|
-
|
139
|
-
document.on("click", "a[data-method]", function(event, element) {
|
140
|
-
if (event.stopped) return;
|
141
|
-
handleMethod(element);
|
142
|
-
event.stop();
|
143
|
-
});
|
144
|
-
|
145
|
-
document.on("submit", function(event) {
|
146
|
-
var element = event.findElement(),
|
147
|
-
message = element.readAttribute('data-confirm');
|
148
|
-
if (message && !confirm(message)) {
|
149
|
-
event.stop();
|
150
|
-
return false;
|
151
|
-
}
|
152
|
-
|
153
|
-
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
-
inputs.each(function(input) {
|
155
|
-
input.disabled = true;
|
156
|
-
input.writeAttribute('data-original-value', input.value);
|
157
|
-
input.value = input.readAttribute('data-disable-with');
|
158
|
-
});
|
159
|
-
|
160
|
-
var element = event.findElement("form[data-remote]");
|
161
|
-
if (element) {
|
162
|
-
handleRemote(element);
|
163
|
-
event.stop();
|
164
|
-
}
|
165
|
-
});
|
166
|
-
|
167
|
-
document.on("ajax:after", "form", function(event, element) {
|
168
|
-
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
-
inputs.each(function(input) {
|
170
|
-
input.value = input.readAttribute('data-original-value');
|
171
|
-
input.removeAttribute('data-original-value');
|
172
|
-
input.disabled = false;
|
173
|
-
});
|
174
|
-
});
|
175
|
-
})();
|
@@ -1 +0,0 @@
|
|
1
|
-
//js
|
File without changes
|
File without changes
|
@@ -1,170 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("test/test_helper.rb")
|
3
|
-
|
4
|
-
class MyController < ActionController::Base
|
5
|
-
|
6
|
-
def hello
|
7
|
-
render :text => "Just a test"
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
class CustomThemeController < ActionController::Base
|
13
|
-
|
14
|
-
def hello
|
15
|
-
render :text => "Just a test"
|
16
|
-
end
|
17
|
-
|
18
|
-
def theme_selector
|
19
|
-
'custom'
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
class PrivateCustomThemeController < ActionController::Base
|
25
|
-
|
26
|
-
def hello
|
27
|
-
render :text => "Just a test"
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def private_theme_selector
|
33
|
-
'private_custom'
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
class ActionMailerInclusionTest < Test::Unit::TestCase
|
39
|
-
|
40
|
-
should "include the ActionController module" do
|
41
|
-
assert ActionMailer::Base.included_modules.include?(ThemesForRails::ActionController)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
class ActionControllerInclusionTest < Test::Unit::TestCase
|
47
|
-
should "include the ActionController module" do
|
48
|
-
assert ActionController::Base.included_modules.include?(ThemesForRails::ActionController)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class ApplicationControllerInclusionTest < Test::Unit::TestCase
|
53
|
-
should "include the ActionController module" do
|
54
|
-
assert ApplicationController.included_modules.include?(ThemesForRails::ActionController)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
module ThemesForRails
|
59
|
-
class ActionControllerTest < ::ActionController::TestCase
|
60
|
-
context "at class level" do
|
61
|
-
|
62
|
-
should "respond_to theme" do
|
63
|
-
assert ApplicationController.respond_to?(:theme)
|
64
|
-
end
|
65
|
-
|
66
|
-
context "setting the theme with a String" do
|
67
|
-
|
68
|
-
tests MyController
|
69
|
-
|
70
|
-
should "set the selected theme for all actions" do
|
71
|
-
MyController.theme 'default'
|
72
|
-
@controller.expects(:set_theme).with('default')
|
73
|
-
assert_equal nil, @controller.theme_name
|
74
|
-
get :hello
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "setting the theme with a Symbol" do
|
79
|
-
|
80
|
-
tests CustomThemeController
|
81
|
-
|
82
|
-
should "call the selected private method" do
|
83
|
-
CustomThemeController.theme :theme_selector
|
84
|
-
get :hello
|
85
|
-
assert_equal 'custom', @controller.theme_name
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "setting the theme with a Symbol (private)" do
|
90
|
-
|
91
|
-
tests PrivateCustomThemeController
|
92
|
-
|
93
|
-
should "call the selected private method" do
|
94
|
-
PrivateCustomThemeController.theme :private_theme_selector
|
95
|
-
get :hello
|
96
|
-
assert_equal 'private_custom', @controller.theme_name
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "at instance level" do
|
102
|
-
|
103
|
-
tests ApplicationController
|
104
|
-
|
105
|
-
should "respond_to theme" do
|
106
|
-
assert @controller.respond_to?(:theme)
|
107
|
-
end
|
108
|
-
|
109
|
-
should "should store the theme's name" do
|
110
|
-
@controller.theme 'default'
|
111
|
-
assert_equal @controller.theme_name, 'default'
|
112
|
-
end
|
113
|
-
|
114
|
-
context "when a theme has been set" do
|
115
|
-
|
116
|
-
tests ApplicationController
|
117
|
-
|
118
|
-
should "add the theme's view path to the front of the general view paths" do
|
119
|
-
antes = @controller.view_paths.size
|
120
|
-
@controller.theme 'default'
|
121
|
-
assert_equal antes + 1, @controller.view_paths.size
|
122
|
-
end
|
123
|
-
|
124
|
-
should "have a proper view path" do
|
125
|
-
@controller.theme 'default'
|
126
|
-
view_path = @controller.view_paths.first
|
127
|
-
theme_view_path = File.expand_path(File.join("test", "dummy_app", "themes", "default", "views"))
|
128
|
-
assert_equal view_path.to_s, theme_view_path
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|
133
|
-
context "using url helpers" do
|
134
|
-
|
135
|
-
tests ApplicationController
|
136
|
-
|
137
|
-
should "provide url method to access a given stylesheet file in the current theme" do
|
138
|
-
@controller.theme 'default'
|
139
|
-
assert_equal @controller.send(:current_theme_stylesheet_path, "style"), "/themes/default/stylesheets/style.css"
|
140
|
-
end
|
141
|
-
|
142
|
-
should "provide url method to access a given javascript file in the current theme" do
|
143
|
-
@controller.theme 'default'
|
144
|
-
assert_equal @controller.send(:current_theme_javascript_path, "app"), "/themes/default/javascripts/app.js"
|
145
|
-
end
|
146
|
-
|
147
|
-
should "provide url method to access a given image file in the current theme" do
|
148
|
-
@controller.theme 'default'
|
149
|
-
assert_equal @controller.send(:current_theme_image_path, "logo.png"), "/themes/default/images/logo.png"
|
150
|
-
end
|
151
|
-
|
152
|
-
context "with multiple dots" do
|
153
|
-
|
154
|
-
tests ApplicationController
|
155
|
-
|
156
|
-
should "provide url method to access a given stylesheet file in the current theme" do
|
157
|
-
@controller.theme 'default'
|
158
|
-
assert_equal @controller.send(:current_theme_stylesheet_path, "style.compact"), "/themes/default/stylesheets/style.compact.css"
|
159
|
-
end
|
160
|
-
|
161
|
-
should "provide url method to access a given javascript file in the current theme" do
|
162
|
-
@controller.theme 'default'
|
163
|
-
assert_equal @controller.send(:current_theme_javascript_path, "app.min"), "/themes/default/javascripts/app.min.js"
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("test/test_helper.rb")
|
3
|
-
|
4
|
-
THEME = 'pink'
|
5
|
-
|
6
|
-
class Notifier < ActionMailer::Base
|
7
|
-
default :theme => THEME
|
8
|
-
|
9
|
-
def welcome(user)
|
10
|
-
mail(:theme => user.theme)
|
11
|
-
end
|
12
|
-
|
13
|
-
def thanks(user)
|
14
|
-
mail
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module ThemesForRails
|
19
|
-
class ActionMailerTest < ::ActionController::TestCase
|
20
|
-
|
21
|
-
should "set theme using mail headers" do
|
22
|
-
Notifier.any_instance.expects(:theme).with("purple")
|
23
|
-
|
24
|
-
user = mock("User", :theme => "purple")
|
25
|
-
Notifier.welcome(user)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "set theme using mail default opts" do
|
29
|
-
Notifier.any_instance.expects(:theme).with("pink")
|
30
|
-
|
31
|
-
user = mock("User")
|
32
|
-
Notifier.thanks(user)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("test/test_helper.rb")
|
3
|
-
|
4
|
-
class ViewHelpersTest < ::ActionController::IntegrationTest
|
5
|
-
|
6
|
-
include ::ThemesForRails::ActionView
|
7
|
-
include ::ActionView::Helpers::AssetTagHelper
|
8
|
-
include ::ERB::Util
|
9
|
-
include ::ActionView::Helpers::TagHelper
|
10
|
-
include ::ActionView::Helpers::FormTagHelper
|
11
|
-
def theme_name
|
12
|
-
'default'
|
13
|
-
end
|
14
|
-
|
15
|
-
def config
|
16
|
-
@config ||= stub({:perform_caching => false, :asset_path => "/assets", :asset_host => ''})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module ThemesForRails
|
21
|
-
class CommonViewHelpersTest < ViewHelpersTest
|
22
|
-
|
23
|
-
should "provide path helpers for a given theme name" do
|
24
|
-
|
25
|
-
assert_equal "/themes/sometheme/stylesheets/style.css", theme_stylesheet_path('style', "sometheme")
|
26
|
-
assert_equal "/themes/sometheme/javascripts/app.js", theme_javascript_path('app', "sometheme")
|
27
|
-
assert_equal "/themes/sometheme/images/logo.png", theme_image_path('logo.png', "sometheme")
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
should "provide path helpers for a given theme name with dots" do
|
32
|
-
|
33
|
-
assert_equal "/themes/some.theme/stylesheets/style.css", theme_stylesheet_path('style', "some.theme")
|
34
|
-
assert_equal "/themes/some.theme/javascripts/app.js", theme_javascript_path('app', "some.theme")
|
35
|
-
assert_equal "/themes/some.theme/images/logo.png", theme_image_path('logo.png', "some.theme")
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
should 'delegate to stylesheet_link_tag' do
|
40
|
-
assert_match /media=.screen/, theme_stylesheet_link_tag('cuac.css')
|
41
|
-
end
|
42
|
-
|
43
|
-
should 'delegate options (lazy testing, I know)' do
|
44
|
-
assert_match /media=.print/, theme_stylesheet_link_tag('cuac.css', :media => 'print')
|
45
|
-
end
|
46
|
-
should 'delegate options in image_tag' do
|
47
|
-
assert_match /width=.40/, theme_image_tag('image.css', :size => '40x50')
|
48
|
-
end
|
49
|
-
|
50
|
-
should 'delegate options in image_submit_tag' do
|
51
|
-
assert_match /class=.search_button/, theme_image_submit_tag('image.png', :class => 'search_button')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|