2018-06-07 12:57:29 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ClicksController do
|
|
|
|
|
2019-04-23 17:41:36 +08:00
|
|
|
let(:url) { "https://discourse.org/" }
|
|
|
|
let(:headers) { { REMOTE_ADDR: "192.168.0.1" } }
|
|
|
|
let(:post) { create_post(raw: "this is a post with a link #{url}") }
|
2018-06-07 12:57:29 +08:00
|
|
|
|
2019-04-23 17:41:36 +08:00
|
|
|
context '#track' do
|
|
|
|
it "creates a TopicLinkClick" do
|
|
|
|
sign_in(Fabricate(:user))
|
2018-06-07 12:57:29 +08:00
|
|
|
|
2019-04-23 17:41:36 +08:00
|
|
|
expect {
|
|
|
|
get "/clicks/track", params: { url: url, post_id: post.id, topic_id: post.topic_id }, headers: headers
|
|
|
|
}.to change { TopicLinkClick.count }.by(1)
|
2018-06-07 12:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|