Commit b9c066d8 by Vladislav

#20242 При изменении значения переменной в РК ставить ее в очередь на обновление.

1 parent f3268e03
...@@ -177,11 +177,6 @@ class CampaignVariablesController extends Controller ...@@ -177,11 +177,6 @@ class CampaignVariablesController extends Controller
if (is_null($value)) { if (is_null($value)) {
$dictionary_campaign->dictionaryCampaignVariables()->where('variable_id', $variable_id) $dictionary_campaign->dictionaryCampaignVariables()->where('variable_id', $variable_id)
->delete(); ->delete();
$dictionary_campaign->update([
'updated_need' => Carbon::now(),
]);
} else { } else {
$dictionary_campaign_variable = $dictionary_campaign->dictionaryCampaignVariables()->firstWhere('variable_id', $variable_id); $dictionary_campaign_variable = $dictionary_campaign->dictionaryCampaignVariables()->firstWhere('variable_id', $variable_id);
...@@ -196,11 +191,16 @@ class CampaignVariablesController extends Controller ...@@ -196,11 +191,16 @@ class CampaignVariablesController extends Controller
]); ]);
} }
}
$dictionary_campaign->update([ $dictionary_campaign->update([
'updated_need' => Carbon::now(), 'updated_need' => Carbon::now(),
]); ]);
} $dictionary_campaign->groups()->update([
'updated_need' => Carbon::now(),
]);
} }
} }
...@@ -65,23 +65,49 @@ class ReplaceByVariablesTest extends TestCase ...@@ -65,23 +65,49 @@ class ReplaceByVariablesTest extends TestCase
})->all() })->all()
); );
$this->variable = factory(Variable::class)->create([ $this->dictionaryCampaign = DictionaryCampaign::first();
$this->assertNull($this->dictionaryCampaign->updated_need);
$this->actingAs($this->user)
->post(route('token.campaign.variable.add', [
$this->token->id,
$this->dictionary->getKey(),
$this->campaign->id,
]), [
'variable' => 'add',
'name' => 'var', 'name' => 'var',
'default_value' => 'var value', 'default_value' => 'var value',
]); ])
->assertStatus(302);
$this->assertEquals(1, Variable::count());
$this->variable = Variable::first();
$this->variable_2 = factory(Variable::class)->create([ $this->actingAs($this->user)
->post(route('token.campaign.variable.add', [
$this->token->id,
$this->dictionary->getKey(),
$this->campaign->id,
]), [
'variable' => 'add',
'name' => 'vartwo', 'name' => 'vartwo',
'default_value' => 'vartwo value', 'default_value' => 'vartwo value',
]); ])
->assertStatus(302);
$this->dictionaryCampaign = DictionaryCampaign::first(); $this->assertEquals(2, Variable::count());
$this->dictionaryCampaign->dictionaryCampaignVariables()->create([ $this->dictionaryCampaign->dictionaryCampaignVariables()->create([
'variable_id' => $this->variable->getKey(), 'variable_id' => $this->variable->getKey(),
'value' => 'custom var value', 'value' => 'custom var value',
]); ]);
$this->dictionaryCampaign->refresh();
$this->assertNotNull($this->dictionaryCampaign->updated_need);
} }
public function testReplaceByVariables() public function testReplaceByVariables()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!