Files
grecia/spec/models/attachable_spec.rb
Javi Martín edd47877c2 Extract methods to get tenant subfolder/file paths
We were using the same logic in many different places, so we're
simplifying the code. I'm not convinced about the method names, though,
so we might change them in the future.

Note using this method for the default tenant in the `TenantDiskService`
class resulted in a `//` in the path, which is probably harmless but
very ugly and it also generates a different key than the one we got
until now. I've added an extra test to make sure that isn't the case.
2022-11-11 01:41:14 +01:00

18 lines
535 B
Ruby

require "rails_helper"
describe Attachable do
it "stores attachments for the default tenant in the default folder" do
file_path = build(:image).file_path
expect(file_path).to include "storage/"
expect(file_path).not_to include "storage//"
expect(file_path).not_to include "tenants"
end
it "stores tenant attachments in a folder for the tenant" do
allow(Tenant).to receive(:current_schema).and_return("image-master")
expect(build(:image).file_path).to include "storage/tenants/image-master/"
end
end