SimplyBased 0.1.0 — Couchbase-native ActiveModel ORM

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>
This commit is contained in:
GregandClaude Opus 4.8 committed 2026-06-20 13:58:47 -05:00
commit 86299b8827
84 files changed
+9904

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
require 'spec_helper'
describe 'Mass assignment protection' do
context 'when using attr_protected' do
before do
Category.instance_eval do
@_accessible_attributes = []
attr_protected :parent, :alias
end
end
it 'does not allow to set with mass assignment using attributes=' do
item = Category.new
item.attributes = { parent: 'a', name: 'c' }
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
it 'does not allow to set with mass assignment using attributes= - ignore string vs. symbol' do
item = Category.new
item.attributes = { 'parent' => 'a', 'name' => 'c' }
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
it 'does not allow to set with mass assignment using the constructor' do
item = Category.new(parent: 'a', name: 'c')
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
it 'does not allow to set with mass assignment using update_attributes' do
item = Category.new
item.update_attributes(parent: 'a', name: 'c')
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
end
context 'attr_accessible' do
before do
Category.instance_eval do
@_protected_attributes = []
attr_accessible :name
end
end
it 'does not allow to set with mass assignment using attributes=' do
item = Category.new
item.attributes = { parent: 'a', name: 'c' }
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
it 'does not allow to set with mass assignment using the constructor' do
item = Category.new(parent: 'a', name: 'c')
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
it 'does not allow to set with mass assignment using update_attributes' do
item = Category.new
item.update_attributes(parent: 'a', name: 'c')
expect(item.name).to eq 'c'
expect(item.parent).to be_nil
end
end
end