corkboard 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.env.template +1 -0
  2. data/.gitignore +15 -0
  3. data/.rspec.template +2 -0
  4. data/.rvmrc.template +4 -0
  5. data/.wiprc +0 -0
  6. data/.yardopts +1 -0
  7. data/Gemfile +15 -0
  8. data/Gemfile.lock +223 -0
  9. data/app/assets/images/corkboard/.gitkeep +0 -0
  10. data/corkboard.gemspec +41 -0
  11. data/lib/corkboard/version.rb +1 -1
  12. data/script/rails +8 -0
  13. data/spec/controllers/corkboard/application_controller_spec.rb +7 -0
  14. data/spec/controllers/corkboard/authorizations_controller_spec.rb +26 -0
  15. data/spec/controllers/corkboard/board_controller_spec.rb +29 -0
  16. data/spec/controllers/corkboard/posts_controller_spec.rb +7 -0
  17. data/spec/corkboard/client_spec.rb +52 -0
  18. data/spec/corkboard/clients/instagram_spec.rb +30 -0
  19. data/spec/corkboard/engine_spec.rb +11 -0
  20. data/spec/corkboard/provider_spec.rb +28 -0
  21. data/spec/corkboard/providers/instagram_spec.rb +44 -0
  22. data/spec/corkboard/publishers/mock_spec.rb +12 -0
  23. data/spec/corkboard/publishers/pusher_spec.rb +12 -0
  24. data/spec/corkboard/service/config_spec.rb +12 -0
  25. data/spec/corkboard_spec.rb +136 -0
  26. data/spec/dummy/README.rdoc +261 -0
  27. data/spec/dummy/Rakefile +7 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  31. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy/app/mailers/.gitkeep +0 -0
  33. data/spec/dummy/app/models/.gitkeep +0 -0
  34. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/spec/dummy/config.ru +4 -0
  36. data/spec/dummy/config/application.rb +65 -0
  37. data/spec/dummy/config/boot.rb +10 -0
  38. data/spec/dummy/config/database.yml +25 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +37 -0
  41. data/spec/dummy/config/environments/production.rb +67 -0
  42. data/spec/dummy/config/environments/test.rb +37 -0
  43. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/dummy/config/initializers/corkboard.rb +45 -0
  45. data/spec/dummy/config/initializers/inflections.rb +15 -0
  46. data/spec/dummy/config/initializers/jasmine.rb +5 -0
  47. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  48. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  49. data/spec/dummy/config/initializers/session_store.rb +8 -0
  50. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  51. data/spec/dummy/config/locales/en.yml +5 -0
  52. data/spec/dummy/config/routes.rb +3 -0
  53. data/spec/dummy/db/.gitkeep +0 -0
  54. data/spec/dummy/db/migrate/20121212222912_create_corkboard_authorizations.corkboard.rb +18 -0
  55. data/spec/dummy/db/schema.rb +31 -0
  56. data/spec/dummy/lib/assets/.gitkeep +0 -0
  57. data/spec/dummy/log/.gitkeep +0 -0
  58. data/spec/dummy/public/404.html +26 -0
  59. data/spec/dummy/public/422.html +26 -0
  60. data/spec/dummy/public/500.html +25 -0
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/script/rails +6 -0
  63. data/spec/helpers/corkboard/application_helper_spec.rb +7 -0
  64. data/spec/javascripts/fixtures/board.html +3 -0
  65. data/spec/javascripts/helpers/jasmine-jquery.js +340 -0
  66. data/spec/javascripts/spec.css +3 -0
  67. data/spec/javascripts/spec.js +5 -0
  68. data/spec/javascripts/spec_helper.js +41 -0
  69. data/spec/javascripts/specs/corkboard/app/board_spec.js +68 -0
  70. data/spec/javascripts/specs/corkboard/base_spec.js +17 -0
  71. data/spec/javascripts/specs/corkboard/lib/publisher_spec.js +101 -0
  72. data/spec/javascripts/specs/corkboard/lib/weighted_randomizer_spec.js +23 -0
  73. data/spec/javascripts/specs/corkboard_spec.js +45 -0
  74. data/spec/javascripts/support/jasmine.yml +75 -0
  75. data/spec/javascripts/support/jasmine_config.rb +1 -0
  76. data/spec/models/corkboard/authorization_spec.rb +7 -0
  77. data/spec/models/corkboard/post_spec.rb +7 -0
  78. data/spec/models/corkboard/subscription_spec.rb +7 -0
  79. data/spec/requests/authorizations_spec.rb +39 -0
  80. data/spec/requests/board_spec.rb +70 -0
  81. data/spec/routing/authorizations_routing_spec.rb +25 -0
  82. data/spec/routing/board_routing_spec.rb +7 -0
  83. data/spec/routing/posts_routing_spec.rb +15 -0
  84. data/spec/spec_helper.rb +51 -0
  85. data/spec/support/helpers/config_helpers.rb +26 -0
  86. data/spec/support/helpers/controller_helpers.rb +12 -0
  87. data/spec/support/helpers/post_helpers.rb +119 -0
  88. data/vendor/assets/javascripts/jquery.masonry-extensions.js +203 -0
  89. data/vendor/assets/javascripts/jquery.masonry.js +499 -0
  90. data/vendor/assets/javascripts/modernizr.js +821 -0
  91. data/vendor/assets/javascripts/pusher.js +48 -0
  92. metadata +176 -11
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ mount Corkboard::Engine => "/corkboard"
3
+ end
File without changes
@@ -0,0 +1,18 @@
1
+ # This migration comes from corkboard (originally 1)
2
+ class CreateCorkboardAuthorizations < ActiveRecord::Migration
3
+ def change
4
+ create_table :corkboard_authorizations, :force => true do |t|
5
+ t.references :resource_owner, :polymorphic => { :default => 'User' }
6
+ t.string :provider, :null => false
7
+ t.string :uid, :null => false
8
+ t.string :token, :null => false
9
+ t.text :info
10
+ t.text :extra
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :corkboard_authorizations, [:resource_owner_type, :resource_owner_id],
15
+ :name => 'index_corkboard_authorizations_on_resource_owner'
16
+ add_index :corkboard_authorizations, :provider
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20121212222912) do
15
+
16
+ create_table "corkboard_authorizations", :force => true do |t|
17
+ t.integer "resource_owner_id"
18
+ t.string "resource_owner_type", :default => "User"
19
+ t.string "provider", :null => false
20
+ t.string "uid", :null => false
21
+ t.string "token", :null => false
22
+ t.text "info"
23
+ t.text "extra"
24
+ t.datetime "created_at", :null => false
25
+ t.datetime "updated_at", :null => false
26
+ end
27
+
28
+ add_index "corkboard_authorizations", ["provider"], :name => "index_corkboard_authorizations_on_provider"
29
+ add_index "corkboard_authorizations", ["resource_owner_type", "resource_owner_id"], :name => "index_corkboard_authorizations_on_resource_owner"
30
+
31
+ end
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Corkboard::ApplicationHelper do
4
+ it "is pending" do
5
+ pending
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ <article id="corkboard" class="corkboard board">
2
+ <ul class="corkboard posts"></ul>
3
+ </article>
@@ -0,0 +1,340 @@
1
+ // jasmine-jquery version 1.3.1
2
+ // patched by Corey Innis to:
3
+ // * add support for Zepto or Ender.
4
+ // * use the fixtures route from jasminerice.
5
+ //
6
+ (function(supportedLibs) {
7
+ var $, $name, i, n;
8
+
9
+ for(i = 0, n = supportedLibs.length; i < n; i ++) {
10
+ $name = supportedLibs[i];
11
+ $ = window[$name];
12
+
13
+ if($) {
14
+ break;
15
+ }
16
+ }
17
+
18
+ // "this" is the global object (window in the browser).
19
+ this.readFixtures = function() {
20
+ return jasmine.getFixtures().proxyCallTo_('read', arguments);
21
+ };
22
+
23
+ this.preloadFixtures = function() {
24
+ jasmine.getFixtures().proxyCallTo_('preload', arguments);
25
+ };
26
+
27
+ this.loadFixtures = function() {
28
+ jasmine.getFixtures().proxyCallTo_('load', arguments);
29
+ };
30
+
31
+ this.setFixtures = function(html) {
32
+ jasmine.getFixtures().set(html);
33
+ };
34
+
35
+ this.sandbox = function(attributes) {
36
+ return jasmine.getFixtures().sandbox(attributes);
37
+ };
38
+
39
+ this.spyOnEvent = function(selector, eventName) {
40
+ jasmine[$name].events.spyOn(selector, eventName);
41
+ }
42
+
43
+ jasmine.getFixtures = function() {
44
+ return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures();
45
+ };
46
+
47
+ jasmine.Fixtures = function() {
48
+ this.containerId = 'jasmine-fixtures';
49
+ this.fixturesCache_ = {};
50
+ this.fixturesPath = 'jasmine/fixtures';
51
+ };
52
+
53
+ jasmine.Fixtures.prototype.set = function(html) {
54
+ this.cleanUp();
55
+ this.createContainer_(html);
56
+ };
57
+
58
+ jasmine.Fixtures.prototype.preload = function() {
59
+ this.read.apply(this, arguments);
60
+ };
61
+
62
+ jasmine.Fixtures.prototype.load = function() {
63
+ this.cleanUp();
64
+ this.createContainer_(this.read.apply(this, arguments));
65
+ };
66
+
67
+ jasmine.Fixtures.prototype.read = function() {
68
+ var htmlChunks = [];
69
+
70
+ var fixtureUrls = arguments;
71
+ for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
72
+ htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]));
73
+ }
74
+
75
+ return htmlChunks.join('');
76
+ };
77
+
78
+ jasmine.Fixtures.prototype.clearCache = function() {
79
+ this.fixturesCache_ = {};
80
+ };
81
+
82
+ jasmine.Fixtures.prototype.cleanUp = function() {
83
+ $('#' + this.containerId).remove();
84
+ };
85
+
86
+ jasmine.Fixtures.prototype.sandbox = function(attributes) {
87
+ var attributesToSet = attributes || {};
88
+ return $('<div id="sandbox" />').attr(attributesToSet);
89
+ };
90
+
91
+ jasmine.Fixtures.prototype.createContainer_ = function(html) {
92
+ var container;
93
+ if(html.selector !== undefined) {
94
+ container = $('<div id="' + this.containerId + '" />');
95
+ container.html(html);
96
+ } else {
97
+ container = '<div id="' + this.containerId + '">' + html + '</div>'
98
+ }
99
+ $('body').append(container);
100
+ };
101
+
102
+ jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
103
+ if (typeof this.fixturesCache_[url] == 'undefined') {
104
+ this.loadFixtureIntoCache_(url);
105
+ }
106
+ return this.fixturesCache_[url];
107
+ };
108
+
109
+ jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
110
+ var self = this;
111
+ var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl;
112
+ var ext = relativeUrl.split('.').pop();
113
+ var type = (ext === 'js') ? 'script' : ext;
114
+
115
+ $.ajax({
116
+ async : false, // must be synchronous to guarantee that no tests are run before fixture is loaded
117
+ cache : false,
118
+ dataType : type,
119
+ url : url,
120
+
121
+ success : function(data) {
122
+ self.fixturesCache_[relativeUrl] = data;
123
+ },
124
+
125
+ error : function(jqXHR, status, errorThrown) {
126
+ throw Error('Fixture could not be loaded: ' + url + ' (status: ' + status + ', message: ' + errorThrown.message + ')');
127
+ }
128
+ });
129
+ };
130
+
131
+ jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
132
+ return this[methodName].apply(this, passedArguments);
133
+ };
134
+
135
+ jasmine[$name] = function() {};
136
+
137
+ jasmine[$name].browserTagCaseIndependentHtml = function(html) {
138
+ return $('<div/>').append(html).html();
139
+ };
140
+
141
+ jasmine[$name].elementToString = function(element) {
142
+ if(element.clone) {
143
+ return $('<div />').append(element.clone()).html();
144
+ }
145
+ else {
146
+ // NOTE: we're not cloning here (for ender built with bonzo), so there
147
+ // *could* be some issue. bonzo uses cloning in its #appendTo definition
148
+ // which could be another option.
149
+ return $('<div />').append(element).html();
150
+ }
151
+ };
152
+
153
+ jasmine[$name].matchersClass = {};
154
+
155
+ (function(namespace) {
156
+ var data = {
157
+ spiedEvents: {},
158
+ handlers: []
159
+ };
160
+
161
+ namespace.events = {
162
+ spyOn: function(selector, eventName) {
163
+ var handler = function(e) {
164
+ data.spiedEvents[[selector, eventName]] = e;
165
+ };
166
+ $(selector).bind(eventName, handler);
167
+ data.handlers.push(handler);
168
+ },
169
+
170
+ wasTriggered: function(selector, eventName) {
171
+ return !!(data.spiedEvents[[selector, eventName]]);
172
+ },
173
+
174
+ cleanUp: function() {
175
+ data.spiedEvents = {};
176
+ data.handlers = [];
177
+ }
178
+ }
179
+ })(jasmine[$name]);
180
+
181
+ (function(){
182
+ var CustomMatchers = {
183
+ toHaveClass: function(className) {
184
+ return this.actual.hasClass(className);
185
+ },
186
+
187
+ toBeVisible: function() {
188
+ return this.actual.is(':visible');
189
+ },
190
+
191
+ toBeHidden: function() {
192
+ return this.actual.is(':hidden');
193
+ },
194
+
195
+ toBeSelected: function() {
196
+ return this.actual.is(':selected');
197
+ },
198
+
199
+ toBeChecked: function() {
200
+ return this.actual.is(':checked');
201
+ },
202
+
203
+ toBeEmpty: function() {
204
+ return this.actual.is(':empty');
205
+ },
206
+
207
+ toExist: function() {
208
+ return this.actual.size() > 0;
209
+ },
210
+
211
+ toHaveAttr: function(attributeName, expectedAttributeValue) {
212
+ return hasProperty(this.actual.attr(attributeName), expectedAttributeValue);
213
+ },
214
+
215
+ toHaveId: function(id) {
216
+ return this.actual.attr('id') == id;
217
+ },
218
+
219
+ toHaveHtml: function(html) {
220
+ return this.actual.html() == jasmine[$name].browserTagCaseIndependentHtml(html);
221
+ },
222
+
223
+ toHaveText: function(text) {
224
+ if (text && $.isFunction(text.test)) {
225
+ return text.test(this.actual.text());
226
+ } else {
227
+ return this.actual.text() == text;
228
+ }
229
+ },
230
+
231
+ toHaveValue: function(value) {
232
+ return this.actual.val() == value;
233
+ },
234
+
235
+ toHaveData: function(key, expectedValue) {
236
+ return hasProperty(this.actual.data(key), expectedValue);
237
+ },
238
+
239
+ toBe: function(selector) {
240
+ return this.actual.is(selector);
241
+ },
242
+
243
+ toContain: function(selector) {
244
+ return this.actual.find(selector).size() > 0;
245
+ },
246
+
247
+ toBeDisabled: function(selector){
248
+ return this.actual.is(':disabled');
249
+ },
250
+
251
+ // tests the existence of a specific event binding
252
+ toHandle: function(eventName) {
253
+ var events = this.actual.data("events");
254
+ return events && events[eventName].length > 0;
255
+ },
256
+
257
+ // tests the existence of a specific event binding + handler
258
+ toHandleWith: function(eventName, eventHandler) {
259
+ var stack = this.actual.data("events")[eventName];
260
+ var i;
261
+ for (i = 0; i < stack.length; i++) {
262
+ if (stack[i].handler == eventHandler) {
263
+ return true;
264
+ }
265
+ }
266
+ return false;
267
+ },
268
+
269
+ toHaveCss: function(expected) {
270
+ var element = this.actual;
271
+ var pass = true;
272
+ var dummy = $('<p>');
273
+
274
+ if(element.closest('body').length) {
275
+ dummy.appendTo('body');
276
+ }
277
+
278
+ var result = $.each(expected, function(key, value) {
279
+ dummy.css(key, value);
280
+
281
+ if(element.css(key) !== dummy.css(key)) {
282
+ return pass = false;
283
+ }
284
+ });
285
+
286
+ dummy.remove();
287
+ return pass;
288
+ }
289
+ };
290
+
291
+ var hasProperty = function(actualValue, expectedValue) {
292
+ if (expectedValue === undefined) {
293
+ return actualValue !== undefined;
294
+ }
295
+ return actualValue == expectedValue;
296
+ };
297
+
298
+ var bindMatcher = function(methodName) {
299
+ var builtInMatcher = jasmine.Matchers.prototype[methodName];
300
+
301
+ jasmine[$name].matchersClass[methodName] = function() {
302
+ if (this.actual.selector !== undefined) {
303
+ var result = CustomMatchers[methodName].apply(this, arguments);
304
+ this.actual = jasmine[$name].elementToString(this.actual);
305
+ return result;
306
+ }
307
+
308
+ if (builtInMatcher) {
309
+ return builtInMatcher.apply(this, arguments);
310
+ }
311
+
312
+ return false;
313
+ };
314
+ };
315
+
316
+ for(var methodName in CustomMatchers) {
317
+ bindMatcher(methodName);
318
+ }
319
+ })();
320
+
321
+ beforeEach(function() {
322
+ this.addMatchers(jasmine[$name].matchersClass);
323
+ this.addMatchers({
324
+ toHaveBeenTriggeredOn: function(selector) {
325
+ this.message = function() {
326
+ return [
327
+ "Expected event " + this.actual + " to have been triggered on" + selector,
328
+ "Expected event " + this.actual + " not to have been triggered on" + selector
329
+ ];
330
+ };
331
+ return jasmine[$name].events.wasTriggered(selector, this.actual);
332
+ }
333
+ })
334
+ });
335
+
336
+ afterEach(function() {
337
+ jasmine.getFixtures().cleanUp();
338
+ jasmine[$name].events.cleanUp();
339
+ });
340
+ })(['jQuery', 'Zepto', 'ender']);