diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/models/jira_import_state_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/models/jira_import_state_spec.rb')
-rw-r--r-- | spec/models/jira_import_state_spec.rb | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/spec/models/jira_import_state_spec.rb b/spec/models/jira_import_state_spec.rb index 99f9e035205..d2535636c63 100644 --- a/spec/models/jira_import_state_spec.rb +++ b/spec/models/jira_import_state_spec.rb @@ -124,7 +124,7 @@ describe JiraImportState do jira_import.schedule expect(jira_import.jid).to eq('some-job-id') - expect(jira_import.scheduled_at).to be_within(1.second).of(Time.now) + expect(jira_import.scheduled_at).to be_within(1.second).of(Time.current) end end @@ -163,4 +163,39 @@ describe JiraImportState do end end end + + context 'ensure error_message size on save' do + let_it_be(:project) { create(:project) } + + before do + stub_const('JiraImportState::ERROR_MESSAGE_SIZE', 10) + end + + context 'when jira import has no error_message' do + let(:jira_import) { build(:jira_import_state, project: project)} + + it 'does not run the callback', :aggregate_failures do + expect { jira_import.save }.to change { JiraImportState.count }.by(1) + expect(jira_import.reload.error_message).to be_nil + end + end + + context 'when jira import error_message does not exceed the limit' do + let(:jira_import) { build(:jira_import_state, project: project, error_message: 'error')} + + it 'does not run the callback', :aggregate_failures do + expect { jira_import.save }.to change { JiraImportState.count }.by(1) + expect(jira_import.reload.error_message).to eq('error') + end + end + + context 'when error_message exceeds limit' do + let(:jira_import) { build(:jira_import_state, project: project, error_message: 'error message longer than the limit')} + + it 'truncates error_message to the limit', :aggregate_failures do + expect { jira_import.save! }.to change { JiraImportState.count }.by(1) + expect(jira_import.reload.error_message.size).to eq 10 + end + end + end end |