summaryrefslogtreecommitdiff
path: root/spec/models/issue_spec.rb
diff options
context:
space:
mode:
authorJarka Košanová <jarka@gitlab.com>2018-09-24 16:14:11 +0200
committerJarka Košanová <jarka@gitlab.com>2018-09-24 22:50:17 +0200
commit3a7c29417d71502ff4da74fedf84e71fc7c68754 (patch)
tree9bab397cea6fd2eeaa5f8f895bc7c9d7bcdd5f69 /spec/models/issue_spec.rb
parent983bd38f9189a5c7c470f76f7a83044ec7259d21 (diff)
downloadgitlab-ce-3a7c29417d71502ff4da74fedf84e71fc7c68754.tar.gz
Add specs for closing and reopening issue
Diffstat (limited to 'spec/models/issue_spec.rb')
-rw-r--r--spec/models/issue_spec.rb29
1 files changed, 23 insertions, 6 deletions
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