These three specs files use the pattern: ```ruby RSpec.describe ClassName do describe "ClassName" do ``` This is redundant and unnecessary. Drop the `describe "ClassName" do`. There are many other cases where we could drop unnecessary spec subclasses (any nested describe/context blocks not using before/after/let/etc. can be folded into the containing block), but as those could potentially be useful for grouping (even if I don't think the tradeoff is worth it), I am not modifying those.
23 lines
782 B
Ruby
23 lines
782 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "spec_helper"
|
|
|
|
RSpec.describe ApiKey do
|
|
let(:prj) {
|
|
Project.create_with_id(name: "test-project")
|
|
}
|
|
|
|
it "can be created and rotated" do
|
|
expect(prj.api_keys.count).to eq 0
|
|
api_key = described_class.create_with_id(owner_table: "project", owner_id: prj.id, used_for: "inference_endpoint", project_id: prj.id)
|
|
expect(prj.reload.api_keys.count).to eq 1
|
|
key = api_key.key
|
|
api_key.rotate
|
|
expect(api_key.key).not_to eq key
|
|
end
|
|
|
|
it "can be created and rotated2" do
|
|
expect { described_class.create_with_id(owner_table: "invalid-owner", owner_id: "2d1784a8-f70d-48e7-92b1-3f428381d62f", used_for: "inference_endpoint", project_id: prj.id) }.to raise_error("Invalid owner_table: invalid-owner")
|
|
end
|
|
end
|