diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-02-21 15:37:00 -0600 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-03-06 09:47:44 -0600 |
commit | a29517dd0c6515121a2f42e08ad011415a3d8618 (patch) | |
tree | 93977c5a003a378749a3de252336500a732771d6 /spec/presenters/projects | |
parent | 336b818bcbcb070968f825f6a426e046a457d556 (diff) | |
download | gitlab-ce-a29517dd0c6515121a2f42e08ad011415a3d8618.tar.gz |
Added tests for the repository_controller and repository_helper
Added specs for the deploy_keys_presenter and added a new method in the presenter
called #key_available?
Fixed some minor UX inconsistencies and added a concern to handle
redirection
Diffstat (limited to 'spec/presenters/projects')
-rw-r--r-- | spec/presenters/projects/settings/deploy_keys_presenter_spec.rb | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb b/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb index 26ed9ac93a0..8faaaf55d72 100644 --- a/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb +++ b/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb @@ -3,6 +3,11 @@ require 'spec_helper' describe Projects::Settings::DeployKeysPresenter do let(:project) { create(:empty_project) } let(:user) { create(:user) } + let(:deploy_key) { create(:deploy_key, public: true) } + + let!(:deploy_keys_project) do + create(:deploy_keys_project, project: project, deploy_key: deploy_key) + end subject(:presenter) do described_class.new(project, current_user: user) @@ -13,16 +18,42 @@ describe Projects::Settings::DeployKeysPresenter do end describe '#enabled_keys' do - let(:deploy_key) do - create(:deploy_keys_project, project: project).deploy_key - end - - it 'returns project keys' do - expect(presenter.enabled_keys).to eq [deploy_key] + it 'returns currently enabled keys' do + expect(presenter.enabled_keys).to eq [deploy_keys_project.deploy_key] end it 'does not contain enabled_keys inside available_keys' do expect(presenter.available_keys).not_to include deploy_key end + + it 'returns the enabled_keys size' do + expect(presenter.enabled_keys_size).to eq(1) + end + + it 'returns true if there is any enabled_keys' do + expect(presenter.any_keys_enabled?).to eq(true) + end + end + + describe '#available_keys/#available_project_keys' do + it 'returns the current available_keys' do + expect(presenter.available_keys).to be_empty + end + + it 'returns the current available_project_keys' do + expect(presenter.available_project_keys).to be_empty + end + + it 'returns if any available_project_keys are enabled' do + expect(presenter.any_available_project_keys_enabled?).to eq(false) + end + + it 'returns the available_project_keys size' do + expect(presenter.available_project_keys_size).to eq(0) + end + + it 'shows if there is an available key' do + expect(presenter.key_available?(deploy_key)).to eq(false) + end end end |