From 6083387a5eedc7bbdfada15ffbc0e16fd54d4988 Mon Sep 17 00:00:00 2001 From: Jakub Mahnert Date: Fri, 12 Jan 2018 15:55:44 +0100 Subject: [PATCH] fix skip actions --- lib/gooddata/lcm/lcm2.rb | 10 ++++------ spec/unit/lcm/lcm2_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 spec/unit/lcm/lcm2_spec.rb diff --git a/lib/gooddata/lcm/lcm2.rb b/lib/gooddata/lcm/lcm2.rb index 2181f6db1..4b60f12a0 100644 --- a/lib/gooddata/lcm/lcm2.rb +++ b/lib/gooddata/lcm/lcm2.rb @@ -276,11 +276,6 @@ def perform(mode, params = {}) end end - check_unused_params(actions, params) - - # Print name of actions to be performed for debug purposes - print_action_names(mode, actions) - # TODO: Check all action params first new_params = params @@ -299,9 +294,12 @@ def perform(mode, params = {}) skip_actions = (params.skip_actions || []) actions = actions.reject do |action| - skip_actions.include?(action.to_s) + skip_actions.include?(action.name.split('::').last) end + check_unused_params(actions, params) + print_action_names(mode, actions) + # Run actions errors = [] results = [] diff --git a/spec/unit/lcm/lcm2_spec.rb b/spec/unit/lcm/lcm2_spec.rb new file mode 100644 index 000000000..f99cfdd41 --- /dev/null +++ b/spec/unit/lcm/lcm2_spec.rb @@ -0,0 +1,36 @@ +# encoding: UTF-8 +# +# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved. +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +require 'gooddata/lcm/lcm2' + +describe 'GoodData::LCM2' do + describe '#skip_actions' do + let(:client) { double(:client) } + let(:domain) { double(:domain) } + let(:logger) { double(:logger) } + let(:params) do + params = { + skip_actions: %w(CollectSegments SynchronizeUsers), + GDC_GD_CLIENT: client, + GDC_LOGGER: logger + } + GoodData::LCM2.convert_to_smart_hash(params) + end + + before do + allow(client).to receive(:class) { GoodData::Rest::Client } + allow(client).to receive(:domain) { domain } + allow(logger).to receive(:info) + allow(domain).to receive(:data_products) + end + + it 'skips actions in skip_actions' do + expect(GoodData::LCM2::CollectSegments).not_to receive(:call) + expect(GoodData::LCM2::SynchronizeUsers).not_to receive(:call) + GoodData::LCM2.perform('users', params) + end + end +end