summaryrefslogtreecommitdiff
path: root/spec/serializers/build_entity_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/serializers/build_entity_spec.rb')
-rw-r--r--spec/serializers/build_entity_spec.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/serializers/build_entity_spec.rb b/spec/serializers/build_entity_spec.rb
index 7dcdf54fd93..b5eb84ae43b 100644
--- a/spec/serializers/build_entity_spec.rb
+++ b/spec/serializers/build_entity_spec.rb
@@ -6,7 +6,7 @@ describe BuildEntity do
let(:request) { double('request') }
before do
- allow(request).to receive(:user).and_return(user)
+ allow(request).to receive(:current_user).and_return(user)
end
let(:entity) do
@@ -24,6 +24,10 @@ describe BuildEntity do
expect(subject).not_to include(/variables/)
end
+ it 'contains whether it is playable' do
+ expect(subject[:playable]).to eq build.playable?
+ end
+
it 'contains timestamps' do
expect(subject).to include(:created_at, :updated_at)
end
@@ -37,13 +41,37 @@ describe BuildEntity do
it 'does not contain path to play action' do
expect(subject).not_to include(:play_path)
end
+
+ it 'is not a playable job' do
+ expect(subject[:playable]).to be false
+ end
end
context 'when build is a manual action' do
let(:build) { create(:ci_build, :manual) }
- it 'contains path to play action' do
- expect(subject).to include(:play_path)
+ context 'when user is allowed to trigger action' do
+ before do
+ build.project.add_master(user)
+ end
+
+ it 'contains path to play action' do
+ expect(subject).to include(:play_path)
+ end
+
+ it 'is a playable action' do
+ expect(subject[:playable]).to be true
+ end
+ end
+
+ context 'when user is not allowed to trigger action' do
+ it 'does not contain path to play action' do
+ expect(subject).not_to include(:play_path)
+ end
+
+ it 'is not a playable action' do
+ expect(subject[:playable]).to be false
+ end
end
end
end