attachinary-dox 1.3.1.pre → 1.3.1.pre2

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.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/lib/attachinary/version.rb +1 -1
  4. data/spec/dummy/Gemfile +20 -0
  5. data/spec/dummy/Gemfile.lock +267 -0
  6. data/spec/dummy/Rakefile +7 -0
  7. data/spec/dummy/app/active_record/note.rb +12 -0
  8. data/spec/dummy/app/assets/config/manifest.js +2 -0
  9. data/spec/dummy/app/assets/javascripts/application.js +28 -0
  10. data/spec/dummy/app/assets/stylesheets/application.css +21 -0
  11. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  12. data/spec/dummy/app/controllers/notes_controller.rb +56 -0
  13. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  14. data/spec/dummy/app/views/notes/_form_builder.html.erb +28 -0
  15. data/spec/dummy/app/views/notes/_form_nojs.html.erb +17 -0
  16. data/spec/dummy/app/views/notes/_form_raw.html.erb +28 -0
  17. data/spec/dummy/app/views/notes/_form_simple_form.html.erb +17 -0
  18. data/spec/dummy/app/views/notes/_note.html.erb +15 -0
  19. data/spec/dummy/app/views/notes/edit.html.erb +1 -0
  20. data/spec/dummy/app/views/notes/index.html.erb +12 -0
  21. data/spec/dummy/app/views/notes/new.html.erb +1 -0
  22. data/spec/dummy/config/application.rb +62 -0
  23. data/spec/dummy/config/boot.rb +4 -0
  24. data/spec/dummy/config/cloudinary.yml.example +15 -0
  25. data/spec/dummy/config/database.yml +25 -0
  26. data/spec/dummy/config/environment.rb +5 -0
  27. data/spec/dummy/config/environments/development.rb +33 -0
  28. data/spec/dummy/config/environments/production.rb +63 -0
  29. data/spec/dummy/config/environments/test.rb +37 -0
  30. data/spec/dummy/config/initializers/attachinary.rb +1 -0
  31. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  32. data/spec/dummy/config/initializers/inflections.rb +15 -0
  33. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  34. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  35. data/spec/dummy/config/initializers/session_store.rb +8 -0
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/spec/dummy/config/locales/en.yml +5 -0
  38. data/spec/dummy/config/routes.rb +5 -0
  39. data/spec/dummy/config.ru +4 -0
  40. data/spec/dummy/db/migrate/20120608091037_create_tables.rb +17 -0
  41. data/spec/dummy/db/migrate/20120608104143_create_notes.rb +9 -0
  42. data/spec/dummy/db/schema.rb +35 -0
  43. data/spec/dummy/script/rails +6 -0
  44. data/spec/dummy/spec/rails_helper.rb +48 -0
  45. data/spec/dummy/spec/spec_helper.rb +92 -0
  46. data/spec/dummy/vendor/assets/javascripts/jquery.fileupload.js +1604 -0
  47. data/spec/dummy/vendor/assets/javascripts/jquery.iframe-transport.js +227 -0
  48. data/spec/dummy/vendor/assets/javascripts/jquery.ui.widget.js +528 -0
  49. data/spec/factories.rb +17 -0
  50. data/spec/features/notes_spec.rb +97 -0
  51. data/spec/models/attachinary/file_spec.rb +44 -0
  52. data/spec/models/note_spec.rb +176 -0
  53. data/spec/spec_helper.rb +78 -0
  54. data/spec/support/A.gif +0 -0
  55. data/spec/support/A.txt +1 -0
  56. data/spec/support/B.gif +0 -0
  57. data/spec/support/C.gif +0 -0
  58. data/spec/support/request_helpers.rb +16 -0
  59. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/bigdecimal-3.1.9/gem_make.out +5 -5
  60. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/bigdecimal-3.1.9/mkmf.log +3 -3
  61. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/cgi-0.4.2/gem_make.out +5 -5
  62. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/date-3.4.1/gem_make.out +5 -5
  63. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/erb-4.0.4/gem_make.out +5 -5
  64. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/io-console-0.8.0/gem_make.out +5 -5
  65. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/json-2.12.0/gem_make.out +5 -5
  66. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/mini_racer-0.18.1/gem_make.out +5 -5
  67. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/nio4r-2.7.4/gem_make.out +5 -5
  68. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/psych-5.2.6/gem_make.out +5 -5
  69. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/puma-6.4.2/gem_make.out +5 -5
  70. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/racc-1.8.1/gem_make.out +5 -5
  71. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/stringio-3.1.7/gem_make.out +5 -5
  72. data/vendor/bundle/ruby/3.3.0/extensions/x86_64-linux/3.3.0/websocket-driver-0.7.7/gem_make.out +5 -5
  73. metadata +114 -160
  74. data/lib/tasks/ci.rake +0 -16
  75. data/vendor/cache/actioncable-7.2.2.1.gem +0 -0
  76. data/vendor/cache/actionmailbox-7.2.2.1.gem +0 -0
  77. data/vendor/cache/actionmailer-7.2.2.1.gem +0 -0
  78. data/vendor/cache/actionpack-7.2.2.1.gem +0 -0
  79. data/vendor/cache/actiontext-7.2.2.1.gem +0 -0
  80. data/vendor/cache/actionview-7.2.2.1.gem +0 -0
  81. data/vendor/cache/activejob-7.2.2.1.gem +0 -0
  82. data/vendor/cache/activemodel-7.2.2.1.gem +0 -0
  83. data/vendor/cache/activerecord-7.2.2.1.gem +0 -0
  84. data/vendor/cache/activestorage-7.2.2.1.gem +0 -0
  85. data/vendor/cache/activesupport-7.2.2.1.gem +0 -0
  86. data/vendor/cache/addressable-2.8.7.gem +0 -0
  87. data/vendor/cache/base64-0.2.0.gem +0 -0
  88. data/vendor/cache/benchmark-0.4.0.gem +0 -0
  89. data/vendor/cache/bigdecimal-3.1.9.gem +0 -0
  90. data/vendor/cache/builder-3.3.0.gem +0 -0
  91. data/vendor/cache/capybara-3.40.0.gem +0 -0
  92. data/vendor/cache/capybara-screenshot-1.0.26.gem +0 -0
  93. data/vendor/cache/cgi-0.4.2.gem +0 -0
  94. data/vendor/cache/childprocess-5.1.0.gem +0 -0
  95. data/vendor/cache/cloudinary-2.3.0.gem +0 -0
  96. data/vendor/cache/coderay-1.1.3.gem +0 -0
  97. data/vendor/cache/coffee-rails-5.0.0.gem +0 -0
  98. data/vendor/cache/coffee-script-2.4.1.gem +0 -0
  99. data/vendor/cache/coffee-script-source-1.12.2.gem +0 -0
  100. data/vendor/cache/concurrent-ruby-1.3.5.gem +0 -0
  101. data/vendor/cache/connection_pool-2.5.3.gem +0 -0
  102. data/vendor/cache/crass-1.0.6.gem +0 -0
  103. data/vendor/cache/database_cleaner-2.1.0.gem +0 -0
  104. data/vendor/cache/database_cleaner-active_record-2.2.1.gem +0 -0
  105. data/vendor/cache/database_cleaner-core-2.0.1.gem +0 -0
  106. data/vendor/cache/date-3.4.1.gem +0 -0
  107. data/vendor/cache/diff-lcs-1.6.2.gem +0 -0
  108. data/vendor/cache/dotenv-3.1.2.gem +0 -0
  109. data/vendor/cache/drb-2.2.3.gem +0 -0
  110. data/vendor/cache/erb-4.0.4.gem +0 -0
  111. data/vendor/cache/erubi-1.13.1.gem +0 -0
  112. data/vendor/cache/execjs-2.10.0.gem +0 -0
  113. data/vendor/cache/factory_bot-6.5.1.gem +0 -0
  114. data/vendor/cache/factory_bot_rails-6.4.4.gem +0 -0
  115. data/vendor/cache/faraday-2.13.1.gem +0 -0
  116. data/vendor/cache/faraday-follow_redirects-0.3.0.gem +0 -0
  117. data/vendor/cache/faraday-multipart-1.1.0.gem +0 -0
  118. data/vendor/cache/faraday-net_http-3.4.0.gem +0 -0
  119. data/vendor/cache/ffi-1.17.2-aarch64-linux-gnu.gem +0 -0
  120. data/vendor/cache/ffi-1.17.2-aarch64-linux-musl.gem +0 -0
  121. data/vendor/cache/ffi-1.17.2-arm-linux-gnu.gem +0 -0
  122. data/vendor/cache/ffi-1.17.2-arm-linux-musl.gem +0 -0
  123. data/vendor/cache/ffi-1.17.2-arm64-darwin.gem +0 -0
  124. data/vendor/cache/ffi-1.17.2-x86_64-darwin.gem +0 -0
  125. data/vendor/cache/ffi-1.17.2-x86_64-linux-gnu.gem +0 -0
  126. data/vendor/cache/ffi-1.17.2-x86_64-linux-musl.gem +0 -0
  127. data/vendor/cache/formatador-1.1.0.gem +0 -0
  128. data/vendor/cache/globalid-1.2.1.gem +0 -0
  129. data/vendor/cache/guard-2.19.1.gem +0 -0
  130. data/vendor/cache/guard-compat-1.2.1.gem +0 -0
  131. data/vendor/cache/guard-rspec-4.7.3.gem +0 -0
  132. data/vendor/cache/i18n-1.14.7.gem +0 -0
  133. data/vendor/cache/io-console-0.8.0.gem +0 -0
  134. data/vendor/cache/irb-1.15.2.gem +0 -0
  135. data/vendor/cache/jquery-rails-4.6.0.gem +0 -0
  136. data/vendor/cache/json-2.12.0.gem +0 -0
  137. data/vendor/cache/launchy-3.1.1.gem +0 -0
  138. data/vendor/cache/libv8-node-23.6.1.0-aarch64-linux.gem +0 -0
  139. data/vendor/cache/libv8-node-23.6.1.0-arm64-darwin.gem +0 -0
  140. data/vendor/cache/libv8-node-23.6.1.0-x86_64-darwin.gem +0 -0
  141. data/vendor/cache/libv8-node-23.6.1.0-x86_64-linux-musl.gem +0 -0
  142. data/vendor/cache/libv8-node-23.6.1.0-x86_64-linux.gem +0 -0
  143. data/vendor/cache/libv8-node-23.6.1.0.gem +0 -0
  144. data/vendor/cache/listen-3.0.8.gem +0 -0
  145. data/vendor/cache/logger-1.7.0.gem +0 -0
  146. data/vendor/cache/loofah-2.24.1.gem +0 -0
  147. data/vendor/cache/lumberjack-1.2.10.gem +0 -0
  148. data/vendor/cache/mail-2.8.1.gem +0 -0
  149. data/vendor/cache/marcel-1.0.4.gem +0 -0
  150. data/vendor/cache/matrix-0.4.2.gem +0 -0
  151. data/vendor/cache/method_source-1.1.0.gem +0 -0
  152. data/vendor/cache/mime-types-3.7.0.gem +0 -0
  153. data/vendor/cache/mime-types-data-3.2025.0520.gem +0 -0
  154. data/vendor/cache/mini_mime-1.1.5.gem +0 -0
  155. data/vendor/cache/mini_racer-0.18.1.gem +0 -0
  156. data/vendor/cache/minitest-5.25.5.gem +0 -0
  157. data/vendor/cache/multipart-post-2.4.1.gem +0 -0
  158. data/vendor/cache/nenv-0.3.0.gem +0 -0
  159. data/vendor/cache/net-http-0.6.0.gem +0 -0
  160. data/vendor/cache/net-imap-0.5.8.gem +0 -0
  161. data/vendor/cache/net-pop-0.1.2.gem +0 -0
  162. data/vendor/cache/net-protocol-0.2.2.gem +0 -0
  163. data/vendor/cache/net-smtp-0.5.1.gem +0 -0
  164. data/vendor/cache/nio4r-2.7.4.gem +0 -0
  165. data/vendor/cache/nokogiri-1.18.8-aarch64-linux-gnu.gem +0 -0
  166. data/vendor/cache/nokogiri-1.18.8-aarch64-linux-musl.gem +0 -0
  167. data/vendor/cache/nokogiri-1.18.8-arm-linux-gnu.gem +0 -0
  168. data/vendor/cache/nokogiri-1.18.8-arm-linux-musl.gem +0 -0
  169. data/vendor/cache/nokogiri-1.18.8-arm64-darwin.gem +0 -0
  170. data/vendor/cache/nokogiri-1.18.8-x86_64-darwin.gem +0 -0
  171. data/vendor/cache/nokogiri-1.18.8-x86_64-linux-gnu.gem +0 -0
  172. data/vendor/cache/nokogiri-1.18.8-x86_64-linux-musl.gem +0 -0
  173. data/vendor/cache/notiffany-0.1.3.gem +0 -0
  174. data/vendor/cache/ostruct-0.6.1.gem +0 -0
  175. data/vendor/cache/pp-0.6.2.gem +0 -0
  176. data/vendor/cache/prettyprint-0.2.0.gem +0 -0
  177. data/vendor/cache/pry-0.15.2.gem +0 -0
  178. data/vendor/cache/psych-5.2.6.gem +0 -0
  179. data/vendor/cache/public_suffix-6.0.2.gem +0 -0
  180. data/vendor/cache/puma-6.4.2.gem +0 -0
  181. data/vendor/cache/racc-1.8.1.gem +0 -0
  182. data/vendor/cache/rack-3.1.15.gem +0 -0
  183. data/vendor/cache/rack-session-2.1.1.gem +0 -0
  184. data/vendor/cache/rack-test-2.2.0.gem +0 -0
  185. data/vendor/cache/rackup-2.2.1.gem +0 -0
  186. data/vendor/cache/rails-7.2.2.1.gem +0 -0
  187. data/vendor/cache/rails-dom-testing-2.3.0.gem +0 -0
  188. data/vendor/cache/rails-html-sanitizer-1.6.2.gem +0 -0
  189. data/vendor/cache/railties-7.2.2.1.gem +0 -0
  190. data/vendor/cache/rake-13.2.1.gem +0 -0
  191. data/vendor/cache/rb-fsevent-0.9.8.gem +0 -0
  192. data/vendor/cache/rb-inotify-0.11.1.gem +0 -0
  193. data/vendor/cache/rdoc-6.14.0.gem +0 -0
  194. data/vendor/cache/regexp_parser-2.10.0.gem +0 -0
  195. data/vendor/cache/reline-0.6.1.gem +0 -0
  196. data/vendor/cache/rexml-3.4.1.gem +0 -0
  197. data/vendor/cache/rspec-3.13.0.gem +0 -0
  198. data/vendor/cache/rspec-core-3.13.3.gem +0 -0
  199. data/vendor/cache/rspec-expectations-3.13.4.gem +0 -0
  200. data/vendor/cache/rspec-mocks-3.13.4.gem +0 -0
  201. data/vendor/cache/rspec-rails-8.0.0.gem +0 -0
  202. data/vendor/cache/rspec-support-3.13.3.gem +0 -0
  203. data/vendor/cache/rspec_junit_formatter-0.6.0.gem +0 -0
  204. data/vendor/cache/rubyzip-2.4.1.gem +0 -0
  205. data/vendor/cache/securerandom-0.4.1.gem +0 -0
  206. data/vendor/cache/selenium-webdriver-4.32.0.gem +0 -0
  207. data/vendor/cache/shellany-0.0.1.gem +0 -0
  208. data/vendor/cache/simple_form-5.3.1.gem +0 -0
  209. data/vendor/cache/sprockets-4.2.1.gem +0 -0
  210. data/vendor/cache/sprockets-rails-3.5.2.gem +0 -0
  211. data/vendor/cache/sqlite3-2.6.0-aarch64-linux-gnu.gem +0 -0
  212. data/vendor/cache/sqlite3-2.6.0-aarch64-linux-musl.gem +0 -0
  213. data/vendor/cache/sqlite3-2.6.0-arm-linux-gnu.gem +0 -0
  214. data/vendor/cache/sqlite3-2.6.0-arm-linux-musl.gem +0 -0
  215. data/vendor/cache/sqlite3-2.6.0-arm64-darwin.gem +0 -0
  216. data/vendor/cache/sqlite3-2.6.0-x86_64-darwin.gem +0 -0
  217. data/vendor/cache/sqlite3-2.6.0-x86_64-linux-gnu.gem +0 -0
  218. data/vendor/cache/sqlite3-2.6.0-x86_64-linux-musl.gem +0 -0
  219. data/vendor/cache/stringio-3.1.7.gem +0 -0
  220. data/vendor/cache/thor-1.3.2.gem +0 -0
  221. data/vendor/cache/timeout-0.4.3.gem +0 -0
  222. data/vendor/cache/tzinfo-2.0.6.gem +0 -0
  223. data/vendor/cache/uri-1.0.3.gem +0 -0
  224. data/vendor/cache/useragent-0.16.11.gem +0 -0
  225. data/vendor/cache/valid_attribute-2.0.0.gem +0 -0
  226. data/vendor/cache/websocket-1.2.11.gem +0 -0
  227. data/vendor/cache/websocket-driver-0.7.7.gem +0 -0
  228. data/vendor/cache/websocket-extensions-0.1.5.gem +0 -0
  229. data/vendor/cache/xpath-3.2.0.gem +0 -0
  230. data/vendor/cache/zeitwerk-2.6.18.gem +0 -0
