Sha256: 898035d81f1416c4dd27ba6e27d2f508f3981eaeb08b0773f12f1a17d36c3eb3
Contents?: true
Size: 908 Bytes
Versions: 11
Compression:
Stored size: 908 Bytes
Contents
require 'rails_helper' module Wordpress RSpec.describe Relationship, type: :model do let(:post) { create(:post, :with_tags) } let(:first_tag) { post.tags.first } let(:second_tag) { post.tags[1] } it "has tags" do expect(post.tags.count).to eq 2 end it "increments counts" do expect(first_tag.count).to eq 1 expect(second_tag.count).to eq 1 end it "decrements counts when removed from a post" do first_tag second_tag post.tags.destroy_all first_tag.reload second_tag.reload expect(first_tag.count).to eq 0 expect(second_tag.count).to eq 0 end it "decrements count when post is deleted" do first_tag second_tag post.destroy first_tag.reload second_tag.reload expect(first_tag.count).to eq 0 expect(second_tag.count).to eq 0 end end end
Version data entries
11 entries across 11 versions & 1 rubygems