diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-07 06:59:03 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-05-07 06:59:03 -0700 |
commit | af5d0e9e92f3fb818c73f1b8b991ea61ddc35dd4 (patch) | |
tree | 2695e4d262df1fdfc213a2c73fbee76f0b5e05be /spec | |
parent | dc41ffa309fee7697693cfaea42486707d98f5f0 (diff) | |
parent | a50d96a84149c34c85f9f02cacfd2d15582c8eff (diff) | |
download | gitlab-ce-af5d0e9e92f3fb818c73f1b8b991ea61ddc35dd4.tar.gz |
Merge pull request #3275 from Undev/feature/code_cleanup_remove_old_hashes
Code cleanup: Replace old hashes and remove trailing spaces
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/merge_request_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/milestone_spec.rb | 2 | ||||
-rw-r--r-- | spec/observers/users_project_observer_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/groups_spec.rb | 26 | ||||
-rw-r--r-- | spec/requests/api/system_hooks_spec.rb | 162 | ||||
-rw-r--r-- | spec/routing/admin_routing_spec.rb | 24 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 14 | ||||
-rw-r--r-- | spec/tasks/gitlab/backup_rake_spec.rb | 10 |
8 files changed, 121 insertions, 121 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index c64c053bad2..a4660806cca 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -36,7 +36,7 @@ describe MergeRequest do it { should respond_to(:can_be_merged?) } it { should respond_to(:cannot_be_merged?) } end - + describe 'modules' do it { should include_module(Issuable) } end diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index f74fea01aaa..efab5510c59 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -134,7 +134,7 @@ describe Milestone do it 'should be false if milestone active and not all nestied issues closed' do issue.milestone = milestone - issue.save + issue.save milestone.can_be_closed?.should be_false end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 66d5c7d91af..b5f72946492 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -16,7 +16,7 @@ describe UsersProjectObserver do it "should send email to user" do subject.should_receive(:notification) - Event.stub(:create => true) + Event.stub(create: true) create(:users_project) end diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index e97ceb2c991..cf284b607a5 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -26,7 +26,7 @@ describe Gitlab::API do json_response.first['name'].should == group1.name end end - + context "when authenticated as admin" do it "admin: should return an array of all groups" do get api("/groups", admin) @@ -36,7 +36,7 @@ describe Gitlab::API do end end end - + describe "GET /groups/:id" do context "when authenticated as user" do it "should return one of user1's groups" do @@ -44,32 +44,32 @@ describe Gitlab::API do response.status.should == 200 json_response['name'] == group1.name end - + it "should not return a non existing group" do get api("/groups/1328", user1) response.status.should == 404 end - + it "should not return a group not attached to user1" do get api("/groups/#{group2.id}", user1) response.status.should == 404 end end - + context "when authenticated as admin" do it "should return any existing group" do get api("/groups/#{group2.id}", admin) response.status.should == 200 json_response['name'] == group2.name end - + it "should not return a non existing group" do get api("/groups/1328", admin) response.status.should == 404 end end end - + describe "POST /groups" do context "when authenticated as user" do it "should not create group" do @@ -77,7 +77,7 @@ describe Gitlab::API do response.status.should == 403 end end - + context "when authenticated as admin" do it "should create group" do post api("/groups", admin), attributes_for(:group) @@ -85,17 +85,17 @@ describe Gitlab::API do end it "should not create group, duplicate" do - post api("/groups", admin), {:name => "Duplicate Test", :path => group2.path} + post api("/groups", admin), {name: "Duplicate Test", path: group2.path} response.status.should == 404 end it "should return 400 bad request error if name not given" do - post api("/groups", admin), { :path => group2.path } + post api("/groups", admin), { path: group2.path } response.status.should == 400 end it "should return 400 bad request error if path not given" do - post api("/groups", admin), { :name => 'test' } + post api("/groups", admin), { name: 'test' } response.status.should == 400 end end @@ -104,8 +104,8 @@ describe Gitlab::API do describe "POST /groups/:id/projects/:project_id" do let(:project) { create(:project) } before(:each) do - project.stub!(:transfer).and_return(true) - Project.stub(:find).and_return(project) + project.stub!(:transfer).and_return(true) + Project.stub(:find).and_return(project) end diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index fe1b324c921..647e31ce034 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -1,81 +1,81 @@ -require 'spec_helper'
-
-describe Gitlab::API do
- include ApiHelpers
-
- let(:user) { create(:user) }
- let(:admin) { create(:admin) }
- let!(:hook) { create(:system_hook, url: "http://example.com") }
-
- before { stub_request(:post, hook.url) }
-
- describe "GET /hooks" do
- context "when no user" do
- it "should return authentication error" do
- get api("/hooks")
- response.status.should == 401
- end
- end
-
- context "when not an admin" do
- it "should return forbidden error" do
- get api("/hooks", user)
- response.status.should == 403
- end
- end
-
- context "when authenticated as admin" do
- it "should return an array of hooks" do
- get api("/hooks", admin)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['url'].should == hook.url
- end
- end
- end
-
- describe "POST /hooks" do
- it "should create new hook" do
- expect {
- post api("/hooks", admin), url: 'http://example.com'
- }.to change { SystemHook.count }.by(1)
- end
-
- it "should respond with 400 if url not given" do
- post api("/hooks", admin)
- response.status.should == 400
- end
-
- it "should not create new hook without url" do
- expect {
- post api("/hooks", admin)
- }.to_not change { SystemHook.count }
- end
- end
-
- describe "GET /hooks/:id" do
- it "should return hook by id" do
- get api("/hooks/#{hook.id}", admin)
- response.status.should == 200
- json_response['event_name'].should == 'project_create'
- end
-
- it "should return 404 on failure" do
- get api("/hooks/404", admin)
- response.status.should == 404
- end
- end
-
- describe "DELETE /hooks/:id" do
- it "should delete a hook" do
- expect {
- delete api("/hooks/#{hook.id}", admin)
- }.to change { SystemHook.count }.by(-1)
- end
-
- it "should return success if hook id not found" do
- delete api("/hooks/12345", admin)
- response.status.should == 200
- end
- end
-end
\ No newline at end of file +require 'spec_helper' + +describe Gitlab::API do + include ApiHelpers + + let(:user) { create(:user) } + let(:admin) { create(:admin) } + let!(:hook) { create(:system_hook, url: "http://example.com") } + + before { stub_request(:post, hook.url) } + + describe "GET /hooks" do + context "when no user" do + it "should return authentication error" do + get api("/hooks") + response.status.should == 401 + end + end + + context "when not an admin" do + it "should return forbidden error" do + get api("/hooks", user) + response.status.should == 403 + end + end + + context "when authenticated as admin" do + it "should return an array of hooks" do + get api("/hooks", admin) + response.status.should == 200 + json_response.should be_an Array + json_response.first['url'].should == hook.url + end + end + end + + describe "POST /hooks" do + it "should create new hook" do + expect { + post api("/hooks", admin), url: 'http://example.com' + }.to change { SystemHook.count }.by(1) + end + + it "should respond with 400 if url not given" do + post api("/hooks", admin) + response.status.should == 400 + end + + it "should not create new hook without url" do + expect { + post api("/hooks", admin) + }.to_not change { SystemHook.count } + end + end + + describe "GET /hooks/:id" do + it "should return hook by id" do + get api("/hooks/#{hook.id}", admin) + response.status.should == 200 + json_response['event_name'].should == 'project_create' + end + + it "should return 404 on failure" do + get api("/hooks/404", admin) + response.status.should == 404 + end + end + + describe "DELETE /hooks/:id" do + it "should delete a hook" do + expect { + delete api("/hooks/#{hook.id}", admin) + }.to change { SystemHook.count }.by(-1) + end + + it "should return success if hook id not found" do + delete api("/hooks/12345", admin) + response.status.should == 200 + end + end +end diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb index b6509fcb8b2..c14fff5109b 100644 --- a/spec/routing/admin_routing_spec.rb +++ b/spec/routing/admin_routing_spec.rb @@ -56,15 +56,15 @@ describe Admin::UsersController, "routing" do end end -# team_admin_project GET /admin/projects/:id/team(.:format) admin/projects#team {:id=>/[^\/]+/} -# team_update_admin_project PUT /admin/projects/:id/team_update(.:format) admin/projects#team_update {:id=>/[^\/]+/} -# admin_projects GET /admin/projects(.:format) admin/projects#index {:id=>/[^\/]+/} -# POST /admin/projects(.:format) admin/projects#create {:id=>/[^\/]+/} -# new_admin_project GET /admin/projects/new(.:format) admin/projects#new {:id=>/[^\/]+/} -# edit_admin_project GET /admin/projects/:id/edit(.:format) admin/projects#edit {:id=>/[^\/]+/} -# admin_project GET /admin/projects/:id(.:format) admin/projects#show {:id=>/[^\/]+/} -# PUT /admin/projects/:id(.:format) admin/projects#update {:id=>/[^\/]+/} -# DELETE /admin/projects/:id(.:format) admin/projects#destroy {:id=>/[^\/]+/} +# team_admin_project GET /admin/projects/:id/team(.:format) admin/projects#team {id: /[^\/]+/} +# team_update_admin_project PUT /admin/projects/:id/team_update(.:format) admin/projects#team_update {id: /[^\/]+/} +# admin_projects GET /admin/projects(.:format) admin/projects#index {id: /[^\/]+/} +# POST /admin/projects(.:format) admin/projects#create {id: /[^\/]+/} +# new_admin_project GET /admin/projects/new(.:format) admin/projects#new {id: /[^\/]+/} +# edit_admin_project GET /admin/projects/:id/edit(.:format) admin/projects#edit {id: /[^\/]+/} +# admin_project GET /admin/projects/:id(.:format) admin/projects#show {id: /[^\/]+/} +# PUT /admin/projects/:id(.:format) admin/projects#update {id: /[^\/]+/} +# DELETE /admin/projects/:id(.:format) admin/projects#destroy {id: /[^\/]+/} describe Admin::ProjectsController, "routing" do it "to #index" do get("/admin/projects").should route_to('admin/projects#index') @@ -75,9 +75,9 @@ describe Admin::ProjectsController, "routing" do end end -# edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {:id=>/[^\/]+/, :project_id=>/[^\/]+/} -# admin_project_member PUT /admin/projects/:project_id/members/:id(.:format) admin/projects/members#update {:id=>/[^\/]+/, :project_id=>/[^\/]+/} -# DELETE /admin/projects/:project_id/members/:id(.:format) admin/projects/members#destroy {:id=>/[^\/]+/, :project_id=>/[^\/]+/} +# edit_admin_project_member GET /admin/projects/:project_id/members/:id/edit(.:format) admin/projects/members#edit {id: /[^\/]+/, project_id: /[^\/]+/} +# admin_project_member PUT /admin/projects/:project_id/members/:id(.:format) admin/projects/members#update {id: /[^\/]+/, project_id: /[^\/]+/} +# DELETE /admin/projects/:project_id/members/:id(.:format) admin/projects/members#destroy {id: /[^\/]+/, project_id: /[^\/]+/} describe Admin::Projects::MembersController, "routing" do it "to #edit" do get("/admin/projects/test/members/1/edit").should route_to('admin/projects/members#edit', project_id: 'test', id: '1') diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index dd4fb54af69..613c4565755 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -279,7 +279,7 @@ describe HooksController, "routing" do end end -# project_commit GET /:project_id/commit/:id(.:format) commit#show {:id=>/[[:alnum:]]{6,40}/, :project_id=>/[^\/]+/} +# project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /[[:alnum:]]{6,40}/, project_id: /[^\/]+/} describe CommitController, "routing" do it "to #show" do get("/gitlabhq/commit/4246fb").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb') @@ -375,7 +375,7 @@ describe NotesController, "routing" do end end -# project_blame GET /:project_id/blame/:id(.:format) blame#show {:id=>/.+/, :project_id=>/[^\/]+/} +# project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/} describe BlameController, "routing" do it "to #show" do get("/gitlabhq/blame/master/app/models/project.rb").should route_to('blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') @@ -383,7 +383,7 @@ describe BlameController, "routing" do end end -# project_blob GET /:project_id/blob/:id(.:format) blob#show {:id=>/.+/, :project_id=>/[^\/]+/} +# project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/} describe BlobController, "routing" do it "to #show" do get("/gitlabhq/blob/master/app/models/project.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') @@ -392,7 +392,7 @@ describe BlobController, "routing" do end end -# project_tree GET /:project_id/tree/:id(.:format) tree#show {:id=>/.+/, :project_id=>/[^\/]+/} +# project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/} describe TreeController, "routing" do it "to #show" do get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') @@ -400,9 +400,9 @@ describe TreeController, "routing" do end end -# project_compare_index GET /:project_id/compare(.:format) compare#index {:id=>/[^\/]+/, :project_id=>/[^\/]+/} -# POST /:project_id/compare(.:format) compare#create {:id=>/[^\/]+/, :project_id=>/[^\/]+/} -# project_compare /:project_id/compare/:from...:to(.:format) compare#show {:from=>/.+/, :to=>/.+/, :id=>/[^\/]+/, :project_id=>/[^\/]+/} +# project_compare_index GET /:project_id/compare(.:format) compare#index {id: /[^\/]+/, project_id: /[^\/]+/} +# POST /:project_id/compare(.:format) compare#create {id: /[^\/]+/, project_id: /[^\/]+/} +# project_compare /:project_id/compare/:from...:to(.:format) compare#show {from: /.+/, to: /.+/, id: /[^\/]+/, project_id: /[^\/]+/} describe CompareController, "routing" do it "to #index" do get("/gitlabhq/compare").should route_to('compare#index', project_id: 'gitlabhq') diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index babbf2916f8..4ad63114cb4 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -22,21 +22,21 @@ describe 'gitlab:app namespace rake task' do context 'gitlab version' do before do - Dir.stub :glob => [] + Dir.stub glob: [] Dir.stub :chdir - File.stub :exists? => true - Kernel.stub :system => true + File.stub exists?: true + Kernel.stub system: true end let(:gitlab_version) { %x{git rev-parse HEAD}.gsub(/\n/,"") } it 'should fail on mismach' do - YAML.stub :load_file => {:gitlab_version => gitlab_version.reverse} + YAML.stub load_file: {gitlab_version: gitlab_version.reverse} expect { run_rake_task }.to raise_error SystemExit end it 'should invoke restoration on mach' do - YAML.stub :load_file => {:gitlab_version => gitlab_version} + YAML.stub load_file: {gitlab_version: gitlab_version} Rake::Task["gitlab:backup:db:restore"].should_receive :invoke Rake::Task["gitlab:backup:repo:restore"].should_receive :invoke expect { run_rake_task }.to_not raise_error SystemExit |