diff --git a/VERSIONS_WIP/60288 b/VERSIONS_WIP/60288 index 6b300680e3ef00a31ba934f6648c247ebb58585f..8e5a01428e0d8854aeca588fa3a120ba139889f6 100644 --- a/VERSIONS_WIP/60288 +++ b/VERSIONS_WIP/60288 @@ -1 +1 @@ - - ticket #60288 : Intégration Redmine : ne pas rendre éditable les infos techniques Bokeh \ No newline at end of file + - ticket #60288 : Assistance : les informations techniques ne sont plus modifiables dans la description \ No newline at end of file diff --git a/library/Class/WebService/Redmine/Issue.php b/library/Class/WebService/Redmine/Issue.php index 25bc46db98f34ed1bc3bfe861ebf389ced566836..a415ab2e3a76a3553cf54662caebe9f2ac0af73a 100644 --- a/library/Class/WebService/Redmine/Issue.php +++ b/library/Class/WebService/Redmine/Issue.php @@ -21,6 +21,8 @@ class Class_WebService_Redmine_Issue extends Class_Entity { + use Trait_Translator; + public static function newWith($data) { $instance = new static(); $instance->updateAttributes($data); @@ -48,11 +50,23 @@ class Class_WebService_Redmine_Issue extends Class_Entity { public function getCreateParams() { return ['subject' => $this->_attribs['subject'], - 'description' => $this->_attribs['description'], + 'description' => $this->getTechnicalInformations() . "\n\n" . $this->_attribs['description'], 'custom_fields' => $this->getCustomFieldsParams()]; } + + + public function getTechnicalInformations() { + $datas = [$this->_('Url : ') . Class_Url::rootUrl() . Class_Url::baseUrl(), + $this->_('Version : ') . BOKEH_RELEASE_NUMBER . ' (' . BOKEH_VERSION . ')', + $this->_('Navigateur : ') . Zend_Controller_Front::getInstance()->getRequest()->getHeader('User-Agent'), + $this->_('Base de données : ') . Zend_Db_Table::getDefaultAdapter()->getConfig()['dbname']]; + + return implode("\n", $datas); + } + + protected function getCustomFieldsParams() { return [['id' => Class_WebService_Redmine::CUSTOM_PRIORITY_ID, 'value' => $this->_attribs['priority']], diff --git a/library/ZendAfi/Form/Redmine/Issue.php b/library/ZendAfi/Form/Redmine/Issue.php index af2f6e2dcb7c4b316ae71d7a9924194785a58a67..4c902d8afdce9eb379a4cdeccc07d63976f6d1bb 100644 --- a/library/ZendAfi/Form/Redmine/Issue.php +++ b/library/ZendAfi/Form/Redmine/Issue.php @@ -37,7 +37,9 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { public function getValues() { $values = parent::getValues(); - $values['status'] = ['id' => $values['status_id']]; + $values['status'] = ['id' => isset($values['status_id']) + ? $values['status_id'] + : 1]; return $values; } @@ -72,6 +74,16 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { 'required' => true, 'allowEmpty' => false]) + ->addElement('textarea', + 'technical_informations', + ['label' => $this->_('Informations techniques'), + 'rows' => 4, + 'cols' => 70, + 'required' => false, + 'readonly' => 'readonly', + 'allowEmpty' => false, + 'value' => $this->_issue->getTechnicalInformations()]) + ->addElement('textarea', 'description', ['label' => $this->_('Description'), @@ -79,9 +91,10 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { 'cols' => 70, 'required' => true, 'allowEmpty' => false, - 'value' => $this->getDefaultDescription()]) + 'value' => '', + 'placeholder' => $this->_('Merci de préciser les différentes étapes pour reproduire le problème rencontré, l\'adresse de la page, si il faut être connecté avec un compte particulier')]) - ->addDisplayGroup(['subject', 'description'], + ->addDisplayGroup(['subject', 'description', 'technical_informations'], 'common', ['legend' => '']) ; @@ -202,14 +215,4 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { return $this; } - - - protected function getDefaultDescription() { - $datas = [$this->_('Url : ') . Class_Url::rootUrl() . Class_Url::baseUrl(), - $this->_('Version : ') . BOKEH_RELEASE_NUMBER . ' (' . BOKEH_VERSION . ')', - $this->_('Navigateur : ') . Zend_Controller_Front::getInstance()->getRequest()->getHeader('User-Agent'), - $this->_('Base de données : ') . Zend_Db_Table::getDefaultAdapter()->getConfig()['dbname']]; - - return implode("\n", $datas); - } } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/RedmineControllerTest.php b/tests/application/modules/admin/controllers/RedmineControllerTest.php index 73044bcc5fd614f44d8774f53658fdfed67a5347..fcfdb19b818ff22b5152a01e5bebfdf4ae35fa0c 100644 --- a/tests/application/modules/admin/controllers/RedmineControllerTest.php +++ b/tests/application/modules/admin/controllers/RedmineControllerTest.php @@ -574,6 +574,63 @@ class Admin_RedmineControllerEditIssue34248Test extends Admin_RedmineControllerF +class Admin_RedmineControllerPostAddIssueTest extends Admin_RedmineControllerWithApiTestCase { + protected $_create_params; + + public function setUp() { + parent::setUp(); + + $this->_redmine_api + ->whenCalled('all') + ->with(['project_id' => 123]) + ->answers([]) + ->whenCalled('create') + ->answers([]); + + + $this->postDispatch('admin/redmine/add/id_lib/1', + ['priority' => 'Normale', + 'notes' => 'Change priority', + 'subject' => 'there\'s a bug', + 'description' => 'I think it does not work as expected', + 'technical_informations' => 'pouet', + 'module' => '', + 'contact' => '']); + + $this->_create_params = $this->_redmine_api->getFirstAttributeForLastCallOn('create'); + } + + + /** @test */ + public function descriptionFieldShouldContainsAsExpected() { + $this->assertContains('as expected', + $this->_create_params['description']); + } + + + /** @test */ + public function descriptionFieldShouldContainsTechnicalInformations() { + $this->assertContains('Url : ', + $this->_create_params['description']); + } + + + /** @test */ + public function descriptionFieldShouldContainsPouet() { + $this->assertNotContains('pouet', + $this->_create_params['description']); + } + + + /** @test */ + public function createParamsFieldsShouldNotContainsTechnicalInformations() { + $this->assertNotContains('technical_informations', array_keys($this->_create_params)); + } +} + + + + class Admin_RedmineControllerPostEditIssue34247Test extends Admin_RedmineControllerWithApiTestCase { protected $_update_params; @@ -676,6 +733,7 @@ class Admin_RedmineControllerAddIssueTest extends Admin_RedmineControllerFixture ['//select[@id="priority"]//option[@value="Normale"][@selected]'], ['//select[@id="module"]'], ['//textarea[@id="description"]'], + ['//textarea[@id="technical_informations"][@readonly][contains(text(), "Url :")]'], ['//textarea[@id="contact"]']]; }