diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-25 13:11:31 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-25 13:11:31 +0000 |
commit | cb0f024cd4c4aa51c7824e4e1a6c4d0f307afad1 (patch) | |
tree | 6d34a738b99169e4dcf620f488b614e90ce68888 | |
parent | b55f8aebab4ceec157ba38d981fe68b4dd688346 (diff) | |
parent | 398921b67ca8fefa5045fede67cf9591a0ac361f (diff) | |
download | gitlab-ce-cb0f024cd4c4aa51c7824e4e1a6c4d0f307afad1.tar.gz |
Merge branch 'ce-7013-add-epics-close-support' into 'master'
CE port of Adding state to epics
See merge request gitlab-org/gitlab-ce!21771
-rw-r--r-- | app/assets/javascripts/issue_show/components/app.vue | 1 | ||||
-rw-r--r-- | app/assets/javascripts/issue_show/components/edit_actions.vue | 15 | ||||
-rw-r--r-- | app/assets/javascripts/issue_show/components/form.vue | 5 | ||||
-rw-r--r-- | locale/gitlab.pot | 9 | ||||
-rw-r--r-- | spec/javascripts/issue_show/components/edit_actions_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/issue_show/components/form_spec.js | 1 | ||||
-rw-r--r-- | spec/models/issue_spec.rb | 29 | ||||
-rw-r--r-- | spec/support/helpers/migrations_helpers.rb | 4 |
8 files changed, 58 insertions, 7 deletions
diff --git a/app/assets/javascripts/issue_show/components/app.vue b/app/assets/javascripts/issue_show/components/app.vue index ad928484952..c6ad3aa3e0d 100644 --- a/app/assets/javascripts/issue_show/components/app.vue +++ b/app/assets/javascripts/issue_show/components/app.vue @@ -293,6 +293,7 @@ :show-delete-button="showDeleteButton" :can-attach-file="canAttachFile" :enable-autocomplete="enableAutocomplete" + :issuable-type="issuableType" /> <recaptcha-modal diff --git a/app/assets/javascripts/issue_show/components/edit_actions.vue b/app/assets/javascripts/issue_show/components/edit_actions.vue index 7fd3ea61aa7..bcf8686afcc 100644 --- a/app/assets/javascripts/issue_show/components/edit_actions.vue +++ b/app/assets/javascripts/issue_show/components/edit_actions.vue @@ -1,7 +1,13 @@ <script> + import { __, sprintf } from '~/locale'; import updateMixin from '../mixins/update'; import eventHub from '../event_hub'; + const issuableTypes = { + issue: __('Issue'), + epic: __('Epic'), + }; + export default { mixins: [updateMixin], props: { @@ -18,6 +24,10 @@ required: false, default: true, }, + issuableType: { + type: String, + required: true, + }, }, data() { return { @@ -37,8 +47,11 @@ eventHub.$emit('close.form'); }, deleteIssuable() { + const confirmMessage = sprintf(__('%{issuableType} will be removed! Are you sure?'), { + issuableType: issuableTypes[this.issuableType], + }); // eslint-disable-next-line no-alert - if (window.confirm('Issue will be removed! Are you sure?')) { + if (window.confirm(confirmMessage)) { this.deleteLoading = true; eventHub.$emit('delete.issuable'); diff --git a/app/assets/javascripts/issue_show/components/form.vue b/app/assets/javascripts/issue_show/components/form.vue index e509bb52f7d..03d8d0ec67c 100644 --- a/app/assets/javascripts/issue_show/components/form.vue +++ b/app/assets/javascripts/issue_show/components/form.vue @@ -27,6 +27,10 @@ required: false, default: () => [], }, + issuableType: { + type: String, + required: true, + }, markdownPreviewPath: { type: String, required: true, @@ -110,6 +114,7 @@ :form-state="formState" :can-destroy="canDestroy" :show-delete-button="showDeleteButton" + :issuable-type="issuableType" /> </form> </template> diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 771d1612676..1b66786a890 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -107,6 +107,9 @@ msgstr "" msgid "%{group_docs_link_start}Groups%{group_docs_link_end} allow you to manage and collaborate across multiple projects. Members of a group have access to all of its projects." msgstr "" +msgid "%{issuableType} will be removed! Are you sure?" +msgstr "" + msgid "%{loadingIcon} Started" msgstr "" @@ -2553,6 +2556,9 @@ msgstr "" msgid "Environments|You don't have any environments right now." msgstr "" +msgid "Epic" +msgstr "" + msgid "Error" msgstr "" @@ -3296,6 +3302,9 @@ msgstr "" msgid "Invite" msgstr "" +msgid "Issue" +msgstr "" + msgid "Issue Boards" msgstr "" diff --git a/spec/javascripts/issue_show/components/edit_actions_spec.js b/spec/javascripts/issue_show/components/edit_actions_spec.js index a3772285527..004621f488a 100644 --- a/spec/javascripts/issue_show/components/edit_actions_spec.js +++ b/spec/javascripts/issue_show/components/edit_actions_spec.js @@ -21,6 +21,7 @@ describe('Edit Actions components', () => { propsData: { canDestroy: true, formState: store.formState, + issuableType: 'issue', }, }).$mount(); diff --git a/spec/javascripts/issue_show/components/form_spec.js b/spec/javascripts/issue_show/components/form_spec.js index 50ce019c32a..eaac1e3536d 100644 --- a/spec/javascripts/issue_show/components/form_spec.js +++ b/spec/javascripts/issue_show/components/form_spec.js @@ -15,6 +15,7 @@ describe('Inline edit form component', () => { description: 'a', lockedWarningVisible: false, }, + issuableType: 'issue', markdownPreviewPath: '/', markdownDocsPath: '/', projectPath: '/', diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index c21d85fb2a4..19bc2713ef5 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -84,15 +84,32 @@ describe Issue do end end - describe '#closed_at' do - it 'sets closed_at to Time.now when issue is closed' do - issue = create(:issue, state: 'opened') + describe '#close' do + subject(:issue) { create(:issue, state: 'opened') } - expect(issue.closed_at).to be_nil + it 'sets closed_at to Time.now when an issue is closed' do + expect { issue.close }.to change { issue.closed_at }.from(nil) + end - issue.close + it 'changes the state to closed' do + expect { issue.close }.to change { issue.state }.from('opened').to('closed') + end + end + + describe '#reopen' do + let(:user) { create(:user) } + let(:issue) { create(:issue, state: 'closed', closed_at: Time.now, closed_by: user) } + + it 'sets closed_at to nil when an issue is reopend' do + expect { issue.reopen }.to change { issue.closed_at }.to(nil) + end + + it 'sets closed_by to nil when an issue is reopend' do + expect { issue.reopen }.to change { issue.closed_by }.from(user).to(nil) + end - expect(issue.closed_at).to be_present + it 'changes the state to opened' do + expect { issue.reopen }.to change { issue.state }.from('closed').to('opened') end end diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb index 0bc235701eb..0c35764ed9a 100644 --- a/spec/support/helpers/migrations_helpers.rb +++ b/spec/support/helpers/migrations_helpers.rb @@ -3,6 +3,10 @@ module MigrationsHelpers Class.new(ActiveRecord::Base) do self.table_name = name self.inheritance_column = :_type_disabled + + def self.name + table_name.singularize.camelcase + end end end |