Commit 7ef156a2 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Add author to statuses

parent 88749476
...@@ -9,6 +9,8 @@ class CommitStatus < ActiveRecord::Base ...@@ -9,6 +9,8 @@ class CommitStatus < ActiveRecord::Base
validates_presence_of :name validates_presence_of :name
alias_attribute :author, :user
scope :running, ->() { where(status: 'running') } scope :running, ->() { where(status: 'running') }
scope :pending, ->() { where(status: 'pending') } scope :pending, ->() { where(status: 'pending') }
scope :success, ->() { where(status: 'success') } scope :success, ->() { where(status: 'success') }
......
...@@ -52,7 +52,7 @@ module API ...@@ -52,7 +52,7 @@ module API
name = params[:name] || params[:context] name = params[:name] || params[:context]
status = GenericCommitStatus.running_or_pending.find_by(commit: ci_commit, name: name, ref: params[:ref]) 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) status.update(attrs)
case params[:state].to_s case params[:state].to_s
......
...@@ -232,6 +232,7 @@ module API ...@@ -232,6 +232,7 @@ module API
class CommitStatus < Grape::Entity class CommitStatus < Grape::Entity
expose :id, :sha, :ref, :status, :name, :target_url, :description, expose :id, :sha, :ref, :status, :name, :target_url, :description,
:created_at, :started_at, :finished_at :created_at, :started_at, :finished_at
expose :author, using: Entities::UserBasic
end end
class Event < Grape::Entity class Event < Grape::Entity
......
...@@ -18,6 +18,13 @@ describe CommitStatus do ...@@ -18,6 +18,13 @@ describe CommitStatus do
it { is_expected.to respond_to :running? } it { is_expected.to respond_to :running? }
it { is_expected.to respond_to :pending? } 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 describe :started? do
subject { commit_status.started? } subject { commit_status.started? }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment