summaryrefslogtreecommitdiff
path: root/spec/models/jira_import_state_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-29 18:08:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-29 18:08:26 +0000
commitb64a8161c9442d82897a341d6bf935dd3e748b06 (patch)
treeb9953db8607d1393aa8ac588a15f184dd8e183f6 /spec/models/jira_import_state_spec.rb
parent6e33325c1458cb31b4d36a7eec817fa00ec3faaf (diff)
downloadgitlab-ce-b64a8161c9442d82897a341d6bf935dd3e748b06.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/jira_import_state_spec.rb')
-rw-r--r--spec/models/jira_import_state_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/models/jira_import_state_spec.rb b/spec/models/jira_import_state_spec.rb
index 493e9d2d78c..d2535636c63 100644
--- a/spec/models/jira_import_state_spec.rb
+++ b/spec/models/jira_import_state_spec.rb
@@ -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