mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 16:46:12 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
21 lines
534 B
Ruby
21 lines
534 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe ClicksController do
|
|
|
|
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}") }
|
|
|
|
context '#track' do
|
|
it "creates a TopicLinkClick" do
|
|
sign_in(Fabricate(:user))
|
|
|
|
expect {
|
|
get "/clicks/track", params: { url: url, post_id: post.id, topic_id: post.topic_id }, headers: headers
|
|
}.to change { TopicLinkClick.count }.by(1)
|
|
end
|
|
end
|
|
end
|