diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-12 12:15:48 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-12 12:16:55 +0200 |
commit | 7ef156a24292f98d89bc424cc245f00548831863 (patch) | |
tree | 304513ad3f2468fbed91943fac2cdeb2ef594f90 | |
parent | 887494761ee41e8e647753e597fab534ed738058 (diff) | |
download | gitlab-ce-7ef156a24292f98d89bc424cc245f00548831863.tar.gz |
Add author to statuses
-rw-r--r-- | app/models/commit_status.rb | 2 | ||||
-rw-r--r-- | lib/api/commit_statuses.rb | 2 | ||||
-rw-r--r-- | lib/api/entities.rb | 1 | ||||
-rw-r--r-- | spec/models/commit_status_spec.rb | 7 |
4 files changed, 11 insertions, 1 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 4c6de18527b..de7b29a649d 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -9,6 +9,8 @@ class CommitStatus < ActiveRecord::Base validates_presence_of :name + alias_attribute :author, :user + scope :running, ->() { where(status: 'running') } scope :pending, ->() { where(status: 'pending') } scope :success, ->() { where(status: 'success') } diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index 41c05334296..c478b3dc245 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -52,7 +52,7 @@ module API name = params[:name] || params[:context] status = GenericCommitStatus.running_or_pending.find_by(commit: ci_commit, name: name, ref: params[:ref]) - status = GenericCommitStatus.new(commit: ci_commit) unless status + status = GenericCommitStatus.new(commit: ci_commit, user: current_user) unless status status.update(attrs) case params[:state].to_s diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e1c5a459751..bfb242bb6fd 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -232,6 +232,7 @@ module API class CommitStatus < Grape::Entity expose :id, :sha, :ref, :status, :name, :target_url, :description, :created_at, :started_at, :finished_at + expose :author, using: Entities::UserBasic end class Event < Grape::Entity diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index c1af50afb7c..cbefa7798de 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -18,6 +18,13 @@ describe CommitStatus do it { is_expected.to respond_to :running? } it { is_expected.to respond_to :pending? } + describe :author do + subject { commit_status.author } + before { commit_status.author = User.new } + + it { is_expected.to eq(commit_status.user) } + end + describe :started? do subject { commit_status.started? } |