Commit a33cc1d98e497aca1634c5abc9032595e27e234e

Authored by Leandro Santos
2 parents 2c33e2e9 48167ee1
Exists in staging

mergin with master

Gemfile.lock
... ... @@ -161,13 +161,11 @@ GEM
161 161 ansi (1.5.0)
162 162 api-pagination (4.1.1)
163 163 arel (6.0.3)
164   - awesome_print (1.6.1)
165 164 axiom-types (0.1.1)
166 165 descendants_tracker (~> 0.0.4)
167 166 ice_nine (~> 0.11.0)
168 167 thread_safe (~> 0.3, >= 0.3.1)
169 168 builder (3.2.2)
170   - byebug (8.2.2)
171 169 capybara (2.5.0)
172 170 mime-types (>= 1.16)
173 171 nokogiri (>= 1.3.3)
... ... @@ -177,12 +175,9 @@ GEM
177 175 childprocess (0.5.9)
178 176 ffi (~> 1.0, >= 1.0.11)
179 177 chronic (0.10.2)
180   - coderay (1.1.0)
181 178 coercible (1.0.0)
182 179 descendants_tracker (~> 0.0.1)
183 180 concurrent-ruby (1.0.0)
184   - coolline (0.5.0)
185   - unicode_utils (~> 1.4)
186 181 cucumber (1.3.20)
187 182 builder (>= 2.1.2)
188 183 diff-lcs (>= 1.1.3)
... ... @@ -247,19 +242,10 @@ GEM
247 242 grape_logging (1.1.2)
248 243 grape
249 244 hashie (3.4.3)
250   - hirb (0.7.3)
251 245 http-cookie (1.0.2)
252 246 domain_name (~> 0.5)
253 247 i18n (0.7.0)
254 248 ice_nine (0.11.1)
255   - jazz_fingers (3.0.0)
256   - awesome_print (~> 1.6)
257   - hirb (~> 0.7)
258   - pry (~> 0.10)
259   - pry-byebug (~> 3.1)
260   - pry-coolline (~> 0.2)
261   - pry-doc (~> 0.6)
262   - pry-remote (>= 0.1.7)
263 249 json (1.8.3)
264 250 kgio (2.10.0)
265 251 kramdown (1.9.0)
... ... @@ -274,7 +260,6 @@ GEM
274 260 mail (2.6.3)
275 261 mime-types (>= 1.16, < 3)
276 262 metaclass (0.0.4)
277   - method_source (0.8.2)
278 263 mime-types (2.99)
279 264 mini_portile2 (2.0.0)
280 265 minitest (5.8.3)
... ... @@ -296,21 +281,6 @@ GEM
296 281 power_assert (0.2.6)
297 282 protected_attributes (1.1.3)
298 283 activemodel (>= 4.0.1, < 5.0)
299   - pry (0.10.3)
300   - coderay (~> 1.1.0)
301   - method_source (~> 0.8.1)
302   - slop (~> 3.4)
303   - pry-byebug (3.3.0)
304   - byebug (~> 8.0)
305   - pry (~> 0.10)
306   - pry-coolline (0.2.5)
307   - coolline (~> 0.5)
308   - pry-doc (0.8.0)
309   - pry (~> 0.9)
310   - yard (~> 0.8)
311   - pry-remote (0.1.8)
312   - pry (~> 0.9)
313   - slop (~> 3.0)
314 284 rack (1.6.4)
315 285 rack-accept (0.4.5)
316 286 rack (>= 0.4)
... ... @@ -397,7 +367,6 @@ GEM
397 367 slim (3.0.6)
398 368 temple (~> 0.7.3)
399 369 tilt (>= 1.3.3, < 2.1)
400   - slop (3.6.0)
401 370 spring (1.6.1)
402 371 sprockets (3.5.2)
403 372 concurrent-ruby (~> 1.0)
... ... @@ -422,7 +391,6 @@ GEM
422 391 unf (0.1.4)
423 392 unf_ext
424 393 unf_ext (0.0.7.1)
425   - unicode_utils (1.4.0)
426 394 unicorn (4.9.0)
427 395 kgio (~> 2.6)
428 396 rack
... ... @@ -438,7 +406,6 @@ GEM
438 406 will_paginate (3.0.7)
439 407 xpath (2.0.0)
440 408 nokogiri (~> 1.3)
441   - yard (0.8.7.6)
442 409  
443 410 PLATFORMS
444 411 ruby
... ... @@ -481,7 +448,6 @@ DEPENDENCIES
481 448 grape_logging
482 449 honeypot (= 0.0.0)!
483 450 i18n_deprecation (= 0.0.0)!
484   - jazz_fingers
485 451 kandadaboggu-vote_fu (> 0.0.0)!
486 452 kramdown
487 453 launchy
... ...
db/migrate/20160309122141_add_id_to_article_follower.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class AddIdToArticleFollower < ActiveRecord::Migration
  2 + def change
  3 + add_column :article_followers, :id, :primary_key
  4 + end
  5 +end
