mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 06:13:44 +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
28 lines
696 B
Ruby
28 lines
696 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
require_dependency 'post'
|
|
require_dependency 'user'
|
|
|
|
describe BasicPostSerializer do
|
|
|
|
context "name" do
|
|
let(:user) { Fabricate.build(:user) }
|
|
let(:post) { Fabricate.build(:post, user: user) }
|
|
let(:serializer) { BasicPostSerializer.new(post, scope: Guardian.new, root: false) }
|
|
let(:json) { serializer.as_json }
|
|
|
|
it "returns the name it when `enable_names` is true" do
|
|
SiteSetting.enable_names = true
|
|
expect(json[:name]).to be_present
|
|
end
|
|
|
|
it "doesn't return the name it when `enable_names` is false" do
|
|
SiteSetting.enable_names = false
|
|
expect(json[:name]).to be_blank
|
|
end
|
|
|
|
end
|
|
|
|
end
|