summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-15 22:40:35 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-15 22:40:35 +0200
commite21deaee8ee0d453bf899c1b3fb46262cc60dab9 (patch)
tree59b04c9cb1c8ce6c510a78ee787fb31817619835 /spec
parent7e2dbcbe0915cfd75e91d78e943c153f284df37d (diff)
parent0ad669bb5ba08d012d3daa50b51a3a6b069e3e83 (diff)
downloadgitlab-ce-e21deaee8ee0d453bf899c1b3fb46262cc60dab9.tar.gz
Merge remote-tracking branch 'origin/master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g
# Conflicts: # Gemfile.lock
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/namespaces_controller_spec.rb10
-rw-r--r--spec/controllers/root_controller_spec.rb8
-rw-r--r--spec/controllers/uploads_controller_spec.rb8
-rw-r--r--spec/features/atom/dashboard_spec.rb4
-rw-r--r--spec/features/profiles/preferences_spec.rb2
-rw-r--r--spec/features/security/dashboard_access_spec.rb4
-rw-r--r--spec/features/security/group_access_spec.rb6
-rw-r--r--spec/routing/routing_spec.rb6
-rw-r--r--spec/services/projects/create_service_spec.rb11
-rw-r--r--spec/services/projects/fork_service_spec.rb5
-rw-r--r--spec/workers/repository_fork_worker_spec.rb29
11 files changed, 61 insertions, 32 deletions
diff --git a/spec/controllers/namespaces_controller_spec.rb b/spec/controllers/namespaces_controller_spec.rb
index 9c8619722cd..77436958711 100644
--- a/spec/controllers/namespaces_controller_spec.rb
+++ b/spec/controllers/namespaces_controller_spec.rb
@@ -46,13 +46,11 @@ describe NamespacesController do
context "when the project doesn't have public projects" do
context "when not signed in" do
- it "redirects to the sign in page" do
+ it "does not redirect to the sign in page" do
get :show, id: group.path
-
- expect(response).to redirect_to(new_user_session_path)
+ expect(response).not_to redirect_to(new_user_session_path)
end
end
-
context "when signed in" do
before do
sign_in(user)
@@ -86,10 +84,10 @@ describe NamespacesController do
end
context "when the user doesn't have access to the project" do
- it "responds with status 404" do
+ it "redirects to the group's page" do
get :show, id: group.path
- expect(response.status).to eq(404)
+ expect(response).to redirect_to(group_path(group))
end
end
end
diff --git a/spec/controllers/root_controller_spec.rb b/spec/controllers/root_controller_spec.rb
index abbbf6855fc..64dfe8f34e3 100644
--- a/spec/controllers/root_controller_spec.rb
+++ b/spec/controllers/root_controller_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe RootController do
- describe 'GET show' do
+ describe 'GET index' do
context 'with a user' do
let(:user) { create(:user) }
@@ -16,15 +16,15 @@ describe RootController do
end
it 'redirects to their specified dashboard' do
- get :show
+ get :index
expect(response).to redirect_to starred_dashboard_projects_path
end
end
context 'who uses the default dashboard setting' do
it 'renders the default dashboard' do
- get :show
- expect(response).to render_template 'dashboard/show'
+ get :index
+ expect(response).to render_template 'dashboard/projects/index'
end
end
end
diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb
index 0f9780356b1..af5d043cf02 100644
--- a/spec/controllers/uploads_controller_spec.rb
+++ b/spec/controllers/uploads_controller_spec.rb
@@ -156,14 +156,6 @@ describe UploadsController do
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, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png"
-
- expect(response).to redirect_to(new_user_session_path)
- end
- end
-
context "when signed in" do
before do
sign_in(user)
diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb
index ad157d742ff..f81a3c117ff 100644
--- a/spec/features/atom/dashboard_spec.rb
+++ b/spec/features/atom/dashboard_spec.rb
@@ -6,7 +6,7 @@ describe "Dashboard Feed", feature: true do
context "projects atom feed via private token" do
it "should render projects atom feed" do
- visit dashboard_path(:atom, private_token: user.private_token)
+ visit dashboard_projects_path(:atom, private_token: user.private_token)
expect(body).to have_selector('feed title')
end
end
@@ -20,7 +20,7 @@ describe "Dashboard Feed", feature: true do
project.team << [user, :master]
issue_event(issue, user)
note_event(note, user)
- visit dashboard_path(:atom, private_token: user.private_token)
+ visit dashboard_projects_path(:atom, private_token: user.private_token)
end
it "should have issue opened event" do
diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/preferences_spec.rb
index 9bc6145dda4..8f645438cff 100644
--- a/spec/features/profiles/preferences_spec.rb
+++ b/spec/features/profiles/preferences_spec.rb
@@ -70,7 +70,7 @@ describe 'Profile > Preferences', feature: true do
expect(page.current_path).to eq starred_dashboard_projects_path
click_link 'Your Projects'
- expect(page.current_path).to eq dashboard_path
+ expect(page.current_path).to eq dashboard_projects_path
end
end
diff --git a/spec/features/security/dashboard_access_spec.rb b/spec/features/security/dashboard_access_spec.rb
index c38cddbb904..788581a26cb 100644
--- a/spec/features/security/dashboard_access_spec.rb
+++ b/spec/features/security/dashboard_access_spec.rb
@@ -4,7 +4,7 @@ describe "Dashboard access", feature: true do
include AccessMatchers
describe "GET /dashboard" do
- subject { dashboard_path }
+ subject { dashboard_projects_path }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
@@ -40,7 +40,7 @@ describe "Dashboard access", feature: true do
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
- it { is_expected.to be_denied_for :visitor }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /projects/new" do
diff --git a/spec/features/security/group_access_spec.rb b/spec/features/security/group_access_spec.rb
index 8ce15388605..4b78e3a61f0 100644
--- a/spec/features/security/group_access_spec.rb
+++ b/spec/features/security/group_access_spec.rb
@@ -68,7 +68,7 @@ describe 'Group access', feature: true do
it { is_expected.to be_allowed_for group_member(:guest) }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
- it { is_expected.to be_denied_for :visitor }
+ it { is_expected.to be_allowed_for :visitor }
end
context 'with no projects' do
@@ -77,8 +77,8 @@ describe 'Group access', feature: true do
it { is_expected.to be_allowed_for group_member(:reporter) }
it { is_expected.to be_allowed_for group_member(:guest) }
it { is_expected.to be_allowed_for :admin }
- it { is_expected.to be_denied_for :user }
- it { is_expected.to be_denied_for :visitor }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
end
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb
index dd045826692..dfa18f69e05 100644
--- a/spec/routing/routing_spec.rb
+++ b/spec/routing/routing_spec.rb
@@ -206,7 +206,7 @@ end
# dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests
describe DashboardController, "routing" do
it "to #index" do
- expect(get("/dashboard")).to route_to('dashboard#show')
+ expect(get("/dashboard")).to route_to('dashboard/projects#index')
end
it "to #issues" do
@@ -220,8 +220,8 @@ end
# root / root#show
describe RootController, 'routing' do
- it 'to #show' do
- expect(get('/')).to route_to('root#show')
+ it 'to #index' do
+ expect(get('/')).to route_to('root#index')
end
end
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index ff4ed2dd484..25277f07482 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -96,6 +96,17 @@ describe Projects::CreateService do
expect(project.saved?).to be(true)
end
end
+
+ context 'repository creation' do
+ it 'should synchronously create the repository' do
+ expect_any_instance_of(Project).to receive(:create_repository)
+
+ project = create_project(@user, @opts)
+ expect(project).to be_valid
+ expect(project.owner).to eq(@user)
+ expect(project.namespace).to eq(@user.namespace)
+ end
+ end
end
def create_project(user, opts)
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index c04e842c67e..7c4bb74b77f 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -28,8 +28,7 @@ describe Projects::ForkService do
context 'fork project failure' do
it "fails due to transaction failure" do
@to_project = fork_project(@from_project, @to_user, false)
- expect(@to_project.errors).not_to be_empty
- expect(@to_project.errors[:base]).to include("Failed to fork repository via gitlab-shell")
+ expect(@to_project.import_failed?)
end
end
@@ -100,7 +99,7 @@ describe Projects::ForkService do
end
def fork_project(from_project, user, fork_success = true, params = {})
- allow_any_instance_of(Gitlab::Shell).to receive(:fork_repository).and_return(fork_success)
+ allow(RepositoryForkWorker).to receive(:perform_async).and_return(fork_success)
Projects::ForkService.new(from_project, user, params).execute
end
end
diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb
new file mode 100644
index 00000000000..aa031106968
--- /dev/null
+++ b/spec/workers/repository_fork_worker_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+describe RepositoryForkWorker do
+ let(:project) { create(:project) }
+ let(:fork_project) { create(:project, forked_from_project: project) }
+
+ subject { RepositoryForkWorker.new }
+
+ describe "#perform" do
+ it "creates a new repository from a fork" do
+ expect_any_instance_of(Gitlab::Shell).to receive(:fork_repository).with(
+ project.path_with_namespace,
+ fork_project.namespace.path).
+ and_return(true)
+ expect(ProjectCacheWorker).to receive(:perform_async)
+
+ subject.perform(project.id,
+ project.path_with_namespace,
+ fork_project.namespace.path)
+ end
+
+ it "handles bad fork" do
+ expect_any_instance_of(Gitlab::Shell).to receive(:fork_repository).and_return(false)
+ subject.perform(project.id,
+ project.path_with_namespace,
+ fork_project.namespace.path)
+ end
+ end
+end