refact
This commit is contained in:
@@ -109,8 +109,8 @@ RSpec.describe WarpEngine::ApplicationToken, type: :model do
|
||||
token = create(:application_token)
|
||||
token.revoke!
|
||||
|
||||
expect(described_class.find_by(id: token.id)).to be_nil
|
||||
expect(described_class.unscoped.find(token.id).deleted_at).to be_present
|
||||
expect(described_class.kept.find_by(id: token.id)).to be_nil
|
||||
expect(described_class.find(token.id).deleted_at).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -36,18 +36,24 @@ RSpec.describe WarpEngine::Pipeline do
|
||||
end
|
||||
end
|
||||
|
||||
describe "default_scope" do
|
||||
describe ".kept scope" do
|
||||
it "excludes soft-deleted records" do
|
||||
repo = create(:pipeline)
|
||||
repo.update_column(:deleted_at, Time.current)
|
||||
|
||||
expect(described_class.all).not_to include(repo)
|
||||
expect(described_class.unscoped).to include(repo)
|
||||
expect(described_class.kept).not_to include(repo)
|
||||
end
|
||||
|
||||
it "includes soft-deleted records without scope" do
|
||||
repo = create(:pipeline)
|
||||
repo.update_column(:deleted_at, Time.current)
|
||||
|
||||
expect(described_class.all).to include(repo)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".active" do
|
||||
it "returns only active repos" do
|
||||
it "returns only active kept repos" do
|
||||
active = create(:pipeline, active: true)
|
||||
inactive = create(:pipeline, active: false)
|
||||
|
||||
|
||||
@@ -13,12 +13,19 @@ RSpec.describe WarpEngine::Software, type: :model do
|
||||
it { should have_many(:external_links) }
|
||||
it { should have_many(:software_images).dependent(:destroy) }
|
||||
|
||||
describe "default scope" do
|
||||
describe ".kept scope" do
|
||||
it "excludes soft-deleted records" do
|
||||
active = create(:software)
|
||||
create(:software, deleted_at: Time.current)
|
||||
|
||||
expect(WarpEngine::Software.all).to eq([active])
|
||||
expect(WarpEngine::Software.kept).to eq([active])
|
||||
end
|
||||
|
||||
it "includes soft-deleted records without scope" do
|
||||
active = create(:software)
|
||||
deleted = create(:software, deleted_at: Time.current)
|
||||
|
||||
expect(WarpEngine::Software.all).to contain_exactly(active, deleted)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user