-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Syndicode/issue-activerecord-lazy-model-st…
…ructure fix issue with `method_defined?`
- Loading branch information
Showing
6 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
RSpec.describe "ActiveRecord integration using AttrFilters::ActiveModel", if: active_record? do | ||
context "attributes lazy loading" do | ||
it "should success add filter to an attribute" do | ||
ActiveRecord::Base.establish_connection( | ||
adapter: "sqlite3", | ||
database: ":memory:" | ||
) | ||
ActiveRecord::Base.connection.execute(%(CREATE TABLE IF NOT EXISTS users (name TEXT, age INT);)) | ||
class User < ActiveRecord::Base | ||
include AttrFilters::ActiveModel | ||
|
||
filters :name, trim: true | ||
end | ||
|
||
user = User.new(name: " Mike Dou") | ||
user.valid? | ||
|
||
expect(user.name).to eq("Mike Dou") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters