A from-scratch fork of simply_couch's model layer that runs on Couchbase natively: `include SimplyBased::Model` instead of `include SimplyCouch::Model`. - SimplyBased::Store replaces the CouchDB layer: KV documents, N1QL/SQL++ finders + lazily-created GSIs, CAS mapped onto _rev. No design documents or JavaScript map/reduce — the hand-written association views become N1QL (belongs_to/has_many/has_one scalar FK; habtm via ANY ... SATISFIES + array index, or KV multi-get on the storing side). - Redis replacements on the same cluster: Counter (atomic increment/decrement), Cache (ActiveSupport::Cache::Store over KV+TTL, drop-in Rails.cache/ActiveJob), Lock (insert-if-absent + TTL + CAS-checked release). - Runs the simply_couch test suite against live Couchbase: 378/432 applicable examples green (CouchDB-mechanic specs tagged :couchdb_only and excluded). - Remaining: ancestry (tree) + embedded_in reverse-lookups (recursive/embedded N1QL) and a few pagination/lifecycle edges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
992 B
Ruby
38 lines
992 B
Ruby
require 'spec_helper'
|
|
|
|
describe 'has_local_attached' do
|
|
before do
|
|
class DefaultStyleTest
|
|
include SimplyBased::Model
|
|
property :title
|
|
has_local_attached :file, default_style: :not_original
|
|
end
|
|
end
|
|
|
|
it 'uses default_style when no style given for url' do
|
|
obj = DefaultStyleTest.new
|
|
obj.file_file_name = 'test.jpg'
|
|
|
|
expect(obj.file.url).to eq '/system/file/tmp/not_original.jpg'
|
|
end
|
|
|
|
it 'uses default_style when no style given for path' do
|
|
obj = DefaultStyleTest.new
|
|
obj.file_file_name = 'test.jpg'
|
|
|
|
expect(obj.file.path).to end_with '/system/file/tmp/not_original.jpg'
|
|
end
|
|
|
|
it 'allows explicit style override' do
|
|
obj = DefaultStyleTest.new
|
|
obj.file_file_name = 'test.jpg'
|
|
|
|
expect(obj.file.url(:thumb)).to eq '/system/file/tmp/thumb.jpg'
|
|
end
|
|
|
|
it 'uses default_style from attachment_registry' do
|
|
config = DefaultStyleTest.attachment_registry[:file]
|
|
expect(config[:default_style]).to eq :not_original
|
|
end
|
|
end
|