summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2015-03-31 19:03:54 -0700
committerMarin Jankovski <maxlazio@gmail.com>2015-03-31 19:03:54 -0700
commitd77f333f9c7968337241904918d97f67dd5bae82 (patch)
treee8c75a351267111d7528115f2217caaaff138f7d /spec
parent96d093e59aa9c952c4c85908a664a62a1f2057d4 (diff)
parentc14c03a88f6c9a1054cf0e7dc2067d47cae6710a (diff)
downloadgitlab-ce-d77f333f9c7968337241904918d97f67dd5bae82.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Conflicts: lib/gitlab/markdown.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/namespaces_controller_spec.rb121
1 files changed, 121 insertions, 0 deletions
diff --git a/spec/controllers/namespaces_controller_spec.rb b/spec/controllers/namespaces_controller_spec.rb
new file mode 100644
index 00000000000..9c8619722cd
--- /dev/null
+++ b/spec/controllers/namespaces_controller_spec.rb
@@ -0,0 +1,121 @@
+require 'spec_helper'
+
+describe NamespacesController do
+ let!(:user) { create(:user, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
+
+ describe "GET show" do
+ context "when the namespace belongs to a user" do
+ let!(:other_user) { create(:user) }
+
+ it "redirects to the user's page" do
+ get :show, id: other_user.username
+
+ expect(response).to redirect_to(user_path(other_user))
+ end
+ end
+
+ context "when the namespace belongs to a group" do
+ let!(:group) { create(:group) }
+ let!(:project) { create(:project, namespace: group) }
+
+ context "when the group has public projects" do
+ before do
+ project.update_attribute(:visibility_level, Project::PUBLIC)
+ end
+
+ context "when not signed in" do
+ it "redirects to the group's page" do
+ get :show, id: group.path
+
+ expect(response).to redirect_to(group_path(group))
+ end
+ end
+
+ context "when signed in" do
+ before do
+ sign_in(user)
+ end
+
+ it "redirects to the group's page" do
+ get :show, id: group.path
+
+ expect(response).to redirect_to(group_path(group))
+ end
+ end
+ end
+
+ context "when the project doesn't have public projects" do
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get :show, id: group.path
+
+ expect(response).to redirect_to(new_user_session_path)
+ end
+ end
+
+ context "when signed in" do
+ before do
+ sign_in(user)
+ end
+
+ context "when the user has access to the project" do
+ before do
+ project.team << [user, :master]
+ end
+
+ context "when the user is blocked" do
+ before do
+ user.block
+ project.team << [user, :master]
+ end
+
+ it "redirects to the sign in page" do
+ get :show, id: group.path
+
+ expect(response).to redirect_to(new_user_session_path)
+ end
+ end
+
+ context "when the user isn't blocked" do
+ it "redirects to the group's page" do
+ get :show, id: group.path
+
+ expect(response).to redirect_to(group_path(group))
+ end
+ end
+ end
+
+ context "when the user doesn't have access to the project" do
+ it "responds with status 404" do
+ get :show, id: group.path
+
+ expect(response.status).to eq(404)
+ end
+ end
+ end
+ end
+ end
+
+ context "when the namespace doesn't exist" do
+ context "when signed in" do
+ before do
+ sign_in(user)
+ end
+
+ it "responds with status 404" do
+ get :show, id: "doesntexist"
+
+ expect(response.status).to eq(404)
+ end
+ end
+
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get :show, id: "doesntexist"
+
+ expect(response).to redirect_to(new_user_session_path)
+ end
+ end
+ end
+ end
+end