saphira 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +39 -0
- data/app/assets/images/saphira/icons/32x32/direction_up.png +0 -0
- data/app/assets/images/saphira/icons/32x32/file.png +0 -0
- data/app/assets/images/saphira/icons/32x32/folder.png +0 -0
- data/app/assets/javascripts/saphira/application.js +9 -0
- data/app/assets/javascripts/saphira/file_items.js +2 -0
- data/app/assets/stylesheets/saphira/application.css +7 -0
- data/app/assets/stylesheets/saphira/file_items.css +17 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/saphira/application_controller.rb +4 -0
- data/app/controllers/saphira/file_items_controller.rb +104 -0
- data/app/helpers/saphira/application_helper.rb +4 -0
- data/app/helpers/saphira/file_items_helper.rb +4 -0
- data/app/models/saphira/file_item.rb +83 -0
- data/app/views/layouts/saphira/application.html.erb +14 -0
- data/app/views/saphira/file_items/_form.html.erb +33 -0
- data/app/views/saphira/file_items/edit_file.html.erb +6 -0
- data/app/views/saphira/file_items/edit_folder.html.erb +6 -0
- data/app/views/saphira/file_items/index.html.erb +30 -0
- data/app/views/saphira/file_items/new_file.html.erb +5 -0
- data/app/views/saphira/file_items/new_folder.html.erb +5 -0
- data/app/views/saphira/file_items/show.html.erb +39 -0
- data/config/initializers/acts_as_taggable_on.rb +1 -0
- data/config/initializers/awesome_nested_set.rb +1 -0
- data/config/initializers/dragonfly.rb +7 -0
- data/config/initializers/exifr.rb +2 -0
- data/config/initializers/friendly_id.rb +1 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20110904170134_create_saphira_file_items.rb +23 -0
- data/db/migrate/20110904170241_acts_as_taggable_on_migration.rb +28 -0
- data/lib/saphira/engine.rb +5 -0
- data/lib/saphira/version.rb +3 -0
- data/lib/saphira.rb +4 -0
- data/lib/tasks/saphira_tasks.rake +4 -0
- data/test/dummy/Guardfile +8 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +9 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/cucumber.yml +8 -0
- data/test/dummy/config/database.yml +28 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20110904172951_create_saphira_file_items.rb +23 -0
- data/test/dummy/db/migrate/20110904172952_acts_as_taggable_on_migration.rb +28 -0
- data/test/dummy/db/schema.rb +54 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/features/manage_file_items.feature +35 -0
- data/test/dummy/features/step_definitions/file_item_steps.rb +18 -0
- data/test/dummy/features/step_definitions/web_steps.rb +211 -0
- data/test/dummy/features/support/env.rb +50 -0
- data/test/dummy/features/support/files/eos-550d-wrong-orientation.jpg +0 -0
- data/test/dummy/features/support/paths.rb +38 -0
- data/test/dummy/features/support/selectors.rb +39 -0
- data/test/dummy/lib/tasks/cucumber.rake +65 -0
- data/test/dummy/log/development.log +524 -0
- data/test/dummy/log/test.log +362 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/cucumber +10 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/system/files/development/2011/09/04/20_16_51_527_IMG_0074.JPG +0 -0
- data/test/dummy/system/files/development/2011/09/04/20_16_51_527_IMG_0074.JPG.meta +1 -0
- data/test/dummy/system/files/test/2011/09/04/20_14_52_22_eos_550d_wrong_orientation.jpg +0 -0
- data/test/dummy/system/files/test/2011/09/04/20_14_52_22_eos_550d_wrong_orientation.jpg.meta +1 -0
- data/test/dummy/tmp/cache/assets/C54/230/sprockets%2F63597bd80af49501176a9c782c200818 +0 -0
- data/test/dummy/tmp/cache/assets/C8A/C90/sprockets%2Fb0034d98e259fe21084231df778476e5 +0 -0
- data/test/dummy/tmp/cache/assets/CBB/220/sprockets%2Fe50398a56291b292932098dbaf6f60e7 +0 -0
- data/test/dummy/tmp/cache/assets/CED/3A0/sprockets%2F5598ef34994d21041804d8edaae45e75 +0 -0
- data/test/dummy/tmp/cache/assets/D0F/940/sprockets%2Fe5a0c84816880ab73280e1d7c6c6b53f +0 -0
- data/test/dummy/tmp/cache/assets/D25/A40/sprockets%2F3597585a09358e74b9addba0fc954d87 +0 -0
- data/test/dummy/tmp/cache/assets/D28/040/sprockets%2F54bad3bcb77f949259960f3f80837af9 +0 -0
- data/test/dummy/tmp/cache/assets/D8B/C20/sprockets%2F5b4cb2011e99baa41b98122dabfe94d0 +0 -0
- data/test/dummy/tmp/cache/assets/DA9/040/sprockets%2F840de459a6d1c9d87c8dcaf24f128b6c +0 -0
- data/test/dummy/tmp/cache/assets/DD1/040/sprockets%2Fd417bfb346f42b08fa70df9d17c9a4ee +0 -0
- data/test/dummy/tmp/cache/assets/DF8/F80/sprockets%2Fdda7c25be0e8e262ebc270da9775abd4 +0 -0
- data/test/dummy/tmp/cache/assets/E32/DF0/sprockets%2Fbd8fed5e48cbc136c85e9c4ab6d1e3b4 +0 -0
- data/test/dummy/tmp/dragonfly/cache/body/11/4316e3371abd942602830d5ce3e55d4ba94ec5 +0 -0
- data/test/dummy/tmp/dragonfly/cache/body/3e/f63b348d8ad48be7f3d8869f255af8d5d8b19f +8982 -0
- data/test/dummy/tmp/dragonfly/cache/body/61/e9711fd55eccdf62882cb8d127b22664f7023f +3 -0
- data/test/dummy/tmp/dragonfly/cache/body/a1/d3d5a6ed952ccf4816b4a96d4767ce9bae8164 +5 -0
- data/test/dummy/tmp/dragonfly/cache/body/c2/d1fe276d6e527c155855e99dc19d239b6d71f3 +7 -0
- data/test/dummy/tmp/dragonfly/cache/body/cb/052a86fcf83c49b8a1c5ca5f29b11ba31d4038 +17 -0
- data/test/dummy/tmp/dragonfly/cache/body/d4/ff9b03ee9e54acce72e6b793693031079eb150 +332 -0
- data/test/dummy/tmp/dragonfly/cache/meta/24/d0aebc1b6d4ac3b10caa6cfabf89b0ad8551c5 +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/37/fb962d39887389e020d58ef1f745ef1a6107cc +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/78/da9e9f151eb605b427b43e2098640de3fd4a6d +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/8a/00f63a175cfe09352e9103621040457aafc9e8 +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/a0/d65624dcf4c7e6827639f25060a3bf4bd6020d +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/ee/fe74949a8c2a0bbc077385a12944d9f98a12e0 +0 -0
- data/test/dummy/tmp/dragonfly/cache/meta/f9/67ac04386c59253bd80f4034d18af166cc5691 +0 -0
- data/test/fixtures/saphira/file_items.yml +25 -0
- data/test/functional/saphira/file_items_controller_test.rb +51 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/saphira_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/helpers/saphira/file_items_helper_test.rb +6 -0
- data/test/unit/saphira/file_item_test.rb +9 -0
- metadata +276 -0
@@ -0,0 +1,5 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*/
|
@@ -0,0 +1,7 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
;
|
@@ -0,0 +1,332 @@
|
|
1
|
+
/**
|
2
|
+
* Unobtrusive scripting adapter for jQuery
|
3
|
+
*
|
4
|
+
* Requires jQuery 1.6.0 or later.
|
5
|
+
* https://github.com/rails/jquery-ujs
|
6
|
+
|
7
|
+
* Uploading file using rails.js
|
8
|
+
* =============================
|
9
|
+
*
|
10
|
+
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
11
|
+
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
12
|
+
*
|
13
|
+
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
14
|
+
*
|
15
|
+
* Ex:
|
16
|
+
* $('form').live('ajax:aborted:file', function(event, elements){
|
17
|
+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
18
|
+
* // Returning false in this handler tells rails.js to disallow standard form submission
|
19
|
+
* return false;
|
20
|
+
* });
|
21
|
+
*
|
22
|
+
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
23
|
+
*
|
24
|
+
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
25
|
+
* techniques like the iframe method to upload the file instead.
|
26
|
+
*
|
27
|
+
* Required fields in rails.js
|
28
|
+
* ===========================
|
29
|
+
*
|
30
|
+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
31
|
+
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
32
|
+
*
|
33
|
+
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
34
|
+
*
|
35
|
+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
36
|
+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
37
|
+
*
|
38
|
+
* Ex:
|
39
|
+
* $('form').live('ajax:aborted:required', function(event, elements){
|
40
|
+
* // Returning false in this handler tells rails.js to submit the form anyway.
|
41
|
+
* // The blank required inputs are passed to this function in `elements`.
|
42
|
+
* return ! confirm("Would you like to submit the form with missing info?");
|
43
|
+
* });
|
44
|
+
*/
|
45
|
+
|
46
|
+
|
47
|
+
(function($, undefined) {
|
48
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
49
|
+
var rails;
|
50
|
+
|
51
|
+
$.rails = rails = {
|
52
|
+
// Link elements bound by jquery-ujs
|
53
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]',
|
54
|
+
|
55
|
+
// Select elements bound by jquery-ujs
|
56
|
+
selectChangeSelector: 'select[data-remote]',
|
57
|
+
|
58
|
+
// Form elements bound by jquery-ujs
|
59
|
+
formSubmitSelector: 'form',
|
60
|
+
|
61
|
+
// Form input elements bound by jquery-ujs
|
62
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])',
|
63
|
+
|
64
|
+
// Form input elements disabled during form submission
|
65
|
+
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
66
|
+
|
67
|
+
// Form input elements re-enabled after form submission
|
68
|
+
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
69
|
+
|
70
|
+
// Form required input elements
|
71
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
72
|
+
|
73
|
+
// Form file input elements
|
74
|
+
fileInputSelector: 'input:file',
|
75
|
+
|
76
|
+
// Make sure that every Ajax request sends the CSRF token
|
77
|
+
CSRFProtection: function(xhr) {
|
78
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
79
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
80
|
+
},
|
81
|
+
|
82
|
+
// Triggers an event on an element and returns false if the event result is false
|
83
|
+
fire: function(obj, name, data) {
|
84
|
+
var event = $.Event(name);
|
85
|
+
obj.trigger(event, data);
|
86
|
+
return event.result !== false;
|
87
|
+
},
|
88
|
+
|
89
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
90
|
+
confirm: function(message) {
|
91
|
+
return confirm(message);
|
92
|
+
},
|
93
|
+
|
94
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
95
|
+
ajax: function(options) {
|
96
|
+
return $.ajax(options);
|
97
|
+
},
|
98
|
+
|
99
|
+
// Submits "remote" forms and links with ajax
|
100
|
+
handleRemote: function(element) {
|
101
|
+
var method, url, data,
|
102
|
+
crossDomain = element.data('cross-domain') || null,
|
103
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
104
|
+
|
105
|
+
if (rails.fire(element, 'ajax:before')) {
|
106
|
+
|
107
|
+
if (element.is('form')) {
|
108
|
+
method = element.attr('method');
|
109
|
+
url = element.attr('action');
|
110
|
+
data = element.serializeArray();
|
111
|
+
// memoized value from clicked submit button
|
112
|
+
var button = element.data('ujs:submit-button');
|
113
|
+
if (button) {
|
114
|
+
data.push(button);
|
115
|
+
element.data('ujs:submit-button', null);
|
116
|
+
}
|
117
|
+
} else if (element.is('select')) {
|
118
|
+
method = element.data('method');
|
119
|
+
url = element.data('url');
|
120
|
+
data = element.serialize();
|
121
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
122
|
+
} else {
|
123
|
+
method = element.data('method');
|
124
|
+
url = element.attr('href');
|
125
|
+
data = element.data('params') || null;
|
126
|
+
}
|
127
|
+
|
128
|
+
options = {
|
129
|
+
type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
|
130
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
131
|
+
beforeSend: function(xhr, settings) {
|
132
|
+
if (settings.dataType === undefined) {
|
133
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
134
|
+
}
|
135
|
+
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
136
|
+
},
|
137
|
+
success: function(data, status, xhr) {
|
138
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
139
|
+
},
|
140
|
+
complete: function(xhr, status) {
|
141
|
+
element.trigger('ajax:complete', [xhr, status]);
|
142
|
+
},
|
143
|
+
error: function(xhr, status, error) {
|
144
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
145
|
+
}
|
146
|
+
};
|
147
|
+
// Do not pass url to `ajax` options if blank
|
148
|
+
if (url) { $.extend(options, { url: url }); }
|
149
|
+
|
150
|
+
rails.ajax(options);
|
151
|
+
}
|
152
|
+
},
|
153
|
+
|
154
|
+
// Handles "data-method" on links such as:
|
155
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
156
|
+
handleMethod: function(link) {
|
157
|
+
var href = link.attr('href'),
|
158
|
+
method = link.data('method'),
|
159
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
160
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
161
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
162
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
163
|
+
|
164
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
165
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
166
|
+
}
|
167
|
+
|
168
|
+
form.hide().append(metadata_input).appendTo('body');
|
169
|
+
form.submit();
|
170
|
+
},
|
171
|
+
|
172
|
+
/* Disables form elements:
|
173
|
+
- Caches element value in 'ujs:enable-with' data store
|
174
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
175
|
+
- Adds disabled=disabled attribute
|
176
|
+
*/
|
177
|
+
disableFormElements: function(form) {
|
178
|
+
form.find(rails.disableSelector).each(function() {
|
179
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
180
|
+
element.data('ujs:enable-with', element[method]());
|
181
|
+
element[method](element.data('disable-with'));
|
182
|
+
element.attr('disabled', 'disabled');
|
183
|
+
});
|
184
|
+
},
|
185
|
+
|
186
|
+
/* Re-enables disabled form elements:
|
187
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
188
|
+
- Removes disabled attribute
|
189
|
+
*/
|
190
|
+
enableFormElements: function(form) {
|
191
|
+
form.find(rails.enableSelector).each(function() {
|
192
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
193
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
194
|
+
element.removeAttr('disabled');
|
195
|
+
});
|
196
|
+
},
|
197
|
+
|
198
|
+
/* For 'data-confirm' attribute:
|
199
|
+
- Fires `confirm` event
|
200
|
+
- Shows the confirmation dialog
|
201
|
+
- Fires the `confirm:complete` event
|
202
|
+
|
203
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
204
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
205
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
206
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
207
|
+
*/
|
208
|
+
allowAction: function(element) {
|
209
|
+
var message = element.data('confirm'),
|
210
|
+
answer = false, callback;
|
211
|
+
if (!message) { return true; }
|
212
|
+
|
213
|
+
if (rails.fire(element, 'confirm')) {
|
214
|
+
answer = rails.confirm(message);
|
215
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
216
|
+
}
|
217
|
+
return answer && callback;
|
218
|
+
},
|
219
|
+
|
220
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
221
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
222
|
+
var inputs = $(), input,
|
223
|
+
selector = specifiedSelector || 'input,textarea';
|
224
|
+
form.find(selector).each(function() {
|
225
|
+
input = $(this);
|
226
|
+
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
|
227
|
+
if (nonBlank ? input.val() : !input.val()) {
|
228
|
+
inputs = inputs.add(input);
|
229
|
+
}
|
230
|
+
});
|
231
|
+
return inputs.length ? inputs : false;
|
232
|
+
},
|
233
|
+
|
234
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
235
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
236
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
237
|
+
},
|
238
|
+
|
239
|
+
// Helper function, needed to provide consistent behavior in IE
|
240
|
+
stopEverything: function(e) {
|
241
|
+
$(e.target).trigger('ujs:everythingStopped');
|
242
|
+
e.stopImmediatePropagation();
|
243
|
+
return false;
|
244
|
+
},
|
245
|
+
|
246
|
+
// find all the submit events directly bound to the form and
|
247
|
+
// manually invoke them. If anyone returns false then stop the loop
|
248
|
+
callFormSubmitBindings: function(form) {
|
249
|
+
var events = form.data('events'), continuePropagation = true;
|
250
|
+
if (events !== undefined && events['submit'] !== undefined) {
|
251
|
+
$.each(events['submit'], function(i, obj){
|
252
|
+
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(obj.data);
|
253
|
+
});
|
254
|
+
}
|
255
|
+
return continuePropagation;
|
256
|
+
}
|
257
|
+
};
|
258
|
+
|
259
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
260
|
+
|
261
|
+
$(rails.linkClickSelector).live('click.rails', function(e) {
|
262
|
+
var link = $(this);
|
263
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
264
|
+
|
265
|
+
if (link.data('remote') !== undefined) {
|
266
|
+
rails.handleRemote(link);
|
267
|
+
return false;
|
268
|
+
} else if (link.data('method')) {
|
269
|
+
rails.handleMethod(link);
|
270
|
+
return false;
|
271
|
+
}
|
272
|
+
});
|
273
|
+
|
274
|
+
$(rails.selectChangeSelector).live('change.rails', function(e) {
|
275
|
+
var link = $(this);
|
276
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
277
|
+
|
278
|
+
rails.handleRemote(link);
|
279
|
+
return false;
|
280
|
+
});
|
281
|
+
|
282
|
+
$(rails.formSubmitSelector).live('submit.rails', function(e) {
|
283
|
+
var form = $(this),
|
284
|
+
remote = form.data('remote') !== undefined,
|
285
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
286
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
287
|
+
|
288
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
289
|
+
|
290
|
+
// skip other logic when required values are missing or file upload is present
|
291
|
+
if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
292
|
+
return rails.stopEverything(e);
|
293
|
+
}
|
294
|
+
|
295
|
+
if (remote) {
|
296
|
+
if (nonBlankFileInputs) {
|
297
|
+
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
298
|
+
}
|
299
|
+
|
300
|
+
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
301
|
+
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
302
|
+
if (!$.support.submitBubbles && rails.callFormSubmitBindings(form) === false) return rails.stopEverything(e);
|
303
|
+
|
304
|
+
rails.handleRemote(form);
|
305
|
+
return false;
|
306
|
+
} else {
|
307
|
+
// slight timeout so that the submit button gets properly serialized
|
308
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
309
|
+
}
|
310
|
+
});
|
311
|
+
|
312
|
+
$(rails.formInputClickSelector).live('click.rails', function(event) {
|
313
|
+
var button = $(this);
|
314
|
+
|
315
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
316
|
+
|
317
|
+
// register the pressed submit button
|
318
|
+
var name = button.attr('name'),
|
319
|
+
data = name ? {name:name, value:button.val()} : null;
|
320
|
+
|
321
|
+
button.closest('form').data('ujs:submit-button', data);
|
322
|
+
});
|
323
|
+
|
324
|
+
$(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
|
325
|
+
if (this == event.target) rails.disableFormElements($(this));
|
326
|
+
});
|
327
|
+
|
328
|
+
$(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
|
329
|
+
if (this == event.target) rails.enableFormElements($(this));
|
330
|
+
});
|
331
|
+
|
332
|
+
})( jQuery );
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
name: MyString
|
5
|
+
item_type: MyString
|
6
|
+
file_uid: MyString
|
7
|
+
file_name: MyString
|
8
|
+
slug: MyString
|
9
|
+
path: MyString
|
10
|
+
parent_id: 1
|
11
|
+
lft: 1
|
12
|
+
rgt: 1
|
13
|
+
dynamic_attributes: MyText
|
14
|
+
|
15
|
+
two:
|
16
|
+
name: MyString
|
17
|
+
item_type: MyString
|
18
|
+
file_uid: MyString
|
19
|
+
file_name: MyString
|
20
|
+
slug: MyString
|
21
|
+
path: MyString
|
22
|
+
parent_id: 1
|
23
|
+
lft: 1
|
24
|
+
rgt: 1
|
25
|
+
dynamic_attributes: MyText
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Saphira
|
4
|
+
class FileItemsControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@file_item = file_items(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should get index" do
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert_not_nil assigns(:file_items)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should get new" do
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should create file_item" do
|
21
|
+
assert_difference('FileItem.count') do
|
22
|
+
post :create, file_item: @file_item.attributes
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_redirected_to file_item_path(assigns(:file_item))
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should show file_item" do
|
29
|
+
get :show, id: @file_item.to_param
|
30
|
+
assert_response :success
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should get edit" do
|
34
|
+
get :edit, id: @file_item.to_param
|
35
|
+
assert_response :success
|
36
|
+
end
|
37
|
+
|
38
|
+
test "should update file_item" do
|
39
|
+
put :update, id: @file_item.to_param, file_item: @file_item.attributes
|
40
|
+
assert_redirected_to file_item_path(assigns(:file_item))
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should destroy file_item" do
|
44
|
+
assert_difference('FileItem.count', -1) do
|
45
|
+
delete :destroy, id: @file_item.to_param
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_redirected_to file_items_path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|