Files
nairobi/spec/models/concerns/has_public_author.rb
Javi Martín 6268ae9274 Add and apply RSpec/BeNil rubocop rule
This rule was added in rubocop-rspec 2.9.0.

We were using `be_nil` 50% of the time, and `be nil` the rest of the
time. No strong preference for either one, but IMHO we don't lose
anything be being consistent.
2023-09-06 19:00:56 +02:00

22 lines
649 B
Ruby

require "spec_helper"
shared_examples_for "has_public_author" do
let(:model) { described_class }
describe "public_author" do
it "returns author if author's activity is public" do
author = create(:user, public_activity: true)
authored_element = create(model.to_s.underscore.to_sym, author: author)
expect(authored_element.public_author).to eq(author)
end
it "returns nil if author's activity is private" do
author = create(:user, public_activity: false)
authored_element = create(model.to_s.underscore.to_sym, author: author)
expect(authored_element.public_author).to be nil
end
end
end