Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b9c066d8
authored
Jun 04, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20242 При изменении значения переменной в РК ставить ее в очередь на обновление.
1 parent
f3268e03
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
11 deletions
app/Http/Controllers/CampaignVariablesController.php
tests/Unit/ReplaceByVariablesTest.php
app/Http/Controllers/CampaignVariablesController.php
View file @
b9c066d
...
...
@@ -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
->
groups
()
->
update
([
'updated_need'
=>
Carbon
::
now
(),
]);
}
}
tests/Unit/ReplaceByVariablesTest.php
View file @
b9c066d
...
...
@@ -65,23 +65,49 @@ class ReplaceByVariablesTest extends TestCase
})
->
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'
,
'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'
,
'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
()
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment