soapy_cake 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a83e62398d6bf19d63c844e3b38b49ef77e1c32
4
- data.tar.gz: d3343d5c47737c662a489885633aa481d71bfa4f
3
+ metadata.gz: 6f1b3eafd1d67264317255af0c6a0ec5a7bdf768
4
+ data.tar.gz: 060efd87807a74298141dc39000b59f029e06974
5
5
  SHA512:
6
- metadata.gz: a76be5731e6506480c83e4a1fbbbf73dcfb0c6121a8e9bef0b5ab79e46e06d9dc18465dadd1f3bcbfea21babe07270aab845f7211b63507094f1145bf1131b54
7
- data.tar.gz: 5fe3a19428b63b69d115252904e865e5d4715bdff19b76e1db8bd49c3f74216058ebb6f4667dac7c63b1898d003b9ad1483059a630bb54237367bf235b154b57
6
+ metadata.gz: 27b28c976de97f17fc8e15e3c2a8052d17855f3edc17fe07b1e116cb713f94fcfb2924fb18bd4ee014cfce5ebedecbfbdb6fe63e8ef5c2fe7330b00595f159de
7
+ data.tar.gz: f4242f62639da6318b213391528d4c6e7e43038567a4da2a8502c208348a04e8db0a84a608a7be5d84e10997cac1751ec9d6da1d2d85634d98141c6b7901b202
@@ -111,6 +111,10 @@ module SoapyCake
111
111
  run Request.new(:admin, :addedit, :contact, opts)
112
112
  end
113
113
 
114
+ def add_geo_targets(opts)
115
+ edit_geo_targets(opts.merge(add_edit_option: 'add'))
116
+ end
117
+
114
118
  def edit_geo_targets(opts)
115
119
  require_params(opts, %i(offer_contract_id allow_countries))
116
120
 
@@ -120,7 +124,8 @@ module SoapyCake
120
124
  geo_targets_redirect_options(opts)
121
125
  end
122
126
 
123
- opts = opts.merge(add_edit_option: 'replace', set_targeting_to_geo: true)
127
+ opts[:add_edit_option] ||= 'replace'
128
+ opts[:set_targeting_to_geo] = true
124
129
 
125
130
  run Request.new(:admin, :addedit, :geo_targets, opts)
126
131
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SoapyCake
3
- VERSION = '2.0.0'
3
+ VERSION = '2.1.0'
4
4
  end
@@ -83,4 +83,56 @@ RSpec.describe SoapyCake::AdminAddedit do
83
83
  admin_addedit.add_offer(offer_params.merge(tags: 'tag', tags_replace: true))
84
84
  end
85
85
  end
86
+
87
+ describe '#edit_geo_targets' do
88
+ let(:base_opts) do
89
+ {
90
+ offer_contract_id: 1,
91
+ allow_countries: true,
92
+ countries: %w(DE)
93
+ }
94
+ end
95
+
96
+ it 'replaces the existing config by default' do
97
+ expect(SoapyCake::Request).to receive(:new)
98
+ .with(:admin, :addedit, :geo_targets,
99
+ hash_including(add_edit_option: 'replace'))
100
+
101
+ admin_addedit.edit_geo_targets(base_opts)
102
+ end
103
+
104
+ it 'allows to override the add_edit_option' do
105
+ expect(SoapyCake::Request).to receive(:new)
106
+ .with(:admin, :addedit, :geo_targets,
107
+ hash_including(add_edit_option: 'add'))
108
+
109
+ admin_addedit.edit_geo_targets(base_opts.merge(add_edit_option: 'add'))
110
+ end
111
+
112
+ it 'does not mutate the passed options' do
113
+ allow(SoapyCake::Request).to receive(:new)
114
+
115
+ opts_before = base_opts.dup
116
+ admin_addedit.edit_geo_targets(base_opts)
117
+ expect(base_opts).to eq(opts_before)
118
+ end
119
+ end
120
+
121
+ describe '#add_geo_targets' do
122
+ let(:base_opts) do
123
+ {
124
+ offer_contract_id: 1,
125
+ allow_countries: true,
126
+ countries: %w(DE)
127
+ }
128
+ end
129
+
130
+ it 'adds geo targets' do
131
+ expect(SoapyCake::Request).to receive(:new)
132
+ .with(:admin, :addedit, :geo_targets,
133
+ hash_including(add_edit_option: 'add'))
134
+
135
+ admin_addedit.add_geo_targets(base_opts)
136
+ end
137
+ end
86
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_cake
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-14 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport