Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/controllers/protips_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ def create
end


@protip = Protip.new(create_params)
@protip.user = current_user
@protip = current_user.protips.build(create_params)
respond_to do |format|
if @protip.save
record_event('created protip')
Expand Down
8 changes: 7 additions & 1 deletion app/models/protip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,13 @@ def views_score
end

def comments_score
self.comments.collect { |comment| comment.likes_value_cache + comment.author.score }.reduce(:+) || 0
self.comments.collect do |comment|
if comment.author.present?
comment.likes_value_cache + comment.author.score
else
comment.likes_value_cache
end
end.reduce(:+) || 0
end

QUALITY_WEIGHT = 20
Expand Down
2 changes: 1 addition & 1 deletion spec/routing/achievements_routing_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RSpec.describe AchievementsController, type: :routing do
describe 'routing' do

it 'routes to #new' do
it 'routes to #award' do
expect(post('/award')).to route_to(controller: 'achievements', action: 'award')
end

Expand Down