diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-01 11:45:26 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-01 11:45:26 +0100 |
commit | 57b1976976c2631299e20465e5633652d2753a6f (patch) | |
tree | 81ac15483247964a86e928df155a22bd5fbaaa55 /spec/serializers | |
parent | 6eb3728490cbf33ea3e401653a5da0ab290c6f52 (diff) | |
parent | 7c66ea94ea563a0cd75819b00d7e544d32dee634 (diff) | |
download | gitlab-ce-57b1976976c2631299e20465e5633652d2753a6f.tar.gz |
Merge branch 'master' into auto-pipelines-vue
* master: (73 commits)
Refactor JiraService by moving code out of JiraService#execute method
Rename a label to fix an intermittently-failing spec
Refactor the Git submodules with CI docs
Add CHANGELOG entry
Improve Gitlab::GitAccessWiki spec with download access checks
Improve ProjectPolicy spec to check permissions when wiki is disabled
Allow access to the wiki with git when repository feature disabled
Refactor branch chooser in issuable form
Improve the `Gitlab::OAuth::User` error message
Disable the ee_compat_check task on dev
Make the downtime_check task happy
Revert bump in rufus-scheduler
Fix comma-dangle in function's arguments errors
Improvements after review
Use created date from last_deployment
API: Expose branch status
Grapify the files API
Move task helpers to a module
Fixed GFM autocomplete regex
Add Human Readable Timestamp to backup tar file
...
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/analytics_build_entity_spec.rb | 53 | ||||
-rw-r--r-- | spec/serializers/build_entity_spec.rb | 25 |
2 files changed, 68 insertions, 10 deletions
diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb index c0b7e86b17c..6b33fe66a63 100644 --- a/spec/serializers/analytics_build_entity_spec.rb +++ b/spec/serializers/analytics_build_entity_spec.rb @@ -7,7 +7,9 @@ describe AnalyticsBuildEntity do context 'build with an author' do let(:user) { create(:user) } - let(:build) { create(:ci_build, author: user, started_at: 2.hours.ago, finished_at: 1.hour.ago) } + let(:started_at) { 2.hours.ago } + let(:finished_at) { 1.hour.ago } + let(:build) { create(:ci_build, author: user, started_at: started_at, finished_at: finished_at) } subject { entity.as_json } @@ -31,5 +33,54 @@ describe AnalyticsBuildEntity do it 'contains the duration' do expect(subject[:total_time]).to eq(hours: 1 ) end + + context 'no started at or finished at date' do + let(:started_at) { nil } + let(:finished_at) { nil } + + it 'does not blow up' do + expect{ subject[:date] }.not_to raise_error + end + + it 'shows the right message' do + expect(subject[:date]).to eq('Not started') + end + + it 'shows the right total time' do + expect(subject[:total_time]).to eq({}) + end + end + + context 'no started at date' do + let(:started_at) { nil } + + it 'does not blow up' do + expect{ subject[:date] }.not_to raise_error + end + + it 'shows the right message' do + expect(subject[:date]).to eq('Not started') + end + + it 'shows the right total time' do + expect(subject[:total_time]).to eq({}) + end + end + + context 'no finished at date' do + let(:finished_at) { nil } + + it 'does not blow up' do + expect{ subject[:date] }.not_to raise_error + end + + it 'shows the right message' do + expect(subject[:date]).to eq('about 2 hours ago') + end + + it 'shows the right total time' do + expect(subject[:total_time]).to eq({ hours: 2 }) + end + end end end diff --git a/spec/serializers/build_entity_spec.rb b/spec/serializers/build_entity_spec.rb index 6dcfaec259e..60c9642ee2c 100644 --- a/spec/serializers/build_entity_spec.rb +++ b/spec/serializers/build_entity_spec.rb @@ -1,23 +1,30 @@ require 'spec_helper' describe BuildEntity do + let(:build) { create(:ci_build) } + let(:entity) do described_class.new(build, request: double) end subject { entity.as_json } - context 'when build is a regular job' do - let(:build) { create(:ci_build) } + it 'contains paths to build page and retry action' do + expect(subject).to include(:build_path, :retry_path) + end - it 'contains paths to build page and retry action' do - expect(subject).to include(:build_path, :retry_path) - expect(subject).not_to include(:play_path) - end + it 'does not contain sensitive information' do + expect(subject).not_to include(/token/) + expect(subject).not_to include(/variables/) + end + + it 'contains timestamps' do + expect(subject).to include(:created_at, :updated_at) + end - it 'does not contain sensitive information' do - expect(subject).not_to include(/token/) - expect(subject).not_to include(/variables/) + context 'when build is a regular job' do + it 'does not contain path to play action' do + expect(subject).not_to include(:play_path) end end |