summaryrefslogtreecommitdiff
path: root/spec/helpers/preferences_helper_spec.rb
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-11-24 11:32:59 +0000
committerPhil Hughes <me@iamphill.com>2016-11-24 11:32:59 +0000
commit8c4f4afd6dd6d382aab2d6b992b6ffe3e60f91af (patch)
tree37d3ff76dc31e7fcfa63eb8c2f54c9d84eb9b88a /spec/helpers/preferences_helper_spec.rb
parent03a235783f697572fe201332cb82746401a01daf (diff)
parent3e44ed3e2bf75bb14a2d8b0466b3d92afd0ea067 (diff)
downloadgitlab-ce-autocomplete-space-prefix.tar.gz
Merge branch 'master' into autocomplete-space-prefixautocomplete-space-prefix
Diffstat (limited to 'spec/helpers/preferences_helper_spec.rb')
-rw-r--r--spec/helpers/preferences_helper_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb
index 2f9291afc3f..77841e85223 100644
--- a/spec/helpers/preferences_helper_spec.rb
+++ b/spec/helpers/preferences_helper_spec.rb
@@ -85,4 +85,45 @@ describe PreferencesHelper do
and_return(double('user', messages))
end
end
+
+ describe '#default_project_view' do
+ context 'user not signed in' do
+ before do
+ helper.instance_variable_set(:@project, project)
+ stub_user
+ end
+
+ context 'when repository is empty' do
+ let(:project) { create(:project_empty_repo, :public) }
+
+ it 'returns activity if user has repository access' do
+ allow(helper).to receive(:can?).with(nil, :download_code, project).and_return(true)
+
+ expect(helper.default_project_view).to eq('activity')
+ end
+
+ it 'returns activity if user does not have repository access' do
+ allow(helper).to receive(:can?).with(nil, :download_code, project).and_return(false)
+
+ expect(helper.default_project_view).to eq('activity')
+ end
+ end
+
+ context 'when repository is not empty' do
+ let(:project) { create(:project, :public) }
+
+ it 'returns readme if user has repository access' do
+ allow(helper).to receive(:can?).with(nil, :download_code, project).and_return(true)
+
+ expect(helper.default_project_view).to eq('readme')
+ end
+
+ it 'returns activity if user does not have repository access' do
+ allow(helper).to receive(:can?).with(nil, :download_code, project).and_return(false)
+
+ expect(helper.default_project_view).to eq('activity')
+ end
+ end
+ end
+ end
end