You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been going crazy about this for about a day now and I'm at my wits' end here.
Since my Collections and Controllers have some custom fields and actions I wanted to be thorough and test them out in RSpec and for the life of me I cannot figure out how the gem does this at any point.
I've looked into the ResourceGetter, SearchQueryBuilder, ApplicationController and its serialize_model method and then into forestadmin-jsonapi-serializers and nothing seems to do the trick, I am always stuck with just my normal attributes and nil for my smart fields.
I feel like it should be "easy" and standard for a gem to be testable especially when the usage can be customized which in turn would lead to untested code.
So my question is "simple", how does one use RSpec (or any other testing library for that matter) and actually test the forest smart fields/relations/actions ?
The text was updated successfully, but these errors were encountered:
Unfortaunalbly we don’t have any helpers or functions to test the smart features.
We will soon publish a new version of the agent wich will contain these helpers.
For the moment to testing smart action you can call the endpoint generated and for the smart fields there is an example below.
require 'rails_helper'
RSpec.describe ForestLiana::ResourcesController, type: :request do
before do
ForestLiana.env_secret = 'env_secret_test'
ForestLiana.auth_secret = 'auth_secret_test'
ForestLiana::Bootstrapper.new
end
it 'should return the user serialized with the smart field "full_name"' do
user = create(:user)
controller = ForestLiana::ApplicationController.new
options = {
:field => {
'User' => 'full_name'
},
:skip_collection_check => false
}
json = controller.serialize_model(user, options)
expect(json['data']['attributes']['full_name']).to eq "#{user.first_name} #{user.last_name}"
end
end
I've been going crazy about this for about a day now and I'm at my wits' end here.
Since my Collections and Controllers have some custom fields and actions I wanted to be thorough and test them out in RSpec and for the life of me I cannot figure out how the gem does this at any point.
I've looked into the
ResourceGetter
,SearchQueryBuilder
,ApplicationController
and itsserialize_model
method and then intoforestadmin-jsonapi-serializers
and nothing seems to do the trick, I am always stuck with just my normal attributes and nil for my smart fields.I feel like it should be "easy" and standard for a gem to be testable especially when the usage can be customized which in turn would lead to untested code.
So my question is "simple", how does one use RSpec (or any other testing library for that matter) and actually test the forest smart fields/relations/actions ?
The text was updated successfully, but these errors were encountered: