Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleted instances of answer/answers #9487

Merged
merged 1 commit into from
Apr 15, 2021
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
2 changes: 0 additions & 2 deletions app/controllers/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ def index
@weekly_notes = Node.past_week.select(:type).where(type: 'note').size
@weekly_wikis = Revision.past_week.size
@weekly_questions = Node.questions.past_week.size
@weekly_answers = Answer.past_week.size
@weekly_members = User.past_week.where(status: 1).size
@monthly_notes = Node.past_month.select(:type).where(type: 'note').size
@monthly_wikis = Revision.past_month.size
@monthly_members = User.past_month.where(status: 1).size
@monthly_questions = Node.questions.past_month.size
@monthly_answers = Answer.past_month.size

@notes_per_week_period = Node.frequency('note', @start, @end).round(2)
@edits_per_week_period = Revision.frequency(@start, @end).round(2)
Expand Down
8 changes: 2 additions & 6 deletions test/functional/questions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,21 @@ def setup
assert_response :success
end

test 'should not show answer accept button to users if not logged in' do
test 'should not show accept button to users if not logged in' do
note = nodes(:question)
answer = answers(:one)

get :show, params: { author: note.author.name, date: Time.at(note.created).strftime('%m-%d-%Y'), id: note.title.parameterize }

assert_response :success
assert_select '#answer-' + answer.id.to_s + '-accept', 0
end

test 'should not show accept answer button to user who is not the author of the question' do
test 'should not show accept button to user who is not the author of the question' do
UserSession.create(users(:bob))
note = nodes(:question)
answer = answers(:one)

get :show, params: { author: note.author.name, date: Time.at(note.created).strftime('%m-%d-%Y'), id: note.title.parameterize }

assert_response :success
assert_select '#answer-' + answer.id.to_s + '-accept', 0
end

test 'should get answered' do
Expand Down
4 changes: 1 addition & 3 deletions test/unit/comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,10 @@ def setup
assert comment.save
end

test 'should relate answer comments to user and answer but not node' do
answer = answers(:one)
test 'should relate comments to user but not node' do
user = users(:bob)
comment = Comment.new(comment: 'Test comment')
comment.user = user
comment.answer = answer

assert comment.save
assert_equal user.comments.last, comment
Expand Down