Commit ccf0686b01160e4a61bf8fb4b26f43d1486af9c2
1 parent
d431e433
Exists in
master
and in
4 other branches
Fix api specs. Use id instead path
Showing
8 changed files
with
26 additions
and
40 deletions
Show diff stats
app/controllers/search_controller.rb
| 1 | 1 | class SearchController < ApplicationController |
| 2 | 2 | def show |
| 3 | - result = SearchContext.new(current_user.project_ids, params).execute | |
| 3 | + result = SearchContext.new(current_user.authorized_projects.map(&:id), params).execute | |
| 4 | 4 | |
| 5 | 5 | @projects = result[:projects] |
| 6 | 6 | @merge_requests = result[:merge_requests] | ... | ... |
spec/lib/project_mover_spec.rb
spec/observers/user_observer_spec.rb
| ... | ... | @@ -6,10 +6,7 @@ describe UserObserver do |
| 6 | 6 | it 'calls #after_create when new users are created' do |
| 7 | 7 | new_user = build(:user) |
| 8 | 8 | subject.should_receive(:after_create).with(new_user) |
| 9 | - | |
| 10 | - User.observers.enable :user_observer do | |
| 11 | - new_user.save | |
| 12 | - end | |
| 9 | + new_user.save | |
| 13 | 10 | end |
| 14 | 11 | |
| 15 | 12 | context 'when a new user is created' do | ... | ... |
spec/observers/users_project_observer_spec.rb
| ... | ... | @@ -11,9 +11,7 @@ describe UsersProjectObserver do |
| 11 | 11 | describe "#after_commit" do |
| 12 | 12 | it "should called when UsersProject created" do |
| 13 | 13 | subject.should_receive(:after_commit).once |
| 14 | - UsersProject.observers.enable :users_project_observer do | |
| 15 | - create(:users_project) | |
| 16 | - end | |
| 14 | + create(:users_project) | |
| 17 | 15 | end |
| 18 | 16 | |
| 19 | 17 | it "should send email to user" do |
| ... | ... | @@ -36,9 +34,7 @@ describe UsersProjectObserver do |
| 36 | 34 | describe "#after_update" do |
| 37 | 35 | it "should called when UsersProject updated" do |
| 38 | 36 | subject.should_receive(:after_commit).once |
| 39 | - UsersProject.observers.enable :users_project_observer do | |
| 40 | - create(:users_project).update_attribute(:project_access, UsersProject::MASTER) | |
| 41 | - end | |
| 37 | + create(:users_project).update_attribute(:project_access, UsersProject::MASTER) | |
| 42 | 38 | end |
| 43 | 39 | |
| 44 | 40 | it "should send email to user" do |
| ... | ... | @@ -47,19 +43,14 @@ describe UsersProjectObserver do |
| 47 | 43 | end |
| 48 | 44 | it "should not called after UsersProject destroyed" do |
| 49 | 45 | subject.should_not_receive(:after_commit) |
| 50 | - UsersProject.observers.enable :users_project_observer do | |
| 51 | - users_project.destroy | |
| 52 | - end | |
| 46 | + users_project.destroy | |
| 53 | 47 | end |
| 54 | 48 | end |
| 55 | 49 | |
| 56 | 50 | describe "#after_destroy" do |
| 57 | 51 | it "should called when UsersProject destroyed" do |
| 58 | 52 | subject.should_receive(:after_destroy) |
| 59 | - | |
| 60 | - UsersProject.observers.enable :users_project_observer do | |
| 61 | - create(:users_project).destroy | |
| 62 | - end | |
| 53 | + create(:users_project).destroy | |
| 63 | 54 | end |
| 64 | 55 | |
| 65 | 56 | it "should create new event" do | ... | ... |
spec/requests/api/issues_spec.rb
| ... | ... | @@ -28,7 +28,7 @@ describe Gitlab::API do |
| 28 | 28 | |
| 29 | 29 | describe "GET /projects/:id/issues" do |
| 30 | 30 | it "should return project issues" do |
| 31 | - get api("/projects/#{project.path}/issues", user) | |
| 31 | + get api("/projects/#{project.id}/issues", user) | |
| 32 | 32 | response.status.should == 200 |
| 33 | 33 | json_response.should be_an Array |
| 34 | 34 | json_response.first['title'].should == issue.title |
| ... | ... | @@ -37,7 +37,7 @@ describe Gitlab::API do |
| 37 | 37 | |
| 38 | 38 | describe "GET /projects/:id/issues/:issue_id" do |
| 39 | 39 | it "should return a project issue by id" do |
| 40 | - get api("/projects/#{project.path}/issues/#{issue.id}", user) | |
| 40 | + get api("/projects/#{project.id}/issues/#{issue.id}", user) | |
| 41 | 41 | response.status.should == 200 |
| 42 | 42 | json_response['title'].should == issue.title |
| 43 | 43 | end |
| ... | ... | @@ -45,7 +45,7 @@ describe Gitlab::API do |
| 45 | 45 | |
| 46 | 46 | describe "POST /projects/:id/issues" do |
| 47 | 47 | it "should create a new project issue" do |
| 48 | - post api("/projects/#{project.path}/issues", user), | |
| 48 | + post api("/projects/#{project.id}/issues", user), | |
| 49 | 49 | title: 'new issue', labels: 'label, label2' |
| 50 | 50 | response.status.should == 201 |
| 51 | 51 | json_response['title'].should == 'new issue' |
| ... | ... | @@ -56,7 +56,7 @@ describe Gitlab::API do |
| 56 | 56 | |
| 57 | 57 | describe "PUT /projects/:id/issues/:issue_id" do |
| 58 | 58 | it "should update a project issue" do |
| 59 | - put api("/projects/#{project.path}/issues/#{issue.id}", user), | |
| 59 | + put api("/projects/#{project.id}/issues/#{issue.id}", user), | |
| 60 | 60 | title: 'updated title', labels: 'label2', closed: 1 |
| 61 | 61 | response.status.should == 200 |
| 62 | 62 | json_response['title'].should == 'updated title' |
| ... | ... | @@ -67,7 +67,7 @@ describe Gitlab::API do |
| 67 | 67 | |
| 68 | 68 | describe "DELETE /projects/:id/issues/:issue_id" do |
| 69 | 69 | it "should delete a project issue" do |
| 70 | - delete api("/projects/#{project.path}/issues/#{issue.id}", user) | |
| 70 | + delete api("/projects/#{project.id}/issues/#{issue.id}", user) | |
| 71 | 71 | response.status.should == 405 |
| 72 | 72 | end |
| 73 | 73 | end | ... | ... |
spec/requests/api/merge_requests_spec.rb
| ... | ... | @@ -11,14 +11,14 @@ describe Gitlab::API do |
| 11 | 11 | describe "GET /projects/:id/merge_requests" do |
| 12 | 12 | context "when unauthenticated" do |
| 13 | 13 | it "should return authentication error" do |
| 14 | - get api("/projects/#{project.path}/merge_requests") | |
| 14 | + get api("/projects/#{project.id}/merge_requests") | |
| 15 | 15 | response.status.should == 401 |
| 16 | 16 | end |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | context "when authenticated" do |
| 20 | 20 | it "should return an array of merge_requests" do |
| 21 | - get api("/projects/#{project.path}/merge_requests", user) | |
| 21 | + get api("/projects/#{project.id}/merge_requests", user) | |
| 22 | 22 | response.status.should == 200 |
| 23 | 23 | json_response.should be_an Array |
| 24 | 24 | json_response.first['title'].should == merge_request.title |
| ... | ... | @@ -28,7 +28,7 @@ describe Gitlab::API do |
| 28 | 28 | |
| 29 | 29 | describe "GET /projects/:id/merge_request/:merge_request_id" do |
| 30 | 30 | it "should return merge_request" do |
| 31 | - get api("/projects/#{project.path}/merge_request/#{merge_request.id}", user) | |
| 31 | + get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user) | |
| 32 | 32 | response.status.should == 200 |
| 33 | 33 | json_response['title'].should == merge_request.title |
| 34 | 34 | end |
| ... | ... | @@ -36,7 +36,7 @@ describe Gitlab::API do |
| 36 | 36 | |
| 37 | 37 | describe "POST /projects/:id/merge_requests" do |
| 38 | 38 | it "should return merge_request" do |
| 39 | - post api("/projects/#{project.path}/merge_requests", user), | |
| 39 | + post api("/projects/#{project.id}/merge_requests", user), | |
| 40 | 40 | title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user |
| 41 | 41 | response.status.should == 201 |
| 42 | 42 | json_response['title'].should == 'Test merge_request' |
| ... | ... | @@ -45,7 +45,7 @@ describe Gitlab::API do |
| 45 | 45 | |
| 46 | 46 | describe "PUT /projects/:id/merge_request/:merge_request_id" do |
| 47 | 47 | it "should return merge_request" do |
| 48 | - put api("/projects/#{project.path}/merge_request/#{merge_request.id}", user), title: "New title" | |
| 48 | + put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title" | |
| 49 | 49 | response.status.should == 200 |
| 50 | 50 | json_response['title'].should == 'New title' |
| 51 | 51 | end |
| ... | ... | @@ -53,7 +53,7 @@ describe Gitlab::API do |
| 53 | 53 | |
| 54 | 54 | describe "POST /projects/:id/merge_request/:merge_request_id/comments" do |
| 55 | 55 | it "should return comment" do |
| 56 | - post api("/projects/#{project.path}/merge_request/#{merge_request.id}/comments", user), note: "My comment" | |
| 56 | + post api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user), note: "My comment" | |
| 57 | 57 | response.status.should == 201 |
| 58 | 58 | json_response['note'].should == 'My comment' |
| 59 | 59 | end | ... | ... |
spec/requests/api/milestones_spec.rb
| ... | ... | @@ -11,7 +11,7 @@ describe Gitlab::API do |
| 11 | 11 | |
| 12 | 12 | describe "GET /projects/:id/milestones" do |
| 13 | 13 | it "should return project milestones" do |
| 14 | - get api("/projects/#{project.path}/milestones", user) | |
| 14 | + get api("/projects/#{project.id}/milestones", user) | |
| 15 | 15 | response.status.should == 200 |
| 16 | 16 | json_response.should be_an Array |
| 17 | 17 | json_response.first['title'].should == milestone.title |
| ... | ... | @@ -20,7 +20,7 @@ describe Gitlab::API do |
| 20 | 20 | |
| 21 | 21 | describe "GET /projects/:id/milestones/:milestone_id" do |
| 22 | 22 | it "should return a project milestone by id" do |
| 23 | - get api("/projects/#{project.path}/milestones/#{milestone.id}", user) | |
| 23 | + get api("/projects/#{project.id}/milestones/#{milestone.id}", user) | |
| 24 | 24 | response.status.should == 200 |
| 25 | 25 | json_response['title'].should == milestone.title |
| 26 | 26 | end |
| ... | ... | @@ -28,7 +28,7 @@ describe Gitlab::API do |
| 28 | 28 | |
| 29 | 29 | describe "POST /projects/:id/milestones" do |
| 30 | 30 | it "should create a new project milestone" do |
| 31 | - post api("/projects/#{project.path}/milestones", user), | |
| 31 | + post api("/projects/#{project.id}/milestones", user), | |
| 32 | 32 | title: 'new milestone' |
| 33 | 33 | response.status.should == 201 |
| 34 | 34 | json_response['title'].should == 'new milestone' |
| ... | ... | @@ -38,7 +38,7 @@ describe Gitlab::API do |
| 38 | 38 | |
| 39 | 39 | describe "PUT /projects/:id/milestones/:milestone_id" do |
| 40 | 40 | it "should update a project milestone" do |
| 41 | - put api("/projects/#{project.path}/milestones/#{milestone.id}", user), | |
| 41 | + put api("/projects/#{project.id}/milestones/#{milestone.id}", user), | |
| 42 | 42 | title: 'updated title' |
| 43 | 43 | response.status.should == 200 |
| 44 | 44 | json_response['title'].should == 'updated title' | ... | ... |
spec/spec_helper.rb
| ... | ... | @@ -37,13 +37,10 @@ RSpec.configure do |config| |
| 37 | 37 | config.before do |
| 38 | 38 | stub_gitolite! |
| 39 | 39 | |
| 40 | - # !!! Observers disabled by default in tests | |
| 41 | - #ActiveRecord::Base.observers.disable(:all) | |
| 42 | - # ActiveRecord::Base.observers.enable(:all) | |
| 43 | - | |
| 44 | 40 | # Use tmp dir for FS manipulations |
| 45 | - Gitlab.config.gitolite.stub(repos_path: Rails.root.join('tmp', 'test-git-base-path')) | |
| 46 | - FileUtils.rm_rf Gitlab.config.gitolite.repos_path | |
| 47 | - FileUtils.mkdir_p Gitlab.config.gitolite.repos_path | |
| 41 | + temp_repos_path = Rails.root.join('tmp', 'test-git-base-path') | |
| 42 | + Gitlab.config.gitolite.stub(repos_path: temp_repos_path) | |
| 43 | + FileUtils.rm_rf temp_repos_path | |
| 44 | + FileUtils.mkdir_p temp_repos_path | |
| 48 | 45 | end |
| 49 | 46 | end | ... | ... |