mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 22:09:12 +08:00
DEV: Update the rubocop-discourse gem
This enables cops related to RSpec `subject`. See https://github.com/discourse/rubocop-discourse/pull/32
This commit is contained in:

committed by
Loïc Guitaut

parent
8e1d049e6b
commit
0f4beab0fb
@ -1,16 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe BasicGroupSerializer do
|
||||
subject(:serializer) { described_class.new(group, scope: guardian, root: false) }
|
||||
|
||||
let(:guardian) { Guardian.new }
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
subject { described_class.new(group, scope: guardian, root: false) }
|
||||
|
||||
describe "#display_name" do
|
||||
describe "automatic group" do
|
||||
let(:group) { Group.find(1) }
|
||||
|
||||
it "should include the display name" do
|
||||
expect(subject.display_name).to eq(I18n.t("groups.default_names.admins"))
|
||||
expect(serializer.display_name).to eq(I18n.t("groups.default_names.admins"))
|
||||
end
|
||||
end
|
||||
|
||||
@ -18,22 +19,22 @@ RSpec.describe BasicGroupSerializer do
|
||||
fab!(:group) { Fabricate(:group) }
|
||||
|
||||
it "should not include the display name" do
|
||||
expect(subject.display_name).to eq(nil)
|
||||
expect(serializer.display_name).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#bio_raw" do
|
||||
fab!(:group) { Fabricate(:group, bio_raw: "testing :slightly_smiling_face:") }
|
||||
|
||||
subject do
|
||||
subject(:serializer) do
|
||||
described_class.new(group, scope: guardian, root: false, owner_group_ids: [group.id])
|
||||
end
|
||||
|
||||
fab!(:group) { Fabricate(:group, bio_raw: "testing :slightly_smiling_face:") }
|
||||
|
||||
describe "group owner" do
|
||||
it "should include bio_raw" do
|
||||
expect(subject.as_json[:bio_raw]).to eq("testing :slightly_smiling_face:")
|
||||
expect(subject.as_json[:bio_excerpt]).to start_with("testing <img")
|
||||
expect(serializer.as_json[:bio_raw]).to eq("testing :slightly_smiling_face:")
|
||||
expect(serializer.as_json[:bio_excerpt]).to start_with("testing <img")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -48,7 +49,7 @@ RSpec.describe BasicGroupSerializer do
|
||||
|
||||
it "should be present" do
|
||||
Group.refresh_automatic_groups!
|
||||
expect(subject.as_json[:has_messages]).to eq(true)
|
||||
expect(serializer.as_json[:has_messages]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -59,7 +60,7 @@ RSpec.describe BasicGroupSerializer do
|
||||
before { group.add(user) }
|
||||
|
||||
it "should be present" do
|
||||
expect(subject.as_json[:has_messages]).to eq(true)
|
||||
expect(serializer.as_json[:has_messages]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -67,7 +68,7 @@ RSpec.describe BasicGroupSerializer do
|
||||
let(:guardian) { Guardian.new(Fabricate(:user)) }
|
||||
|
||||
it "should not be present" do
|
||||
expect(subject.as_json[:has_messages]).to eq(nil)
|
||||
expect(serializer.as_json[:has_messages]).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -82,7 +83,7 @@ RSpec.describe BasicGroupSerializer do
|
||||
before { group.add(user) }
|
||||
|
||||
it "should be true" do
|
||||
expect(subject.as_json[:can_see_members]).to eq(true)
|
||||
expect(serializer.as_json[:can_see_members]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
@ -90,7 +91,7 @@ RSpec.describe BasicGroupSerializer do
|
||||
let(:guardian) { Guardian.new(Fabricate(:user)) }
|
||||
|
||||
it "should be false" do
|
||||
expect(subject.as_json[:can_see_members]).to eq(false)
|
||||
expect(serializer.as_json[:can_see_members]).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user