@@ -0,0 +1,528 @@
1
+ /*
2
+ * jQuery UI Widget 1.9.1+amd
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2012 jQuery Foundation and other contributors
6
+ * Released under the MIT license.
7
+ * http://jquery.org/license
8
+ *
9
+ * http://api.jqueryui.com/jQuery.widget/
10
+ */
11
+
12
+ (function (factory) {
13
+ if (typeof define === "function" && define.amd) {
14
+ // Register as an anonymous AMD module:
15
+ define(["jquery"], factory);
16
+ } else {
17
+ // Browser globals:
18
+ factory(jQuery);
19
+ }
20
+ }(function( $, undefined ) {
21
+
22
+ var uuid = 0,
23
+ slice = Array.prototype.slice,
24
+ _cleanData = $.cleanData;
25
+ $.cleanData = function( elems ) {
26
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
27
+ try {
28
+ $( elem ).triggerHandler( "remove" );
29
+ // http://bugs.jquery.com/ticket/8235
30
+ } catch( e ) {}
31
+ }
32
+ _cleanData( elems );
33
+ };
34
+
35
+ $.widget = function( name, base, prototype ) {
36
+ var fullName, existingConstructor, constructor, basePrototype,
37
+ namespace = name.split( "." )[ 0 ];
38
+
39
+ name = name.split( "." )[ 1 ];
40
+ fullName = namespace + "-" + name;
41
+
42
+ if ( !prototype ) {
43
+ prototype = base;
44
+ base = $.Widget;
45
+ }
46
+
47
+ // create selector for plugin
48
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
49
+ return !!$.data( elem, fullName );
50
+ };
51
+
52
+ $[ namespace ] = $[ namespace ] || {};
53
+ existingConstructor = $[ namespace ][ name ];
54
+ constructor = $[ namespace ][ name ] = function( options, element ) {
55
+ // allow instantiation without "new" keyword
56
+ if ( !this._createWidget ) {
57
+ return new constructor( options, element );
58
+ }
59
+
60
+ // allow instantiation without initializing for simple inheritance
61
+ // must use "new" keyword (the code above always passes args)
62
+ if ( arguments.length ) {
63
+ this._createWidget( options, element );
64
+ }
65
+ };
66
+ // extend with the existing constructor to carry over any static properties
67
+ $.extend( constructor, existingConstructor, {
68
+ version: prototype.version,
69
+ // copy the object used to create the prototype in case we need to
70
+ // redefine the widget later
71
+ _proto: $.extend( {}, prototype ),
72
+ // track widgets that inherit from this widget in case this widget is
73
+ // redefined after a widget inherits from it
74
+ _childConstructors: []
75
+ });
76
+
77
+ basePrototype = new base();
78
+ // we need to make the options hash a property directly on the new instance
79
+ // otherwise we'll modify the options hash on the prototype that we're
80
+ // inheriting from
81
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
82
+ $.each( prototype, function( prop, value ) {
83
+ if ( $.isFunction( value ) ) {
84
+ prototype[ prop ] = (function() {
85
+ var _super = function() {
86
+ return base.prototype[ prop ].apply( this, arguments );
87
+ },
88
+ _superApply = function( args ) {
89
+ return base.prototype[ prop ].apply( this, args );
90
+ };
91
+ return function() {
92
+ var __super = this._super,
93
+ __superApply = this._superApply,
94
+ returnValue;
95
+
96
+ this._super = _super;
97
+ this._superApply = _superApply;
98
+
99
+ returnValue = value.apply( this, arguments );
100
+
101
+ this._super = __super;
102
+ this._superApply = __superApply;
103
+
104
+ return returnValue;
105
+ };
106
+ })();
107
+ }
108
+ });
109
+ constructor.prototype = $.widget.extend( basePrototype, {
110
+ // TODO: remove support for widgetEventPrefix
111
+ // always use the name + a colon as the prefix, e.g., draggable:start
112
+ // don't prefix for widgets that aren't DOM-based
113
+ widgetEventPrefix: basePrototype.widgetEventPrefix || name
114
+ }, prototype, {
115
+ constructor: constructor,
116
+ namespace: namespace,
117
+ widgetName: name,
118
+ // TODO remove widgetBaseClass, see #8155
119
+ widgetBaseClass: fullName,
120
+ widgetFullName: fullName
121
+ });
122
+
123
+ // If this widget is being redefined then we need to find all widgets that
124
+ // are inheriting from it and redefine all of them so that they inherit from
125
+ // the new version of this widget. We're essentially trying to replace one
126
+ // level in the prototype chain.
127
+ if ( existingConstructor ) {
128
+ $.each( existingConstructor._childConstructors, function( i, child ) {
129
+ var childPrototype = child.prototype;
130
+
131
+ // redefine the child widget using the same prototype that was
132
+ // originally used, but inherit from the new version of the base
133
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
134
+ });
135
+ // remove the list of existing child constructors from the old constructor
136
+ // so the old child constructors can be garbage collected
137
+ delete existingConstructor._childConstructors;
138
+ } else {
139
+ base._childConstructors.push( constructor );
140
+ }
141
+
142
+ $.widget.bridge( name, constructor );
143
+ };
144
+
145
+ $.widget.extend = function( target ) {
146
+ var input = slice.call( arguments, 1 ),
147
+ inputIndex = 0,
148
+ inputLength = input.length,
149
+ key,
150
+ value;
151
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
152
+ for ( key in input[ inputIndex ] ) {
153
+ value = input[ inputIndex ][ key ];
154
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
155
+ // Clone objects
156
+ if ( $.isPlainObject( value ) ) {
157
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
158
+ $.widget.extend( {}, target[ key ], value ) :
159
+ // Don't extend strings, arrays, etc. with objects
160
+ $.widget.extend( {}, value );
161
+ // Copy everything else by reference
162
+ } else {
163
+ target[ key ] = value;
164
+ }
165
+ }
166
+ }
167
+ }
168
+ return target;
169
+ };
170
+
171
+ $.widget.bridge = function( name, object ) {
172
+ var fullName = object.prototype.widgetFullName;
173
+ $.fn[ name ] = function( options ) {
174
+ var isMethodCall = typeof options === "string",
175
+ args = slice.call( arguments, 1 ),
176
+ returnValue = this;
177
+
178
+ // allow multiple hashes to be passed on init
179
+ options = !isMethodCall && args.length ?
180
+ $.widget.extend.apply( null, [ options ].concat(args) ) :
181
+ options;
182
+
183
+ if ( isMethodCall ) {
184
+ this.each(function() {
185
+ var methodValue,
186
+ instance = $.data( this, fullName );
187
+ if ( !instance ) {
188
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
189
+ "attempted to call method '" + options + "'" );
190
+ }
191
+ if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
192
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
193
+ }
194
+ methodValue = instance[ options ].apply( instance, args );
195
+ if ( methodValue !== instance && methodValue !== undefined ) {
196
+ returnValue = methodValue && methodValue.jquery ?
197
+ returnValue.pushStack( methodValue.get() ) :
198
+ methodValue;
199
+ return false;
200
+ }
201
+ });
202
+ } else {
203
+ this.each(function() {
204
+ var instance = $.data( this, fullName );
205
+ if ( instance ) {
206
+ instance.option( options || {} )._init();
207
+ } else {
208
+ new object( options, this );
209
+ }
210
+ });
211
+ }
212
+
213
+ return returnValue;
214
+ };
215
+ };
216
+
217
+ $.Widget = function( /* options, element */ ) {};
218
+ $.Widget._childConstructors = [];
219
+
220
+ $.Widget.prototype = {
221
+ widgetName: "widget",
222
+ widgetEventPrefix: "",
223
+ defaultElement: "<div>",
224
+ options: {
225
+ disabled: false,
226
+
227
+ // callbacks
228
+ create: null
229
+ },
230
+ _createWidget: function( options, element ) {
231
+ element = $( element || this.defaultElement || this )[ 0 ];
232
+ this.element = $( element );
233
+ this.uuid = uuid++;
234
+ this.eventNamespace = "." + this.widgetName + this.uuid;
235
+ this.options = $.widget.extend( {},
236
+ this.options,
237
+ this._getCreateOptions(),
238
+ options );
239
+
240
+ this.bindings = $();
241
+ this.hoverable = $();
242
+ this.focusable = $();
243
+
244
+ if ( element !== this ) {
245
+ // 1.9 BC for #7810
246
+ // TODO remove dual storage
247
+ $.data( element, this.widgetName, this );
248
+ $.data( element, this.widgetFullName, this );
249
+ this._on( this.element, {
250
+ remove: function( event ) {
251
+ if ( event.target === element ) {
252
+ this.destroy();
253
+ }
254
+ }
255
+ });
256
+ this.document = $( element.style ?
257
+ // element within the document
258
+ element.ownerDocument :
259
+ // element is window or document
260
+ element.document || element );
261
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
262
+ }
263
+
264
+ this._create();
265
+ this._trigger( "create", null, this._getCreateEventData() );
266
+ this._init();
267
+ },
268
+ _getCreateOptions: $.noop,
269
+ _getCreateEventData: $.noop,
270
+ _create: $.noop,
271
+ _init: $.noop,
272
+
273
+ destroy: function() {
274
+ this._destroy();
275
+ // we can probably remove the unbind calls in 2.0
276
+ // all event bindings should go through this._on()
277
+ this.element
278
+ .unbind( this.eventNamespace )
279
+ // 1.9 BC for #7810
280
+ // TODO remove dual storage
281
+ .removeData( this.widgetName )
282
+ .removeData( this.widgetFullName )
283
+ // support: jquery <1.6.3
284
+ // http://bugs.jquery.com/ticket/9413
285
+ .removeData( $.camelCase( this.widgetFullName ) );
286
+ this.widget()
287
+ .unbind( this.eventNamespace )
288
+ .removeAttr( "aria-disabled" )
289
+ .removeClass(
290
+ this.widgetFullName + "-disabled " +
291
+ "ui-state-disabled" );
292
+
293
+ // clean up events and states
294
+ this.bindings.unbind( this.eventNamespace );
295
+ this.hoverable.removeClass( "ui-state-hover" );
296
+ this.focusable.removeClass( "ui-state-focus" );
297
+ },
298
+ _destroy: $.noop,
299
+
300
+ widget: function() {
301
+ return this.element;
302
+ },
303
+
304
+ option: function( key, value ) {
305
+ var options = key,
306
+ parts,
307
+ curOption,
308
+ i;
309
+
310
+ if ( arguments.length === 0 ) {
311
+ // don't return a reference to the internal hash
312
+ return $.widget.extend( {}, this.options );
313
+ }
314
+
315
+ if ( typeof key === "string" ) {
316
+ // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
317
+ options = {};
318
+ parts = key.split( "." );
319
+ key = parts.shift();
320
+ if ( parts.length ) {
321
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
322
+ for ( i = 0; i < parts.length - 1; i++ ) {
323
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
324
+ curOption = curOption[ parts[ i ] ];
325
+ }
326
+ key = parts.pop();
327
+ if ( value === undefined ) {
328
+ return curOption[ key ] === undefined ? null : curOption[ key ];
329
+ }
330
+ curOption[ key ] = value;
331
+ } else {
332
+ if ( value === undefined ) {
333
+ return this.options[ key ] === undefined ? null : this.options[ key ];
334
+ }
335
+ options[ key ] = value;
336
+ }
337
+ }
338
+
339
+ this._setOptions( options );
340
+
341
+ return this;
342
+ },
343
+ _setOptions: function( options ) {
344
+ var key;
345
+
346
+ for ( key in options ) {
347
+ this._setOption( key, options[ key ] );
348
+ }
349
+
350
+ return this;
351
+ },
352
+ _setOption: function( key, value ) {
353
+ this.options[ key ] = value;
354
+
355
+ if ( key === "disabled" ) {
356
+ this.widget()
357
+ .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
358
+ .attr( "aria-disabled", value );
359
+ this.hoverable.removeClass( "ui-state-hover" );
360
+ this.focusable.removeClass( "ui-state-focus" );
361
+ }
362
+
363
+ return this;
364
+ },
365
+
366
+ enable: function() {
367
+ return this._setOption( "disabled", false );
368
+ },
369
+ disable: function() {
370
+ return this._setOption( "disabled", true );
371
+ },
372
+
373
+ _on: function( element, handlers ) {
374
+ var delegateElement,
375
+ instance = this;
376
+ // no element argument, shuffle and use this.element
377
+ if ( !handlers ) {
378
+ handlers = element;
379
+ element = this.element;
380
+ delegateElement = this.widget();
381
+ } else {
382
+ // accept selectors, DOM elements
383
+ element = delegateElement = $( element );
384
+ this.bindings = this.bindings.add( element );
385
+ }
386
+
387
+ $.each( handlers, function( event, handler ) {
388
+ function handlerProxy() {
389
+ // allow widgets to customize the disabled handling
390
+ // - disabled as an array instead of boolean
391
+ // - disabled class as method for disabling individual parts
392
+ if ( instance.options.disabled === true ||
393
+ $( this ).hasClass( "ui-state-disabled" ) ) {
394
+ return;
395
+ }
396
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
397
+ .apply( instance, arguments );
398
+ }
399
+
400
+ // copy the guid so direct unbinding works
401
+ if ( typeof handler !== "string" ) {
402
+ handlerProxy.guid = handler.guid =
403
+ handler.guid || handlerProxy.guid || $.guid++;
404
+ }
405
+
406
+ var match = event.match( /^(\w+)\s*(.*)$/ ),
407
+ eventName = match[1] + instance.eventNamespace,
408
+ selector = match[2];
409
+ if ( selector ) {
410
+ delegateElement.delegate( selector, eventName, handlerProxy );
411
+ } else {
412
+ element.bind( eventName, handlerProxy );
413
+ }
414
+ });
415
+ },
416
+
417
+ _off: function( element, eventName ) {
418
+ eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
419
+ element.unbind( eventName ).undelegate( eventName );
420
+ },
421
+
422
+ _delay: function( handler, delay ) {
423
+ function handlerProxy() {
424
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
425
+ .apply( instance, arguments );
426
+ }
427
+ var instance = this;
428
+ return setTimeout( handlerProxy, delay || 0 );
429
+ },
430
+
431
+ _hoverable: function( element ) {
432
+ this.hoverable = this.hoverable.add( element );
433
+ this._on( element, {
434
+ mouseenter: function( event ) {
435
+ $( event.currentTarget ).addClass( "ui-state-hover" );
436
+ },
437
+ mouseleave: function( event ) {
438
+ $( event.currentTarget ).removeClass( "ui-state-hover" );
439
+ }
440
+ });
441
+ },
442
+
443
+ _focusable: function( element ) {
444
+ this.focusable = this.focusable.add( element );
445
+ this._on( element, {
446
+ focusin: function( event ) {
447
+ $( event.currentTarget ).addClass( "ui-state-focus" );
448
+ },
449
+ focusout: function( event ) {
450
+ $( event.currentTarget ).removeClass( "ui-state-focus" );
451
+ }
452
+ });
453
+ },
454
+
455
+ _trigger: function( type, event, data ) {
456
+ var prop, orig,
457
+ callback = this.options[ type ];
458
+
459
+ data = data || {};
460
+ event = $.Event( event );
461
+ event.type = ( type === this.widgetEventPrefix ?
462
+ type :
463
+ this.widgetEventPrefix + type ).toLowerCase();
464
+ // the original event may come from any element
465
+ // so we need to reset the target on the new event
466
+ event.target = this.element[ 0 ];
467
+
468
+ // copy original event properties over to the new event
469
+ orig = event.originalEvent;
470
+ if ( orig ) {
471
+ for ( prop in orig ) {
472
+ if ( !( prop in event ) ) {
473
+ event[ prop ] = orig[ prop ];
474
+ }
475
+ }
476
+ }
477
+
478
+ this.element.trigger( event, data );
479
+ return !( $.isFunction( callback ) &&
480
+ callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
481
+ event.isDefaultPrevented() );
482
+ }
483
+ };
484
+
485
+ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
486
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
487
+ if ( typeof options === "string" ) {
488
+ options = { effect: options };
489
+ }
490
+ var hasOptions,
491
+ effectName = !options ?
492
+ method :
493
+ options === true || typeof options === "number" ?
494
+ defaultEffect :
495
+ options.effect || defaultEffect;
496
+ options = options || {};
497
+ if ( typeof options === "number" ) {
498
+ options = { duration: options };
499
+ }
500
+ hasOptions = !$.isEmptyObject( options );
501
+ options.complete = callback;
502
+ if ( options.delay ) {
503
+ element.delay( options.delay );
504
+ }
505
+ if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
506
+ element[ method ]( options );
507
+ } else if ( effectName !== method && element[ effectName ] ) {
508
+ element[ effectName ]( options.duration, options.easing, callback );
509
+ } else {
510
+ element.queue(function( next ) {
511
+ $( this )[ method ]();
512
+ if ( callback ) {
513
+ callback.call( element[ 0 ] );
514
+ }
515
+ next();
516
+ });
517
+ }
518
+ };
519
+ });
520
+
521
+ // DEPRECATED
522
+ if ( $.uiBackCompat !== false ) {
523
+ $.Widget.prototype._getCreateOptions = function() {
524
+ return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
525
+ };
526
+ }
527
+
528
+ }));
data/spec/factories.rb ADDED
@@ -0,0 +1,17 @@
1
+ FactoryBot.define do
2
+ factory :note do
3
+ sequence(:body) { |n| "Note ##{n}"}
4
+ after(:build) do |note|
5
+ note.photo ||= FactoryBot.build(:file)
6
+ end
7
+ end
8
+
9
+ factory :file, class: Attachinary::File do
10
+ sequence(:public_id) { |n| "id#{n}"}
11
+ sequence(:version) { |n| "#{n}"}
12
+ width { 800 }
13
+ height { 600 }
14
+ format { 'jpg' }
15
+ resource_type { 'image' }
16
+ end
17
+ end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Notes', type: :feature do
4
+ Capybara.default_max_wait_time = 15
5
+
6
+ describe 'Creating new note' do
7
+
8
+ shared_examples_for "any form" do
9
+ before do
10
+ visit path
11
+ end
12
+
13
+ it 'display an alert if invalid file format is uploaded', :js => true do
14
+ within 'div.photo' do
15
+ accept_alert 'Invalid file format' do
16
+ attach_file 'note[photo]', "#{SPEC_ROOT}/support/A.txt"
17
+ end
18
+ end
19
+ end
20
+
21
+ it 'disables input when first photo is uploaded', :js => true do
22
+ within 'div.photo' do
23
+ attach_file "note[photo]", "#{SPEC_ROOT}/support/A.gif"
24
+ expect(page).to have_css 'input[disabled]'
25
+ end
26
+ end
27
+
28
+ it 'allows multiple images to be uploaded', :js => true do
29
+ within 'div.images' do
30
+ attach_file "note[images][]", "#{SPEC_ROOT}/support/A.gif"
31
+ value = find(:xpath, './/input[@name="note[images][]" and @type="hidden" and contains(@value, \'"A"\')]', :visible => false).value
32
+ images = ActiveSupport::JSON.decode( value)
33
+ expect(images.length).to be 1
34
+ expect(images.map{|i| i["original_filename"]}).to eq ["A"]
35
+ attach_file "note[images][]", "#{SPEC_ROOT}/support/B.gif"
36
+ value = find(:xpath, './/input[@name="note[images][]" and @type="hidden" and contains(@value, \'"B"\')]', :visible => false).value
37
+ images = ActiveSupport::JSON.decode( value)
38
+ expect(images.length).to be 2
39
+ expect(images.map{|i| i["original_filename"]}.sort).to eq ["A", "B"]
40
+ end
41
+ end
42
+
43
+ it 'preserves uploaded photo across postbacks', :js => true do
44
+ within 'div.photo' do
45
+ attach_file "note[photo]", "#{SPEC_ROOT}/support/A.gif"
46
+ expect(page).to have_css 'img'
47
+ end
48
+
49
+ expect(page).to have_button 'Create Note' # wait for it to appear
50
+ click_button 'Create Note'
51
+
52
+ within 'div.photo' do
53
+ expect(page).to have_css 'img'
54
+ end
55
+ end
56
+
57
+ it 'validates presence of photo', :js => true do
58
+ click_button 'Create Note'
59
+ within 'div.photo' do
60
+ expect(page).to have_content "can't be blank"
61
+ end
62
+ end
63
+
64
+ it 'saves the record', :js => true do
65
+ fill_in 'note[body]', with: 'My Note'
66
+ within 'div.photo' do
67
+ attach_file "note[photo]", "#{SPEC_ROOT}/support/A.gif"
68
+ end
69
+ click_button 'Create Note'
70
+
71
+ expect(page).to have_current_path notes_path
72
+ expect(page).to have_content 'My Note'
73
+ expect(page).to have_css 'img'
74
+ end
75
+
76
+ end
77
+
78
+
79
+ context 'raw form', :js do
80
+ let(:path) { new_note_path(kind: 'raw') }
81
+ it_behaves_like "any form"
82
+ end
83
+
84
+ context 'builder form', :js do
85
+ let(:path) { new_note_path(kind: 'builder') }
86
+ it_behaves_like "any form"
87
+ end
88
+
89
+
90
+ context 'simple_form', :js do
91
+ let(:path) { new_note_path(kind: 'simple_form') }
92
+ it_behaves_like "any form"
93
+ end
94
+
95
+ end
96
+
97
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Attachinary::File do
4
+ subject { build(:file) }
5
+
6
+ describe 'validations' do
7
+ it { should be_valid }
8
+ it { should_not have_valid(:public_id).when(nil) }
9
+ it { should_not have_valid(:version).when(nil) }
10
+ it { should_not have_valid(:resource_type).when(nil) }
11
+ end
12
+
13
+ describe '#path(custom_format=nil)' do
14
+ context "image resource_type" do
15
+ subject { build(:file, public_id: 'id', version: '1', format: 'jpg', resource_type: 'image') }
16
+
17
+ it 'allows you to pick format' do
18
+ expect(subject.path).to eq 'v1/id.jpg'
19
+ expect(subject.path('png')).to eq 'v1/id.png'
20
+ expect(subject.path(false)).to eq 'v1/id'
21
+ end
22
+ end
23
+
24
+ context "raw resource_type" do
25
+ subject { build(:file, public_id: 'id.txt', version: '1', format: '', resource_type: 'raw') }
26
+
27
+ it 'ignores the format' do
28
+ expect(subject.path).to eq 'v1/id.txt'
29
+ expect(subject.path('png')).to eq 'v1/id.txt'
30
+ expect(subject.path(false)).to eq 'v1/id.txt'
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '#fullpath(options={})' do
36
+ it 'delegates to Cloudinary' do
37
+ allow(Cloudinary::Utils).to receive(:cloudinary_url).with('v1/id1.png', {resource_type: "image"}).and_return('http_png')
38
+ subject.public_id = 'id1'
39
+ subject.version = '1'
40
+ expect(subject.fullpath(format: 'png')).to eq 'http_png'
41
+ end
42
+ end
43
+
44
+ end