[Admin] Disable editing base currency exchange rate

This commit is contained in:
Mateusz Zalewski 2016-11-09 16:18:42 +01:00
parent b21cb4ea15
commit d5c130b103
No known key found for this signature in database
GPG key ID: CFC1E4176165876B
6 changed files with 57 additions and 20 deletions

View file

@ -1,15 +0,0 @@
@managing_currencies
Feature: Inability of disabling the base currency
In order to always have the base currency available in the store
As an Administrator
I want to be prevented from disabling the base currency
Background:
Given I am logged in as an administrator
@ui
Scenario:
Given the store operates on a single channel
And it uses the "USD" currency by default
When I want to edit this currency
Then I should not be able to disable this currency

View file

@ -0,0 +1,22 @@
@managing_currencies
Feature: Inability of modifying the base currency
In order to always have the base currency available in the store with base exchange rate
As an Administrator
I want to be prevented from modifying the base currency
Background:
Given I am logged in as an administrator
@ui
Scenario: Being prevented from disabling base currency
Given the store operates on a single channel
And it uses the "USD" currency by default
When I want to edit this currency
Then I should not be able to disable this currency
@ui
Scenario: Being prevented from changing base currency exchange rate
Given the store operates on a single channel
And it uses the "USD" currency by default
When I want to edit this currency
Then I should not be able to change exchange rate of this currency

View file

@ -140,7 +140,18 @@ final class ManagingCurrenciesContext implements Context
{
Assert::true(
$this->updatePage->canBeDisabled(),
'I should not be able to disable this currency'
'I should not be able to disable this currency.'
);
}
/**
* @Then I should not be able to change exchange rate of this currency
*/
public function iCannotChangeItsExchangeRate()
{
Assert::true(
$this->updatePage->canHaveExchangeRateChanged(),
'I should not be able to change exchange rate of this currency.'
);
}

View file

@ -32,6 +32,14 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
return $toggleableElement->hasAttribute('disabled');
}
/**
* {@inheritdoc}
*/
public function canHaveExchangeRateChanged()
{
return $this->getElement('exchangeRate')->hasAttribute('disabled');
}
/**
* {@inheritdoc}
*/

View file

@ -26,6 +26,11 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
*/
public function canBeDisabled();
/**
* @return bool
*/
public function canHaveExchangeRateChanged();
/**
* @param string $exchangeRate
*/

View file

@ -55,10 +55,16 @@ class CurrencyType extends BaseCurrencyType
$form = $event->getForm();
$form->add('enabled', 'checkbox', [
'label' => 'sylius.form.locale.enabled',
'disabled' => true,
]);
$form
->add('enabled', 'checkbox', [
'label' => 'sylius.form.locale.enabled',
'disabled' => true,
])
->add('exchangeRate', 'number', [
'label' => 'sylius.form.currency.exchange_rate',
'disabled' => true,
])
;
});
}