Skip to content

Commit 66b46f8

Browse files
seurosvagrant
authored and
vagrant
committed
update mongoid
Remove deprecation warnings Extracted VCR to it own helper Updated carrierwave Annotated routes
1 parent 78222f6 commit 66b46f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1439
-1337
lines changed

Gemfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ gem 'dotenv-rails', groups: [:development, :test]
1616

1717
gem 'strong_parameters'
1818

19-
# Mongo
20-
gem 'mongoid', '~> 2.4.12'
21-
gem 'mongo', '<= 1.6.2'
22-
gem 'mongoid_taggable'
23-
gem 'bson_ext', '~> 1.3'
24-
2519
# Attachements
26-
gem 'carrierwave', '0.5.8'
20+
gem 'carrierwave'
2721
gem 'carrierwave_backgrounder', '0.0.8' #background processing of images
28-
gem 'carrierwave-mongoid', '~> 0.1.7', require: 'carrierwave/mongoid'
22+
gem 'carrierwave-mongoid', require: 'carrierwave/mongoid'
2923

3024
# Two Client-side JS frameworks. Yep, first one to refactor out the other wins.
3125
gem 'backbone-on-rails'
@@ -110,7 +104,7 @@ gem 'faraday', '~> 0.8.1'
110104

111105
# ----------------
112106

113-
gem 'rocket_tag', '0.0.4'
107+
gem 'rocket_tag'
114108

115109
gem 'acts_as_commentable', '2.0.1'
116110
gem 'acts_as_follower', '0.1.1'
@@ -135,6 +129,13 @@ gem 'sanitize'
135129
gem 'simple_form'
136130
gem 'tweet-button'
137131

132+
133+
# Mongo
134+
gem 'mongoid'
135+
gem 'mongo'
136+
gem 'mongoid_taggable'
137+
gem 'bson_ext', '~> 1.3'
138+
138139
group :development do
139140
gem 'better_errors'
140141
gem 'flog'
@@ -155,8 +156,10 @@ group :development, :test do
155156
gem 'pry-byebug'
156157
gem 'quiet_assets'
157158
gem 'syntax'
159+
gem 'annotate'
160+
gem 'mail_view'
158161
end
159-
gem 'mail_view'
162+
160163

161164
group :test do
162165
gem 'capybara'

Gemfile.lock

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ GEM
8282
acts_as_commentable (2.0.1)
8383
acts_as_follower (0.1.1)
8484
addressable (2.3.6)
85+
annotate (2.6.5)
86+
activerecord (>= 2.3.0)
87+
rake (>= 0.8.7)
8588
arel (3.0.3)
8689
ast (2.0.0)
8790
awesome_print (1.2.0)
@@ -117,11 +120,15 @@ GEM
117120
rack (>= 1.0.0)
118121
rack-test (>= 0.5.4)
119122
xpath (~> 2.0)
120-
carrierwave (0.5.8)
121-
activesupport (~> 3.0)
122-
carrierwave-mongoid (0.1.7)
123-
carrierwave (~> 0.5.6)
124-
mongoid (~> 2.1)
123+
carrierwave (0.10.0)
124+
activemodel (>= 3.2.0)
125+
activesupport (>= 3.2.0)
126+
json (>= 1.7)
127+
mime-types (>= 1.16)
128+
carrierwave-mongoid (0.7.1)
129+
carrierwave (>= 0.8.0, < 0.11.0)
130+
mongoid (>= 3.0, < 5.0)
131+
mongoid-grid_fs (>= 1.3, < 3.0)
125132
carrierwave_backgrounder (0.0.8)
126133
carrierwave (~> 0.5)
127134
celluloid (0.15.2)
@@ -346,14 +353,21 @@ GEM
346353
escape
347354
json
348355
rack
349-
mongo (1.3.1)
350-
bson (>= 1.3.1)
351-
mongoid (2.4.12)
352-
activemodel (~> 3.1)
353-
mongo (<= 1.6.2)
354-
tzinfo (~> 0.3.22)
355-
mongoid_taggable (0.1.7)
356+
mongo (1.10.2)
357+
bson (= 1.10.2)
358+
mongoid (3.1.6)
359+
activemodel (~> 3.2)
360+
moped (~> 1.4)
361+
origin (~> 1.0)
362+
tzinfo (~> 0.3.29)
363+
mongoid-grid_fs (2.1.0)
364+
mime-types (>= 1.0, < 3.0)
365+
mongoid (>= 3.0, < 5.0)
366+
mongoid_taggable (1.1.1)
367+
mongoid (>= 3)
368+
rake
356369
mono_logger (1.1.0)
370+
moped (1.5.2)
357371
multi_json (1.10.1)
358372
multi_xml (0.5.5)
359373
multipart-post (1.2.0)
@@ -410,6 +424,7 @@ GEM
410424
omniauth-twitter (0.0.18)
411425
multi_json (~> 1.3)
412426
omniauth-oauth (~> 1.0)
427+
origin (1.1.0)
413428
parser (2.1.9)
414429
ast (>= 1.1, < 3.0)
415430
slop (~> 3.4, >= 3.4.5)
@@ -522,9 +537,9 @@ GEM
522537
rest-client (1.7.1)
523538
mime-types (>= 1.16, < 3.0)
524539
netrc (~> 0.7)
525-
rocket_tag (0.0.4)
526-
activerecord (>= 3.1.0)
527-
squeel
540+
rocket_tag (0.5.6)
541+
activerecord (>= 3.2.0)
542+
squeel (~> 1.0.0)
528543
rspec (3.0.0)
529544
rspec-core (~> 3.0.0)
530545
rspec-expectations (~> 3.0.0)
@@ -649,13 +664,14 @@ PLATFORMS
649664
DEPENDENCIES
650665
acts_as_commentable (= 2.0.1)
651666
acts_as_follower (= 0.1.1)
667+
annotate
652668
awesome_print
653669
backbone-on-rails
654670
better_errors
655671
bson_ext (~> 1.3)
656672
capybara
657-
carrierwave (= 0.5.8)
658-
carrierwave-mongoid (~> 0.1.7)
673+
carrierwave
674+
carrierwave-mongoid
659675
carrierwave_backgrounder (= 0.0.8)
660676
chronic
661677
coffee-rails (~> 3.2.1)
@@ -698,8 +714,8 @@ DEPENDENCIES
698714
memcachier
699715
mini_magick
700716
mixpanel
701-
mongo (<= 1.6.2)
702-
mongoid (~> 2.4.12)
717+
mongo
718+
mongoid
703719
mongoid_taggable
704720
multi_json
705721
never_wastes
@@ -734,7 +750,7 @@ DEPENDENCIES
734750
resque_mailer
735751
resque_spec
736752
rest-client
737-
rocket_tag (= 0.0.4)
753+
rocket_tag
738754
rspec-rails
739755
ruby-progressbar
740756
sanitize

