Commit 8c276580 authored by Mayra Cabrera's avatar Mayra Cabrera

Removes deploy tokens presenter

parent 29913816
...@@ -21,7 +21,7 @@ module Projects ...@@ -21,7 +21,7 @@ module Projects
def render_show def render_show
@deploy_keys = DeployKeysPresenter.new(@project, current_user: current_user) @deploy_keys = DeployKeysPresenter.new(@project, current_user: current_user)
@deploy_tokens = DeployTokensPresenter.new(@project.deploy_tokens.active, current_user: current_user, project: project) @deploy_tokens = @project.deploy_tokens.active
define_deploy_token define_deploy_token
define_protected_refs define_protected_refs
......
module Projects
module Settings
class DeployTokensPresenter < Gitlab::View::Presenter::Simple
include Enumerable
presents :deploy_tokens
def length
deploy_tokens.length
end
def each
deploy_tokens.each do |deploy_token|
yield deploy_token
end
end
end
end
end
...@@ -12,7 +12,7 @@ module DeployTokens ...@@ -12,7 +12,7 @@ module DeployTokens
end end
def expires_at_date def expires_at_date
params[:expires_at].present? ? default_expires_at : params[:expires_at] params[:expires_at].presence || default_expires_at
end end
def default_expires_at def default_expires_at
......
require 'spec_helper'
describe Projects::Settings::DeployTokensPresenter do
let(:user) { create(:user) }
let(:project) { create(:project) }
let!(:project_deploy_tokens) { create_list(:project_deploy_token, 3, project: project) }
let(:deploy_tokens) { project.deploy_tokens }
subject(:presenter) { described_class.new(deploy_tokens, current_user: user, project: project) }
describe '#length' do
it 'returns the size of deploy tokens presented' do
expect(presenter.length).to eq(3)
end
end
end
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