... ...
db/schema.rb
... ... @@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended that you check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(version: 20160224132937) do
  14 +ActiveRecord::Schema.define(version: 20160309122141) do
15 15  
16 16 # These are extensions that must be enabled in order to support this database
17 17 enable_extension "plpgsql"
... ... @@ -56,39 +56,7 @@ ActiveRecord::Schema.define(version: 20160224132937) do
56 56 add_index "action_tracker_notifications", ["profile_id", "action_tracker_id"], name: "index_action_tracker_notif_on_prof_id_act_tracker_id", unique: true, using: :btree
57 57 add_index "action_tracker_notifications", ["profile_id"], name: "index_action_tracker_notifications_on_profile_id", using: :btree
58 58  
59   - create_table "analytics_plugin_page_views", force: :cascade do |t|
60   - t.string "type"
61   - t.integer "visit_id"
62   - t.integer "track_id"
63   - t.integer "referer_page_view_id"
64   - t.string "request_id"
65   - t.integer "user_id"
66   - t.integer "session_id"
67   - t.integer "profile_id"
68   - t.text "url"
69   - t.text "referer_url"
70   - t.text "user_agent"
71   - t.string "remote_ip"
72   - t.datetime "request_started_at"
73   - t.datetime "request_finished_at"
74   - t.datetime "page_loaded_at"
75   - t.integer "time_on_page", default: 0
76   - t.text "data", default: "--- {}\n"
77   - end
78   -
79   - add_index "analytics_plugin_page_views", ["profile_id"], name: "index_analytics_plugin_page_views_on_profile_id", using: :btree
80   - add_index "analytics_plugin_page_views", ["referer_page_view_id"], name: "index_analytics_plugin_page_views_on_referer_page_view_id", using: :btree
81   - add_index "analytics_plugin_page_views", ["request_id"], name: "index_analytics_plugin_page_views_on_request_id", using: :btree
82   - add_index "analytics_plugin_page_views", ["session_id"], name: "index_analytics_plugin_page_views_on_session_id", using: :btree
83   - add_index "analytics_plugin_page_views", ["url"], name: "index_analytics_plugin_page_views_on_url", using: :btree
84   - add_index "analytics_plugin_page_views", ["user_id", "session_id", "profile_id", "url"], name: "analytics_plugin_referer_find", using: :btree
85   - add_index "analytics_plugin_page_views", ["user_id"], name: "index_analytics_plugin_page_views_on_user_id", using: :btree
86   -
87   - create_table "analytics_plugin_visits", force: :cascade do |t|
88   - t.integer "profile_id"
89   - end
90   -
91   - create_table "article_followers", id: false, force: :cascade do |t|
  59 + create_table "article_followers", force: :cascade do |t|
92 60 t.integer "person_id"
93 61 t.integer "article_id"
94 62 t.datetime "since"
... ...
test/unit/article_test.rb
... ... @@ -2301,4 +2301,22 @@ class ArticleTest &lt; ActiveSupport::TestCase
2301 2301 assert_equal "/#{a2.path}", a2.full_path
2302 2302 end
2303 2303  
  2304 + should "increment followers count when a person follow an article" do
  2305 + a = fast_create(Article)
  2306 + p = fast_create(Person)
  2307 + assert_difference "a.reload.followers_count" do
  2308 + a.person_followers << p
  2309 + end
  2310 + end
  2311 +
  2312 + should "decrement followers count when a person unfollow an article" do
  2313 + p = fast_create(Person)
  2314 + a = fast_create(Article, :profile_id => p)
  2315 + a.person_followers << p
  2316 + assert_difference "a.reload.followers_count", -1 do
  2317 + a.person_followers.destroy_all
  2318 + end
  2319 + end
  2320 +
  2321 +
2304 2322 end
... ...