summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-09-25 13:11:31 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-09-25 13:11:31 +0000
commitcb0f024cd4c4aa51c7824e4e1a6c4d0f307afad1 (patch)
tree6d34a738b99169e4dcf620f488b614e90ce68888 /spec
parentb55f8aebab4ceec157ba38d981fe68b4dd688346 (diff)
parent398921b67ca8fefa5045fede67cf9591a0ac361f (diff)
downloadgitlab-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
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/issue_show/components/edit_actions_spec.js1
-rw-r--r--spec/javascripts/issue_show/components/form_spec.js1
-rw-r--r--spec/models/issue_spec.rb29
-rw-r--r--spec/support/helpers/migrations_helpers.rb4
4 files changed, 29 insertions, 6 deletions
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