Sha256: 50a5e8644a13f8d115f467874d5aabc64bef1b55603a2f742347136cee882d7c

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

module ForestLiana
  module Utils
    describe ContextVariables do
      let(:user) do
        {
           'id' => '1',
           'email' => 'jd@forestadmin.com',
           'first_name' => 'John',
           'last_name' => 'Doe',
           'team' => 'Operations',
           'role' => 'role-test',
           'tags' => [{'key' => 'tag1', 'value' => 'value1' }, {'key' => 'tag2', 'value' => 'value2'}],
           'rendering_id'=> '1'
        }
      end

      let(:team) do
        {
          'id' => 1,
          'name' => 'Operations'
        }
      end

      let(:request_context_variables) do
        {
          'foo.id' => 100
        }
      end

      it 'returns the request context variable key when the key is not present into the user data' do
        context_variables = described_class.new(team, user, request_context_variables)
        expect(context_variables.get_value('foo.id')).to eq(100)
      end

      it 'returns the corresponding value from the key provided of the user data' do
        context_variables = described_class.new(team, user, request_context_variables)
        expect(context_variables.get_value('currentUser.first_name')).to eq('John')
        expect(context_variables.get_value('currentUser.tags.key')).to eq('tag1')
        expect(context_variables.get_value('currentUser.team.id')).to eq(1)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
forest_liana-9.4.0 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.16 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.15 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.14 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.13 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.12 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.11 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.10 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.9 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.8 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.7 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.6 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.3 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.2 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.1 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.3.0 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.2.3 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.2.2 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.2.1 spec/services/forest_liana/utils/context_variables_spec.rb
forest_liana-9.2.0 spec/services/forest_liana/utils/context_variables_spec.rb