Commit b9c066d8 by Vladislav

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

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