-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: fix read_value method in Administrate::Field::Base
- Loading branch information
Showing
3 changed files
with
46 additions
and
6 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "rails_helper" | ||
require "administrate/field/base" | ||
|
||
module Administrate | ||
module Field | ||
class VirtualField < Field::Base | ||
def self.searchable? | ||
false | ||
end | ||
|
||
def read_value(data = nil) | ||
resource.inspect | ||
end | ||
|
||
def foobar | ||
"This is a Foobar: #{data}" | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe Administrate::Field::VirtualField do | ||
|
||
describe "#foobar" do | ||
it "displays the foobar" do | ||
resource = double('Model', inspect: 'Inspecting') | ||
Check failure on line 26 in spec/lib/fields/virtual_field_spec.rb GitHub Actions / standardrb
|
||
|
||
field = Administrate::Field::VirtualField.new( | ||
:virtual_field, | ||
nil, | ||
:show, | ||
resource: resource | ||
) | ||
|
||
expect(field.foobar).to eq("This is a Foobar: Inspecting") | ||
end | ||
end | ||
end |