Commit 19aa20d5 authored by Douwe Maan's avatar Douwe Maan

Fix more specs

parent 7c51d5ef
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
%li %li
%span.light fs: %span.light fs:
%strong %strong
= @repository.path_to_repo = @project.repository.path_to_repo
%li %li
%span.light Size %span.light Size
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160316204731) do ActiveRecord::Schema.define(version: 20160320204112) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
......
...@@ -2,9 +2,10 @@ require 'spec_helper' ...@@ -2,9 +2,10 @@ require 'spec_helper'
describe Groups::AvatarsController do describe Groups::AvatarsController do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group, owner: user, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let(:group) { create(:group, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
before do before do
group.add_owner(user)
sign_in(user) sign_in(user)
end end
......
...@@ -18,10 +18,6 @@ describe NamespacesController do ...@@ -18,10 +18,6 @@ describe NamespacesController do
let!(:group) { create(:group) } let!(:group) { create(:group) }
context "when the group is public" do context "when the group is public" do
before do
group.update_attribute(:visibility_level, Group::PUBLIC)
end
context "when not signed in" do context "when not signed in" do
it "redirects to the group's page" do it "redirects to the group's page" do
get :show, id: group.path get :show, id: group.path
...@@ -44,10 +40,14 @@ describe NamespacesController do ...@@ -44,10 +40,14 @@ describe NamespacesController do
end end
context "when the group is private" do context "when the group is private" do
before do
group.update_attribute(:visibility_level, Group::PRIVATE)
end
context "when not signed in" do context "when not signed in" do
it "does not redirect to the sign in page" do it "redirects to the sign in page" do
get :show, id: group.path get :show, id: group.path
expect(response).not_to redirect_to(new_user_session_path) expect(response).to redirect_to(new_user_session_path)
end end
end end
......
...@@ -129,10 +129,6 @@ describe UploadsController do ...@@ -129,10 +129,6 @@ describe UploadsController do
let!(:group) { create(:group, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) } let!(:group) { create(:group, avatar: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")) }
context "when the group is public" do context "when the group is public" do
before do
group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC)
end
context "when not signed in" do context "when not signed in" do
it "responds with status 200" do it "responds with status 200" do
get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png"
...@@ -155,6 +151,10 @@ describe UploadsController do ...@@ -155,6 +151,10 @@ describe UploadsController do
end end
context "when the group is private" do context "when the group is private" do
before do
group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
end
context "when signed in" do context "when signed in" do
before do before do
sign_in(user) sign_in(user)
...@@ -162,7 +162,7 @@ describe UploadsController do ...@@ -162,7 +162,7 @@ describe UploadsController do
context "when the user has access to the project" do context "when the user has access to the project" do
before do before do
project.add_developer(user) group.add_developer(user)
end end
context "when the user is blocked" do context "when the user is blocked" do
......
...@@ -59,18 +59,17 @@ describe Group, models: true do ...@@ -59,18 +59,17 @@ describe Group, models: true do
describe 'scopes' do describe 'scopes' do
let!(:private_group) { create(:group, :private) } let!(:private_group) { create(:group, :private) }
let!(:internal_group) { create(:group, :internal) } let!(:internal_group) { create(:group, :internal) }
let!(:public_group) { create(:group, :public) }
describe 'public_only' do describe 'public_only' do
subject { described_class.public_only.to_a } subject { described_class.public_only.to_a }
it{ is_expected.to eq([public_group]) } it{ is_expected.to eq([group]) }
end end
describe 'public_and_internal_only' do describe 'public_and_internal_only' do
subject { described_class.public_and_internal_only.to_a } subject { described_class.public_and_internal_only.to_a }
it{ is_expected.to eq([public_group, internal_group]) } it{ is_expected.to eq([group, internal_group]) }
end end
end end
......
...@@ -23,7 +23,7 @@ describe CreateSnippetService, services: true do ...@@ -23,7 +23,7 @@ describe CreateSnippetService, services: true do
snippet = create_snippet(nil, @user, @opts) snippet = create_snippet(nil, @user, @opts)
expect(snippet.errors.messages).to have_key(:visibility_level) expect(snippet.errors.messages).to have_key(:visibility_level)
expect(snippet.errors.messages[:visibility_level].first).to( expect(snippet.errors.messages[:visibility_level].first).to(
match('Public visibility has been restricted') match('has been restricted')
) )
end end
......
...@@ -6,9 +6,8 @@ describe Groups::UpdateService, services: true do ...@@ -6,9 +6,8 @@ describe Groups::UpdateService, services: true do
let!(:internal_group) { create(:group, :internal) } let!(:internal_group) { create(:group, :internal) }
let!(:public_group) { create(:group, :public) } let!(:public_group) { create(:group, :public) }
describe "execute" do describe "#execute" do
context "project visibility_level validation" do context "project visibility_level validation" do
context "public group with public projects" do context "public group with public projects" do
let!(:service) { described_class.new(public_group, user, visibility_level: Gitlab::VisibilityLevel::INTERNAL ) } let!(:service) { described_class.new(public_group, user, visibility_level: Gitlab::VisibilityLevel::INTERNAL ) }
...@@ -18,33 +17,32 @@ describe Groups::UpdateService, services: true do ...@@ -18,33 +17,32 @@ describe Groups::UpdateService, services: true do
end end
it "cant downgrade permission level" do it "cant downgrade permission level" do
expect(service.execute).to be_falsy
expect(public_group.errors.count).to eq(2) expect(public_group.errors.count).to eq(2)
end end
end end
context "internal group with internal project" do context "internal group with internal project" do
let!(:service) { described_class.new(internal_group, user, visibility_level: Gitlab::VisibilityLevel::PRIVATE ) } let!(:service) { described_class.new(internal_group, user, visibility_level: Gitlab::VisibilityLevel::PRIVATE ) }
before do before do
internal_group.add_user(user, Gitlab::Access::MASTER) internal_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :internal, group: internal_group) create(:project, :internal, group: internal_group)
end end
it "cant downgrade permission level" do it "cant downgrade permission level" do
expect(service.execute).to be_falsy expect(internal_group.errors.count).to eq(2)
expect(internal_group.errors.count).to eq(2)
end
end end
end
end end
end end
context "unauthorized visibility_level validation" do context "unauthorized visibility_level validation" do
let!(:service) { described_class.new(internal_group, user, visibility_level: 99 ) } let!(:service) { described_class.new(internal_group, user, visibility_level: 99 ) }
before { internal_group.add_user(user, Gitlab::Access::MASTER) } before do
internal_group.add_user(user, Gitlab::Access::MASTER)
end
it "does not change permission level" do it "does not change permission level" do
expect(service.execute).to be_falsy
expect(internal_group.errors.count).to eq(1) expect(internal_group.errors.count).to eq(1)
end end
end end
......
...@@ -25,7 +25,7 @@ describe UpdateSnippetService, services: true do ...@@ -25,7 +25,7 @@ describe UpdateSnippetService, services: true do
update_snippet(@project, @user, @snippet, @opts) update_snippet(@project, @user, @snippet, @opts)
expect(@snippet.errors.messages).to have_key(:visibility_level) expect(@snippet.errors.messages).to have_key(:visibility_level)
expect(@snippet.errors.messages[:visibility_level].first).to( expect(@snippet.errors.messages[:visibility_level].first).to(
match('Public visibility has been restricted') match('has been restricted')
) )
expect(@snippet.visibility_level).to eq(old_visibility) expect(@snippet.visibility_level).to eq(old_visibility)
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