added test file for comments_controller WIP
This commit is contained in:
parent
e5c235ac32
commit
d365d5efa1
3 changed files with 35 additions and 3 deletions
|
|
@ -12,8 +12,8 @@ module Admin
|
||||||
Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC')
|
Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def grouped_comments(comments)
|
def grouped_comments(remarks)
|
||||||
comments.group_by{ |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h
|
remarks.group_by{ |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -280,6 +280,6 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def unread_notifications(user)
|
def unread_notifications(user)
|
||||||
Comment.accessible_by(current_ability).find_since_last_login(current_user).limit(5)
|
Comment.accessible_by(current_ability).find_since_last_login(user).limit(5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
32
spec/controllers/admin/comments_controller_spec.rb
Normal file
32
spec/controllers/admin/comments_controller_spec.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Admin::CommentsController do
|
||||||
|
|
||||||
|
# some settings to be done before like creating objects used by tests
|
||||||
|
describe 'GET #index' do
|
||||||
|
context 'all comments' do
|
||||||
|
it 'populates a hash with conference, event, and comment objects'
|
||||||
|
it 'renders the :index template'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'unread_comments' do
|
||||||
|
it 'populates a hash with conference, event, and comment objects created since last login of current_user'
|
||||||
|
it 'renders the :index template'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'posted_comments' do
|
||||||
|
it 'populates a hash with conference, event, and comments posted by current_user'
|
||||||
|
it 'renders the :index template'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'accessible_ordered_comments' do
|
||||||
|
it 'returns comments'
|
||||||
|
it 'sorts comments by created_at and event title'
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'grouped_comments(remarks)' do
|
||||||
|
it 'groups comments by conference and by event'
|
||||||
|
it 'returns a hash'
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue