diff options
| author | Douwe Maan <douwe@selenight.nl> | 2016-03-20 21:03:53 +0100 |
|---|---|---|
| committer | Douwe Maan <douwe@selenight.nl> | 2016-03-20 21:04:07 +0100 |
| commit | 8db1292139cfdac4c29c03b876b68b9e752cf75a (patch) | |
| tree | 2fcf67ada482ecf4ac90f39c858334a62b709618 /spec/controllers | |
| parent | 2eb19ea3ea36916bbea72a8ccab3e6d15f602ac9 (diff) | |
| download | gitlab-ce-8db1292139cfdac4c29c03b876b68b9e752cf75a.tar.gz | |
Tweaks, refactoring, and specs
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/groups_controller_spec.rb | 39 | ||||
| -rw-r--r-- | spec/controllers/namespaces_controller_spec.rb | 21 | ||||
| -rw-r--r-- | spec/controllers/uploads_controller_spec.rb | 9 |
3 files changed, 13 insertions, 56 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 91db3fd1ee2..938e97298b6 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -20,43 +20,4 @@ describe GroupsController do end end end - - describe 'GET show' do - let(:group) { create(:group, visibility_level: 20) } - - it 'checks if group can be read' do - expect(controller).to receive(:authorize_read_group!) - get :show, id: group.path - end - end - - describe 'POST create' do - before { sign_in(create(:user)) } - - it 'checks if group can be created' do - expect(controller).to receive(:authorize_create_group!) - post :create, { group: { name: "any params" } } - end - end - - describe 'DELETE destroy' do - before { sign_in(create(:user)) } - let(:group) { create(:group, visibility_level: 20) } - - it 'checks if group can be deleted' do - expect(controller).to receive(:authorize_admin_group!) - delete :destroy, id: group.path - end - end - - describe 'PUT update' do - before { sign_in(create(:user)) } - let(:group) { create(:group, visibility_level: 20) } - - it 'checks if group can be updated' do - expect_any_instance_of(Groups::UpdateService).to receive(:execute) - expect(controller).to receive(:authorize_admin_group!) - put :update, id: group.path, group: { name: 'test' } - end - end end diff --git a/spec/controllers/namespaces_controller_spec.rb b/spec/controllers/namespaces_controller_spec.rb index 6350c9c6e48..41ae6063ae0 100644 --- a/spec/controllers/namespaces_controller_spec.rb +++ b/spec/controllers/namespaces_controller_spec.rb @@ -15,12 +15,11 @@ describe NamespacesController do end context "when the namespace belongs to a group" do - let!(:group) { create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let!(:project) { create(:project, namespace: group) } + let!(:group) { create(:group) } - context "when the group has public projects" do + context "when the group is public" do before do - project.update_attribute(:visibility_level, Project::PUBLIC) + group.update_attribute(:visibility_level, Group::PUBLIC) end context "when not signed in" do @@ -44,27 +43,27 @@ describe NamespacesController do end end - context "when the project doesn't have public projects" do + context "when the group is private" do context "when not signed in" do it "does not redirect to the sign in page" do get :show, id: group.path expect(response).not_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 + context "when the user has access to the group" do before do - project.team << [user, :master] + group.add_developer(user) 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 @@ -83,11 +82,11 @@ describe NamespacesController do end end - context "when the user doesn't have access to the project" do - it "redirects to the group's page" do + context "when the user doesn't have access to the group" do + it "responds with status 404" do get :show, id: group.path - expect(response).to redirect_to(group_path(group)) + expect(response.status).to eq(404) end end end diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index bf5b13f2645..0947744fc47 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -127,12 +127,10 @@ describe UploadsController do context "when viewing a group avatar" do let!(:group) { create(:group, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } - let!(:project) { create(:project, namespace: group) } - context "when the group has public projects" do + context "when the group is public" do before do group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC) - project.update_attribute(:visibility_level, Project::PUBLIC) end context "when not signed in" do @@ -156,7 +154,7 @@ describe UploadsController do end end - context "when the project doesn't have public projects" do + context "when the group is private" do context "when signed in" do before do sign_in(user) @@ -164,13 +162,12 @@ describe UploadsController do context "when the user has access to the project" do before do - project.team << [user, :master] + project.add_developer(user) 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 |
