mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 02:35:29 +08:00
Add missing test case for PostController#timings
.
This commit is contained in:
parent
1043a2e99f
commit
5c1143cd55
@ -588,9 +588,10 @@ class TopicsController < ApplicationController
|
||||
current_user,
|
||||
params[:topic_id].to_i,
|
||||
params[:topic_time].to_i,
|
||||
(params[:timings] || []).map { |post_number, t| [post_number.to_i, t.to_i] },
|
||||
(params[:timings] || {}).map { |post_number, t| [post_number.to_i, t.to_i] },
|
||||
mobile: view_context.mobile_view?
|
||||
)
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
|
@ -4,6 +4,27 @@ RSpec.describe TopicsController do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
describe '#timings' do
|
||||
let(:post_1) { Fabricate(:post, topic: topic) }
|
||||
|
||||
it 'should record the timing' do
|
||||
sign_in(user)
|
||||
|
||||
post "/topics/timings.json",
|
||||
topic_id: topic.id,
|
||||
topic_time: 5,
|
||||
timings: { post_1.post_number => 2 }
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
post_timing = PostTiming.first
|
||||
|
||||
expect(post_timing.topic).to eq(topic)
|
||||
expect(post_timing.user).to eq(user)
|
||||
expect(post_timing.msecs).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#timer' do
|
||||
context 'when a user is not logged in' do
|
||||
it 'should return the right response' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user