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

Fix more specs

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