File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -171,8 +171,7 @@ def create
171
171
end
172
172
173
173
174
- @protip = Protip.new(create_params)
175
- @protip.user = current_user
174
+ @protip = current_user.protips.build(create_params)
176
175
respond_to do |format|
177
176
if @protip.save
178
177
record_event('created protip')
Original file line number Diff line number Diff line change @@ -607,7 +607,13 @@ def views_score
607
607
end
608
608
609
609
def comments_score
610
- self . comments . collect { |comment | comment . likes_value_cache + comment . author . score } . reduce ( :+ ) || 0
610
+ self . comments . collect do |comment |
611
+ if comment . author . present?
612
+ comment . likes_value_cache + comment . author . score
613
+ else
614
+ comment . likes_value_cache
615
+ end
616
+ end . reduce ( :+ ) || 0
611
617
end
612
618
613
619
QUALITY_WEIGHT = 20
Original file line number Diff line number Diff line change 1
1
RSpec . describe AchievementsController , type : :routing do
2
2
describe 'routing' do
3
3
4
- it 'routes to #new ' do
4
+ it 'routes to #award ' do
5
5
expect ( post ( '/award' ) ) . to route_to ( controller : 'achievements' , action : 'award' )
6
6
end
7
7
You can’t perform that action at this time.
0 commit comments