discourse/spec/requests/clicks_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
629 B
Ruby
Raw Normal View History

# frozen_string_literal: true
RSpec.describe ClicksController do
let(:url) { "https://discourse.org/" }
let(:headers) { { REMOTE_ADDR: "192.168.0.1" } }
2019-05-07 16:19:13 +08:00
let(:post_with_url) { create_post(raw: "this is a post with a link #{url}") }
describe "#track" do
it "creates a TopicLinkClick" do
sign_in(Fabricate(:user))
expect {
2019-05-07 16:19:13 +08:00
post "/clicks/track",
params: {
url: url,
post_id: post_with_url.id,
topic_id: post_with_url.topic_id,
},
headers: headers
}.to change { TopicLinkClick.count }.by(1)
end
end
end