app/models/api_access.rb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# ## Schema Information
2-
# Schema version: 20131205021701
1+
# == Schema Information
32
#
4-
# Table name: `api_accesses`
3+
# Table name: api_accesses
54
#
6-
# ### Columns
7-
#
8-
# Name | Type | Attributes
9-
# ----------------- | ------------------ | ---------------------------
10-
# **`api_key`** | `string(255)` |
11-
# **`awards`** | `text` |
12-
# **`created_at`** | `datetime` |
13-
# **`id`** | `integer` | `not null, primary key`
14-
# **`updated_at`** | `datetime` |
5+
# id :integer not null, primary key
6+
# api_key :string(255)
7+
# awards :text
8+
# created_at :datetime
9+
# updated_at :datetime
1510
#
1611

1712
class ApiAccess < ActiveRecord::Base

app/models/available_coupon.rb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
# ## Schema Information
2-
# Schema version: 20131205021701
1+
# == Schema Information
32
#
4-
# Table name: `available_coupons`
3+
# Table name: available_coupons
54
#
6-
# ### Columns
5+
# id :integer not null, primary key
6+
# codeschool_coupon :string(255)
7+
# peepcode_coupon :string(255)
8+
# recipes_coupon :string(255)
79
#
8-
# Name | Type | Attributes
9-
# ------------------------ | ------------------ | ---------------------------
10-
# **`codeschool_coupon`** | `string(255)` |
11-
# **`id`** | `integer` | `not null, primary key`
12-
# **`peepcode_coupon`** | `string(255)` |
13-
# **`recipes_coupon`** | `string(255)` |
10+
# Indexes
1411
#
15-
# ### Indexes
16-
#
17-
# * `index_available_coupons_on_codeschool_coupon` (_unique_):
18-
# * **`codeschool_coupon`**
19-
# * `index_available_coupons_on_peepcode_coupon` (_unique_):
20-
# * **`peepcode_coupon`**
12+
# index_available_coupons_on_codeschool_coupon (codeschool_coupon) UNIQUE
13+
# index_available_coupons_on_peepcode_coupon (peepcode_coupon) UNIQUE
2114
#
2215

2316
class AvailableCoupon < ActiveRecord::Base

app/models/badge.rb

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
# ## Schema Information
2-
# Schema version: 20131205021701
1+
# == Schema Information
32
#
4-
# Table name: `badges`
3+
# Table name: badges
54
#
6-
# ### Columns
5+
# id :integer not null, primary key
6+
# created_at :datetime
7+
# updated_at :datetime
8+
# user_id :integer
9+
# badge_class_name :string(255)
710
#
8-
# Name | Type | Attributes
9-
# ----------------------- | ------------------ | ---------------------------
10-
# **`badge_class_name`** | `string(255)` |
11-
# **`created_at`** | `datetime` |
12-
# **`id`** | `integer` | `not null, primary key`
13-
# **`updated_at`** | `datetime` |
14-
# **`user_id`** | `integer` |
11+
# Indexes
1512
#
16-
# ### Indexes
17-
#
18-
# * `index_badges_on_user_id`:
19-
# * **`user_id`**
20-
# * `index_badges_on_user_id_and_badge_class_name` (_unique_):
21-
# * **`user_id`**
22-
# * **`badge_class_name`**
13+
# index_badges_on_user_id (user_id)
14+
# index_badges_on_user_id_and_badge_class_name (user_id,badge_class_name) UNIQUE
2315
#
2416

