mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 09:03:45 +08:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
19 lines
538 B
Ruby
19 lines
538 B
Ruby
# frozen_string_literal: true
|
|
|
|
describe ClicksController do
|
|
|
|
let(:url) { "https://discourse.org/" }
|
|
let(:headers) { { REMOTE_ADDR: "192.168.0.1" } }
|
|
let(:post_with_url) { create_post(raw: "this is a post with a link #{url}") }
|
|
|
|
context '#track' do
|
|
it "creates a TopicLinkClick" do
|
|
sign_in(Fabricate(:user))
|
|
|
|
expect {
|
|
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
|