Skip to content

Commit

Permalink
Merge pull request #87 from A1-frkweiichi/debug/article_is_not_active
Browse files Browse the repository at this point in the history
RSpec: Add Test of scope :postable
  • Loading branch information
A1-frkweiichi authored Sep 21, 2024
2 parents c2bfdc3 + 9e73f37 commit ebbb057
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/models/article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@
end
end

describe 'scopes' do
describe '.postable' do
it 'returns only postable and active articles' do
postable_article = create(:article, user:, is_postable: true, is_active: true)
not_postable_article = create(:article, user:, is_postable: false, is_active: true)
inactive_article = create(:article, user:, is_postable: true, is_active: false)

postable_articles = Article.postable

expect(postable_articles).to include(postable_article)
expect(postable_articles).not_to include(not_postable_article)
expect(postable_articles).not_to include(inactive_article)
end
end
end

describe '.random_postable_article' do
it 'returns a postable article' do
create(:article, user:, is_postable: true, is_active: true)
Expand Down

0 comments on commit ebbb057

Please sign in to comment.