2517
class Badge < ActiveRecord::Base

app/models/comment.rb

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
# ## Schema Information
2-
# Schema version: 20131205021701
1+
# == Schema Information
32
#
4-
# Table name: `comments`
3+
# Table name: comments
54
#
6-
# ### Columns
5+
# id :integer not null, primary key
6+
# title :string(50) default("")
7+
# comment :text default("")
8+
# commentable_id :integer
9+
# commentable_type :string(255)
10+
# user_id :integer
11+
# likes_cache :integer default(0)
12+
# likes_value_cache :integer default(0)
13+
# created_at :datetime
14+
# updated_at :datetime
15+
# likes_count :integer default(0)
716
#
8-
# Name | Type | Attributes
9-
# ------------------------ | ------------------ | ---------------------------
10-
# **`comment`** | `text` | `default("")`
11-
# **`commentable_id`** | `integer` |
12-
# **`commentable_type`** | `string(255)` |
13-
# **`created_at`** | `datetime` |
14-
# **`id`** | `integer` | `not null, primary key`
15-
# **`likes_cache`** | `integer` | `default(0)`
16-
# **`likes_value_cache`** | `integer` | `default(0)`
17-
# **`title`** | `string(50)` | `default("")`
18-
# **`updated_at`** | `datetime` |
19-
# **`user_id`** | `integer` |
17+
# Indexes
2018
#
21-
# ### Indexes
22-
#
23-
# * `index_comments_on_commentable_id`:
24-
# * **`commentable_id`**
25-
# * `index_comments_on_commentable_type`:
26-
# * **`commentable_type`**
27-
# * `index_comments_on_user_id`:
28-
# * **`user_id`**
19+
# index_comments_on_commentable_id (commentable_id)
20+
# index_comments_on_commentable_type (commentable_type)
21+
# index_comments_on_user_id (user_id)
2922
#
3023

3124
class Comment < ActiveRecord::Base
@@ -34,7 +27,7 @@ class Comment < ActiveRecord::Base
3427
include Rakismet::Model
3528

3629
belongs_to :commentable, polymorphic: true
37-
has_many :likes, as: :likable, dependent: :destroy, after_add: :update_likes_cache, after_remove: :update_likes_cache
30+
has_many :likes, as: :likable, dependent: :destroy
3831
has_one :spam_report, as: :spammable
3932
after_create :generate_event
4033
after_create :analyze_spam
@@ -66,10 +59,6 @@ def commented_callback
6659
commentable.try(:commented)
6760
end
6861

69-
def update_likes_cache(like)
70-
like.destroyed? ? decrement_likes_cache(like.value) : increment_likes_cache(like.value)
71-
end
72-
7362
def like_by(user)
7463
unless self.liked_by?(user) or user.id == self.author_id
7564
self.likes.create!(user: user, value: user.score)
@@ -123,18 +112,6 @@ def commenting_on_own?
123112

124113
private
125114

126-
def decrement_likes_cache(value)
127-
self.likes_cache -= 1
128-
self.likes_value_cache -= value
129-
save(validate: false)
130-
end
131-
132-
def increment_likes_cache(value)
133-
self.likes_cache += 1
134-
self.likes_value_cache += value
135-
save(validate: false)
136-
end
137-
138115
def generate_event(options={})
139116
event_type = event_type(options)
140117
data = to_event_hash(options)
@@ -165,7 +142,6 @@ def to_event_hash(options={})
165142
end
166143

167144
def event_audience(event_type, options ={})
168-
audience = {}
169145
case event_type
170146
when :new_comment
171147
audience = Audience.user(self.commentable.try(:user_id))

app/models/country.rb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# ## Schema Information
2-
# Schema version: 20131205021701
1+
# == Schema Information
32
#
4-
# Table name: `countries`
3+
# Table name: countries
54
#
6-
# ### Columns
7-
#
8-
# Name | Type | Attributes
9-
# ----------------- | ------------------ | ---------------------------
10-
# **`code`** | `string(255)` |
11-
# **`created_at`** | `datetime` |
12-
# **`id`** | `integer` | `not null, primary key`
13-
# **`name`** | `string(255)` |
14-
# **`updated_at`** | `datetime` |
5+
# id :integer not null, primary key
6+
# name :string(255)
7+
# code :string(255)
8+
# created_at :datetime
9+
# updated_at :datetime
1510
#
1611

1712
class Country < ActiveRecord::Base

0 commit comments

Comments
 (0)