It hasn't been necessary to use create_with_id since
ebc79622df
, in December 2024.
I have plans to introduce:
```ruby
def create_with_id(id, values)
obj = new(values)
obj.id = id
obj.save_changes
end
```
This will make it easier to use the same id when creating
multiple objects. The first step is removing the existing
uses of create_with_id.
41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
RSpec.describe Clover, "firewall" do
|
|
let(:user) { create_account }
|
|
|
|
let(:project) { project_with_default_policy(user) }
|
|
|
|
let(:firewall) { Firewall.create(name: "default-firewall", location_id: Location::HETZNER_FSN1_ID, project_id: project.id) }
|
|
|
|
describe "unauthenticated" do
|
|
it "not list" do
|
|
get "/project/#{project.ubid}/firewall"
|
|
|
|
expect(last_response).to have_api_error(401, "must include personal access token in Authorization header")
|
|
end
|
|
|
|
it "not create" do
|
|
post "/project/#{project.ubid}/firewall"
|
|
|
|
expect(last_response).to have_api_error(401, "must include personal access token in Authorization header")
|
|
end
|
|
end
|
|
|
|
describe "authenticated" do
|
|
before do
|
|
login_api
|
|
end
|
|
|
|
it "success get all firewalls" do
|
|
Firewall.create(name: "#{firewall.name}-2", location_id: Location::HETZNER_FSN1_ID, project_id: project.id)
|
|
|
|
get "/project/#{project.ubid}/firewall"
|
|
|
|
expect(last_response.status).to eq(200)
|
|
expect(JSON.parse(last_response.body)["items"].length).to eq(2)
|
|
end
|
|
end
|
|
end
|