[#345] replace owner_with_name to name_with_owner

This commit is contained in:
Alexander Machehin 2014-03-19 13:19:03 +06:00
parent d013d8c138
commit d7a3f629e8
14 changed files with 92 additions and 92 deletions

View File

@ -12,7 +12,7 @@ class Projects::BaseController < ApplicationController
end end
def find_project def find_project
@project = Project.find_by_owner_and_name! params[:owner_with_name] @project = Project.find_by_owner_and_name! params[:name_with_owner]
end end
def init_statistics def init_statistics

View File

@ -292,7 +292,7 @@ Rosa::Application.routes.draw do
get :mass_import get :mass_import
end end
end end
scope ':owner_with_name', constraints: { owner_with_name: Project::OWNER_AND_NAME_REGEXP } do # project scope ':name_with_owner', constraints: { name_with_owner: Project::OWNER_AND_NAME_REGEXP } do # project
scope as: 'project' do scope as: 'project' do
resources :wiki do resources :wiki do
collection do collection do

View File

@ -32,7 +32,7 @@ shared_examples_for "api projects user without show rights" do
end end
it "should access violation instead of project data by get_id" do it "should access violation instead of project data by get_id" do
get :get_id, owner_with_name: @project.name_with_owner, format: :json get :get_id, name_with_owner: @project.name_with_owner, format: :json
response.should_not be_success response.should_not be_success
end end
@ -98,17 +98,17 @@ shared_examples_for "api projects user with show rights" do
context 'project find by get_id' do context 'project find by get_id' do
it "should find project by name and owner name" do it "should find project by name and owner name" do
@project.reload @project.reload
get :get_id, owner_with_name: @project.name_with_owner, format: :json get :get_id, name_with_owner: @project.name_with_owner, format: :json
assigns[:project].id.should == @project.id assigns[:project].id.should == @project.id
end end
it "should not find project by non existing name and owner name" do it "should not find project by non existing name and owner name" do
get :get_id, owner_with_name: "#{@project.owner_uname}/NONE_EXISTING_NAME", format: :json get :get_id, name_with_owner: "#{@project.owner_uname}/NONE_EXISTING_NAME", format: :json
assigns[:project].should be_blank assigns[:project].should be_blank
end end
it "should render 404 for non existing name and owner name" do it "should render 404 for non existing name and owner name" do
get :get_id, owner_with_name: "#{@project.owner_uname}/NONE_EXISTING_NAME", format: :json get :get_id, name_with_owner: "#{@project.owner_uname}/NONE_EXISTING_NAME", format: :json
response.body.should == {status: 404, message: I18n.t("flash.404_message")}.to_json response.body.should == {status: 404, message: I18n.t("flash.404_message")}.to_json
end end
end end

View File

@ -9,7 +9,7 @@ describe Projects::BuildListsController do
end end
it 'should be able to perform index action in project scope' do it 'should be able to perform index action in project scope' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should be_success response.should be_success
end end
end end
@ -21,7 +21,7 @@ describe Projects::BuildListsController do
end end
it 'should not be able to perform index action in project scope' do it 'should not be able to perform index action in project scope' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(forbidden_url) response.should redirect_to(forbidden_url)
end end
end end
@ -32,32 +32,32 @@ describe Projects::BuildListsController do
} }
it 'should be able to perform new action' do it 'should be able to perform new action' do
get :new, owner_with_name: @project.name_with_owner get :new, name_with_owner: @project.name_with_owner
response.should render_template(:new) response.should render_template(:new)
end end
it 'should be able to perform create action' do it 'should be able to perform create action' do
post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params) post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params)
response.should redirect_to project_build_lists_path(@project) response.should redirect_to project_build_lists_path(@project)
end end
it 'should save correct commit_hash for branch based build' do it 'should save correct commit_hash for branch based build' do
post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "master" }) post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "master" })
@project.build_lists.last.commit_hash.should == @project.repo.commits('master').first.id @project.build_lists.last.commit_hash.should == @project.repo.commits('master').first.id
end end
it 'should save correct commit_hash for tag based build' do it 'should save correct commit_hash for tag based build' do
system("cd #{@project.repo.path} && git tag 4.7.5.3") # TODO REDO through grit system("cd #{@project.repo.path} && git tag 4.7.5.3") # TODO REDO through grit
post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "4.7.5.3" }) post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "4.7.5.3" })
@project.build_lists.last.commit_hash.should == @project.repo.commits('4.7.5.3').first.id @project.build_lists.last.commit_hash.should == @project.repo.commits('4.7.5.3').first.id
end end
it 'should not be able to create with wrong project version' do it 'should not be able to create with wrong project version' do
lambda{ post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "wrong", commit_hash: nil })}.should change{ @project.build_lists.count }.by(0) lambda{ post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { project_version: "wrong", commit_hash: nil })}.should change{ @project.build_lists.count }.by(0)
end end
it 'should not be able to create with wrong git hash' do it 'should not be able to create with wrong git hash' do
lambda{ post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { commit_hash: 'wrong' }) }.should change{ @project.build_lists.count }.by(0) lambda{ post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params).deep_merge(build_list: { commit_hash: 'wrong' }) }.should change{ @project.build_lists.count }.by(0)
end end
end end
@ -67,12 +67,12 @@ describe Projects::BuildListsController do
} }
it 'should not be able to perform new action' do it 'should not be able to perform new action' do
get :new, owner_with_name: @project.name_with_owner get :new, name_with_owner: @project.name_with_owner
response.should redirect_to(forbidden_url) response.should redirect_to(forbidden_url)
end unless skip_new end unless skip_new
it 'should not be able to perform create action' do it 'should not be able to perform create action' do
post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params) post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params)
response.should redirect_to(forbidden_url) response.should redirect_to(forbidden_url)
end end
end end
@ -119,7 +119,7 @@ describe Projects::BuildListsController do
@user = FactoryGirl.create(:user) @user = FactoryGirl.create(:user)
set_session_for(@user) set_session_for(@user)
@show_params = { owner_with_name: @project.name_with_owner, id: @build_list.id } @show_params = { name_with_owner: @project.name_with_owner, id: @build_list.id }
@build_list.save_to_repository.update_column(:publish_without_qa, false) @build_list.save_to_repository.update_column(:publish_without_qa, false)
@request.env['HTTP_REFERER'] = build_list_path(@build_list) @request.env['HTTP_REFERER'] = build_list_path(@build_list)
end end
@ -315,7 +315,7 @@ describe Projects::BuildListsController do
create_actor_relation(@member_group, @member_user, 'reader') create_actor_relation(@member_group, @member_user, 'reader')
create_relation(@project, @member_group, 'reader') create_relation(@project, @member_group, 'reader')
@show_params = { owner_with_name: @project.name_with_owner, id: @build_list.id } @show_params = { name_with_owner: @project.name_with_owner, id: @build_list.id }
end end
context 'for all build lists' do context 'for all build lists' do

View File

@ -24,7 +24,7 @@ shared_context "collaborators controller" do
role: 'reader' role: 'reader'
} if @group } if @group
@create_params = { @create_params = {
owner_with_name: @project.name_with_owner, name_with_owner: @project.name_with_owner,
format: :json format: :json
} }
@update_params = @create_params.merge(collaborator: { role: 'reader' }) @update_params = @create_params.merge(collaborator: { role: 'reader' })
@ -33,7 +33,7 @@ end
shared_examples_for 'project admin user' do shared_examples_for 'project admin user' do
it 'should be able to view collaborators list' do it 'should be able to view collaborators list' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should be_success response.should be_success
end end
@ -60,7 +60,7 @@ end
shared_examples_for 'user with no rights for this project' do shared_examples_for 'user with no rights for this project' do
it 'should not be able to view collaborators list' do it 'should not be able to view collaborators list' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
@ -83,7 +83,7 @@ describe Projects::CollaboratorsController do
set_session_for(User.new) set_session_for(User.new)
end end
it 'should not be able to perform index action' do it 'should not be able to perform index action' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end

View File

@ -6,15 +6,15 @@ describe Projects::CommentsController do
@project = FactoryGirl.create(:project_with_commit) @project = FactoryGirl.create(:project_with_commit)
@commit = @project.repo.commits.first @commit = @project.repo.commits.first
@create_params = { comment: { body: 'I am a comment!' }, owner_with_name: @project.name_with_owner, commit_id: @commit.id } @create_params = { comment: { body: 'I am a comment!' }, name_with_owner: @project.name_with_owner, commit_id: @commit.id }
@update_params = { comment: { body: 'updated' }, owner_with_name: @project.name_with_owner, commit_id: @commit.id } @update_params = { comment: { body: 'updated' }, name_with_owner: @project.name_with_owner, commit_id: @commit.id }
any_instance_of(Project, versions: ['v1.0', 'v2.0']) any_instance_of(Project, versions: ['v1.0', 'v2.0'])
@comment = FactoryGirl.create(:comment, commentable: @commit, project: @project) @comment = FactoryGirl.create(:comment, commentable: @commit, project: @project)
@user = FactoryGirl.create(:user) @user = FactoryGirl.create(:user)
@own_comment = FactoryGirl.create(:comment, commentable: @commit, user: @user, project: @project) @own_comment = FactoryGirl.create(:comment, commentable: @commit, user: @user, project: @project)
set_session_for(@user) set_session_for(@user)
@path = { owner_with_name: @project.name_with_owner, commit_id: @commit.id } @path = { name_with_owner: @project.name_with_owner, commit_id: @commit.id }
@return_path = commit_path(@project, @commit.id) @return_path = commit_path(@project, @commit.id)
end end

View File

@ -13,7 +13,7 @@ shared_context "comments controller" do
set_session_for(@user) set_session_for(@user)
@path = { owner_with_name: @project.name_with_owner, issue_id: @issue.serial_id } @path = { name_with_owner: @project.name_with_owner, issue_id: @issue.serial_id }
@return_path = project_issue_path(@project, @issue) @return_path = project_issue_path(@project, @issue)
@create_params = { comment: { body: 'I am a comment!' }}.merge(@path) @create_params = { comment: { body: 'I am a comment!' }}.merge(@path)
@update_params = { comment: { body: 'updated' }}.merge(@path) @update_params = { comment: { body: 'updated' }}.merge(@path)

View File

@ -6,7 +6,7 @@ describe Projects::Git::TreesController do
stub_symlink_methods stub_symlink_methods
@project = FactoryGirl.create(:project) @project = FactoryGirl.create(:project)
@params = { owner_with_name: @project.name_with_owner, treeish: "#{@project.name}-master" } @params = { name_with_owner: @project.name_with_owner, treeish: "#{@project.name}-master" }
fill_project @project fill_project @project
end end

View File

@ -2,54 +2,54 @@ require 'spec_helper'
shared_examples_for 'hooks user with project admin rights' do shared_examples_for 'hooks user with project admin rights' do
it 'should be able to perform index action' do it 'should be able to perform index action' do
get :index, {owner_with_name: "#{@project.owner.uname}/#{@project.name}"} get :index, {name_with_owner: "#{@project.owner.uname}/#{@project.name}"}
response.should be_success response.should be_success
end end
it 'should be able to perform new action' do it 'should be able to perform new action' do
get :new, { owner_with_name: @project.name_with_owner, hook: { name: 'web' }} get :new, { name_with_owner: @project.name_with_owner, hook: { name: 'web' }}
response.should be_success response.should be_success
end end
it 'should be able to perform edit action' do it 'should be able to perform edit action' do
get :new, { owner_with_name: @project.name_with_owner, id: @hook.id } get :new, { name_with_owner: @project.name_with_owner, id: @hook.id }
response.should be_success response.should be_success
end end
it 'should be able to perform update action' do it 'should be able to perform update action' do
put :update, { owner_with_name: @project.name_with_owner, id: @hook.id }.merge(@update_params) put :update, { name_with_owner: @project.name_with_owner, id: @hook.id }.merge(@update_params)
response.should redirect_to(project_hooks_path(@project, name: 'web')) response.should redirect_to(project_hooks_path(@project, name: 'web'))
end end
it 'should be able to perform create action' do it 'should be able to perform create action' do
post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params) post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params)
response.should redirect_to(project_hooks_path(@project, name: 'web')) response.should redirect_to(project_hooks_path(@project, name: 'web'))
end end
end end
shared_examples_for 'hooks user without project admin rights' do shared_examples_for 'hooks user without project admin rights' do
it 'should not be able to perform index action' do it 'should not be able to perform index action' do
get :index, { owner_with_name: @project.name_with_owner } get :index, { name_with_owner: @project.name_with_owner }
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to perform new action' do it 'should not be able to perform new action' do
get :new, { owner_with_name: @project.name_with_owner, hook: { name: 'web' }} get :new, { name_with_owner: @project.name_with_owner, hook: { name: 'web' }}
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to perform edit action' do it 'should not be able to perform edit action' do
get :new, { owner_with_name: @project.name_with_owner, id: @hook.id } get :new, { name_with_owner: @project.name_with_owner, id: @hook.id }
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to perform update action' do it 'should not be able to perform update action' do
put :update, { owner_with_name: @project.name_with_owner, id: @hook.id }.merge(@update_params) put :update, { name_with_owner: @project.name_with_owner, id: @hook.id }.merge(@update_params)
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to perform create action' do it 'should not be able to perform create action' do
post :create, { owner_with_name: @project.name_with_owner }.merge(@create_params) post :create, { name_with_owner: @project.name_with_owner }.merge(@create_params)
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
end end

View File

@ -17,7 +17,7 @@ shared_context "issues controller" do
set_session_for(@user) set_session_for(@user)
@create_params = { @create_params = {
owner_with_name: @project.name_with_owner, name_with_owner: @project.name_with_owner,
issue: { issue: {
title: "issue1", title: "issue1",
body: "issue body", body: "issue body",
@ -26,7 +26,7 @@ shared_context "issues controller" do
} }
} }
@update_params = { owner_with_name: @project.name_with_owner, issue: { title: "issue2" }} @update_params = { name_with_owner: @project.name_with_owner, issue: { title: "issue2" }}
@pull = @project.pull_requests.new issue_attributes: { title: 'test', body: 'testing' } @pull = @project.pull_requests.new issue_attributes: { title: 'test', body: 'testing' }
@pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project @pull.issue.user, @pull.issue.project = @project.owner, @pull.to_project
@ -39,12 +39,12 @@ end
shared_examples_for 'issue user with project guest rights' do shared_examples_for 'issue user with project guest rights' do
it 'should be able to perform index action' do it 'should be able to perform index action' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index) response.should render_template(:index)
end end
it 'should be able to perform show action' do it 'should be able to perform show action' do
get :show, owner_with_name: @project.name_with_owner, id: @issue.serial_id get :show, name_with_owner: @project.name_with_owner, id: @issue.serial_id
response.should render_template(:show) response.should render_template(:show)
end end
end end
@ -53,7 +53,7 @@ shared_examples_for 'issue user with project reader rights' do
it 'should be able to perform index action on hidden project' do it 'should be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index) response.should render_template(:index)
end end
@ -70,7 +70,7 @@ end
shared_examples_for 'issue user with project writer rights' do shared_examples_for 'issue user with project writer rights' do
it 'should be able to perform index action on hidden project' do it 'should be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index) response.should render_template(:index)
end end
@ -117,23 +117,23 @@ end
shared_examples_for 'user without issue destroy rights' do shared_examples_for 'user without issue destroy rights' do
it 'should not be able to perform destroy action' do it 'should not be able to perform destroy action' do
delete :destroy, id: @issue.serial_id, owner_with_name: @project.name_with_owner delete :destroy, id: @issue.serial_id, name_with_owner: @project.name_with_owner
response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path)
end end
it 'should not reduce issues count' do it 'should not reduce issues count' do
lambda{ delete :destroy, id: @issue.serial_id, owner_with_name: @project.name_with_owner }.should_not change{ Issue.count } lambda{ delete :destroy, id: @issue.serial_id, name_with_owner: @project.name_with_owner }.should_not change{ Issue.count }
end end
end end
shared_examples_for 'project with issues turned off' do shared_examples_for 'project with issues turned off' do
it 'should not be able to perform index action' do it 'should not be able to perform index action' do
get :index, owner_with_name: @project_with_turned_off_issues.name_with_owner get :index, name_with_owner: @project_with_turned_off_issues.name_with_owner
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to perform show action' do it 'should not be able to perform show action' do
get :show, owner_with_name: @project_with_turned_off_issues.name_with_owner, id: @turned_of_issue.serial_id get :show, name_with_owner: @project_with_turned_off_issues.name_with_owner, id: @turned_of_issue.serial_id
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
end end
@ -215,12 +215,12 @@ describe Projects::IssuesController do
# end # end
it 'should return 404' do it 'should return 404' do
get :show, owner_with_name: @project.name_with_owner, id: 999999 get :show, name_with_owner: @project.name_with_owner, id: 999999
render_template(file: "#{Rails.root}/public/404.html") render_template(file: "#{Rails.root}/public/404.html")
end end
it 'should redirect to pull request page' do it 'should redirect to pull request page' do
get :show, owner_with_name: @project.name_with_owner, id: @pull.serial_id get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id
response.should redirect_to(project_pull_request_path(@project, @pull)) response.should redirect_to(project_pull_request_path(@project, @pull))
end end
end end
@ -260,24 +260,24 @@ describe Projects::IssuesController do
it 'should not be able to perform index action on hidden project' do it 'should not be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
else else
it 'should not be able to perform index action' do it 'should not be able to perform index action' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
it 'should not be able to perform show action' do it 'should not be able to perform show action' do
get :show, owner_with_name: @project.name_with_owner, id: @issue.serial_id get :show, name_with_owner: @project.name_with_owner, id: @issue.serial_id
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
it 'should not be able to perform index action on hidden project' do it 'should not be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
end end

View File

@ -3,67 +3,67 @@ require 'spec_helper'
shared_examples_for 'projects user with reader rights' do shared_examples_for 'projects user with reader rights' do
it 'should be able to fork project' do it 'should be able to fork project' do
post :fork, owner_with_name: @project.name_with_owner post :fork, name_with_owner: @project.name_with_owner
response.should redirect_to(project_path(Project.last)) response.should redirect_to(project_path(Project.last))
end end
it 'should be able to fork project to their group' do it 'should be able to fork project to their group' do
group = FactoryGirl.create(:group) group = FactoryGirl.create(:group)
create_actor_relation(group, @user, 'admin') create_actor_relation(group, @user, 'admin')
lambda { post :fork, owner_with_name: @project.name_with_owner, lambda { post :fork, name_with_owner: @project.name_with_owner,
group: group.id }.should change{ Project.count }.by(1) group: group.id }.should change{ Project.count }.by(1)
end end
it 'should be able to fork project to own group' do it 'should be able to fork project to own group' do
group = FactoryGirl.create(:group, owner: @user) group = FactoryGirl.create(:group, owner: @user)
lambda { post :fork, owner_with_name: @project.name_with_owner, lambda { post :fork, name_with_owner: @project.name_with_owner,
group: group.id }.should change{ Project.count }.by(1) group: group.id }.should change{ Project.count }.by(1)
end end
it 'should be able to fork project with different name' do it 'should be able to fork project with different name' do
post :fork, owner_with_name: @project.name_with_owner, fork_name: 'another_name' post :fork, name_with_owner: @project.name_with_owner, fork_name: 'another_name'
response.should redirect_to(project_path(Project.where(name: 'another_name').last)) response.should redirect_to(project_path(Project.where(name: 'another_name').last))
end end
end end
shared_examples_for 'projects user with project admin rights' do shared_examples_for 'projects user with project admin rights' do
it 'should be able to perform update action' do it 'should be able to perform update action' do
put :update, { owner_with_name: @project.name_with_owner }.merge(@update_params) put :update, { name_with_owner: @project.name_with_owner }.merge(@update_params)
response.should redirect_to(project_path(@project)) response.should redirect_to(project_path(@project))
end end
it 'should be able to perform schedule action' do it 'should be able to perform schedule action' do
put :schedule, { owner_with_name: @project.name_with_owner }.merge(repository_id: @project.repositories.first.id) put :schedule, { name_with_owner: @project.name_with_owner }.merge(repository_id: @project.repositories.first.id)
response.should be_success response.should be_success
end end
end end
shared_examples_for 'user with destroy rights' do shared_examples_for 'user with destroy rights' do
it 'should be able to perform destroy action' do it 'should be able to perform destroy action' do
delete :destroy, { owner_with_name: @project.name_with_owner } delete :destroy, { name_with_owner: @project.name_with_owner }
response.should redirect_to(@project.owner) response.should redirect_to(@project.owner)
end end
it 'should change objects count on destroy' do it 'should change objects count on destroy' do
lambda { delete :destroy, owner_with_name: @project.name_with_owner }.should change{ Project.count }.by(-1) lambda { delete :destroy, name_with_owner: @project.name_with_owner }.should change{ Project.count }.by(-1)
end end
end end
shared_examples_for 'projects user without project admin rights' do shared_examples_for 'projects user without project admin rights' do
it 'should not be able to edit project' do it 'should not be able to edit project' do
description = @project.description description = @project.description
put :update, project: { description:"hack" }, owner_with_name: @project.name_with_owner put :update, project: { description:"hack" }, name_with_owner: @project.name_with_owner
@project.reload.description.should == description @project.reload.description.should == description
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to perform schedule action' do it 'should not be able to perform schedule action' do
put :schedule, { owner_with_name: @project.name_with_owner }.merge(repository_id: @project.repositories.first.id) put :schedule, { name_with_owner: @project.name_with_owner }.merge(repository_id: @project.repositories.first.id)
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should not be able to edit project sections' do it 'should not be able to edit project sections' do
has_wiki, has_issues = @project.has_wiki, @project.has_issues has_wiki, has_issues = @project.has_wiki, @project.has_issues
post :sections, project: { has_wiki: !has_wiki, has_issues: !has_issues }, owner_with_name: @project.name_with_owner post :sections, project: { has_wiki: !has_wiki, has_issues: !has_issues }, name_with_owner: @project.name_with_owner
@project.reload.has_wiki.should == has_wiki @project.reload.has_wiki.should == has_wiki
@project.reload.has_issues.should == has_issues @project.reload.has_issues.should == has_issues
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
@ -72,14 +72,14 @@ shared_examples_for 'projects user without project admin rights' do
it 'writer group should be able to fork project to their group' do it 'writer group should be able to fork project to their group' do
group = FactoryGirl.create(:group) group = FactoryGirl.create(:group)
create_actor_relation(group, @user, 'writer') create_actor_relation(group, @user, 'writer')
lambda { post :fork, owner_with_name: @project.name_with_owner, lambda { post :fork, name_with_owner: @project.name_with_owner,
group: group.id }.should change{ Project.count }.by(1) group: group.id }.should change{ Project.count }.by(1)
end end
it 'reader group should not be able to fork project to their group' do it 'reader group should not be able to fork project to their group' do
group = FactoryGirl.create(:group) group = FactoryGirl.create(:group)
create_actor_relation(group, @user, 'reader') create_actor_relation(group, @user, 'reader')
lambda { post :fork, owner_with_name: @project.name_with_owner, lambda { post :fork, name_with_owner: @project.name_with_owner,
group: group.id }.should change{ Project.count }.by(0) group: group.id }.should change{ Project.count }.by(0)
end end
@ -124,12 +124,12 @@ describe Projects::ProjectsController do
end end
it 'should not be able to perform update action' do it 'should not be able to perform update action' do
put :update, { owner_with_name: @project.name_with_owner }.merge(@update_params) put :update, { name_with_owner: @project.name_with_owner }.merge(@update_params)
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
it 'should not be able to perform schedule action' do it 'should not be able to perform schedule action' do
put :schedule, { owner_with_name: @project.name_with_owner }.merge(repository_id: @project.repositories.first.id) put :schedule, { name_with_owner: @project.name_with_owner }.merge(repository_id: @project.repositories.first.id)
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
@ -207,7 +207,7 @@ describe Projects::ProjectsController do
it_should_behave_like 'user with destroy rights' it_should_behave_like 'user with destroy rights'
it 'should not be able to fork own project' do it 'should not be able to fork own project' do
post :fork, owner_with_name: @project.name_with_owner post :fork, name_with_owner: @project.name_with_owner
response.should redirect_to(@project) response.should redirect_to(@project)
end end
@ -236,7 +236,7 @@ describe Projects::ProjectsController do
it 'should not be able to fork hidden project' do it 'should not be able to fork hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
post :fork, owner_with_name: @project.name_with_owner post :fork, name_with_owner: @project.name_with_owner
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end

View File

@ -19,7 +19,7 @@ shared_context "pull request controller" do
to_ref: 'non_conflicts', to_ref: 'non_conflicts',
from_ref: 'master' }, from_ref: 'master' },
to_project: @project.name_with_owner, to_project: @project.name_with_owner,
owner_with_name: @project.name_with_owner name_with_owner: @project.name_with_owner
} }
@update_params = @create_params.merge(pull_request_action: 'close', id: @pull.serial_id) @update_params = @create_params.merge(pull_request_action: 'close', id: @pull.serial_id)
@wrong_update_params = @create_params.merge( @wrong_update_params = @create_params.merge(
@ -36,13 +36,13 @@ end
shared_examples_for 'pull request user with project guest rights' do shared_examples_for 'pull request user with project guest rights' do
it 'should be able to perform index action' do it 'should be able to perform index action' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index) response.should render_template(:index)
end end
it 'should be able to perform show action when pull request has been created' do it 'should be able to perform show action when pull request has been created' do
@pull.check @pull.check
get :show, owner_with_name: @project.name_with_owner, id: @pull.serial_id get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id
response.should render_template(:show) response.should render_template(:show)
end end
end end
@ -50,7 +50,7 @@ end
shared_examples_for 'pull request user with project reader rights' do shared_examples_for 'pull request user with project reader rights' do
it 'should be able to perform index action on hidden project' do it 'should be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index) response.should render_template(:index)
end end
@ -162,13 +162,13 @@ end
shared_examples_for 'pull request when project with issues turned off' do shared_examples_for 'pull request when project with issues turned off' do
before { @project.update_attributes(has_issues: false) } before { @project.update_attributes(has_issues: false) }
it 'should be able to perform index action' do it 'should be able to perform index action' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should render_template(:index) response.should render_template(:index)
end end
it 'should be able to perform show action when pull request has been created' do it 'should be able to perform show action when pull request has been created' do
@pull.check @pull.check
get :show, owner_with_name: @project.name_with_owner, id: @pull.serial_id get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id
response.should render_template(:show) response.should render_template(:show)
end end
end end
@ -222,12 +222,12 @@ describe Projects::PullRequestsController do
it_should_behave_like 'pull request when project with issues turned off' it_should_behave_like 'pull request when project with issues turned off'
it 'should return 404' do it 'should return 404' do
get :show, owner_with_name: @project.name_with_owner, id: 999999 get :show, name_with_owner: @project.name_with_owner, id: 999999
render_template(file: "#{Rails.root}/public/404.html") render_template(file: "#{Rails.root}/public/404.html")
end end
it 'should redirect to issue page' do it 'should redirect to issue page' do
get :show, owner_with_name: @project.name_with_owner, id: @issue.serial_id get :show, name_with_owner: @project.name_with_owner, id: @issue.serial_id
response.should redirect_to(project_issue_path(@project, @issue)) response.should redirect_to(project_issue_path(@project, @issue))
end end
end end
@ -267,19 +267,19 @@ describe Projects::PullRequestsController do
else else
it 'should not be able to perform index action' do it 'should not be able to perform index action' do
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
it 'should not be able to perform show action' do it 'should not be able to perform show action' do
@pull.check @pull.check
get :show, owner_with_name: @project.name_with_owner, id: @pull.serial_id get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
it 'should not be able to perform index action on hidden project' do it 'should not be able to perform index action on hidden project' do
@project.update_attributes(visibility: 'hidden') @project.update_attributes(visibility: 'hidden')
get :index, owner_with_name: @project.name_with_owner get :index, name_with_owner: @project.name_with_owner
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
end end

View File

@ -53,8 +53,8 @@ describe Projects::SubscribesController do
@project = FactoryGirl.create(:project) @project = FactoryGirl.create(:project)
@issue = FactoryGirl.create(:issue, project_id: @project.id) @issue = FactoryGirl.create(:issue, project_id: @project.id)
@create_params = { issue_id: @issue.serial_id, owner_with_name: @project.name_with_owner } @create_params = { issue_id: @issue.serial_id, name_with_owner: @project.name_with_owner }
@destroy_params = { issue_id: @issue.serial_id, owner_with_name: @project.name_with_owner } @destroy_params = { issue_id: @issue.serial_id, name_with_owner: @project.name_with_owner }
any_instance_of(Project, versions: ['v1.0', 'v2.0']) any_instance_of(Project, versions: ['v1.0', 'v2.0'])

View File

@ -13,7 +13,7 @@ describe Projects::ProjectsController do
end end
it "routes to #edit" do it "routes to #edit" do
get("/import/glib2.0-mib/modify").should route_to("projects/projects#edit", owner_with_name: 'import/glib2.0-mib') get("/import/glib2.0-mib/modify").should route_to("projects/projects#edit", name_with_owner: 'import/glib2.0-mib')
end end
it "routes to #create" do it "routes to #create" do
@ -21,11 +21,11 @@ describe Projects::ProjectsController do
end end
it "routes to #update" do it "routes to #update" do
put("/import/glib2.0-mib").should route_to("projects/projects#update", owner_with_name: 'import/glib2.0-mib') put("/import/glib2.0-mib").should route_to("projects/projects#update", name_with_owner: 'import/glib2.0-mib')
end end
it "routes to #destroy" do it "routes to #destroy" do
delete("/import/glib2.0-mib").should route_to("projects/projects#destroy", owner_with_name: 'import/glib2.0-mib') delete("/import/glib2.0-mib").should route_to("projects/projects#destroy", name_with_owner: 'import/glib2.0-mib')
end end
end end
@ -35,13 +35,13 @@ describe Projects::Git::TreesController do
describe "routing" do describe "routing" do
context "routes to #show" do context "routes to #show" do
it { get("/import/glib2.0-mib").should route_to("projects/git/trees#show", owner_with_name: 'import/glib2.0-mib') } it { get("/import/glib2.0-mib").should route_to("projects/git/trees#show", name_with_owner: 'import/glib2.0-mib') }
it { get("/import/glib2.0-mib/tree/lib2safe-0.03").should route_to("projects/git/trees#show", owner_with_name: 'import/glib2.0-mib', treeish: 'lib2safe-0.03') } it { get("/import/glib2.0-mib/tree/lib2safe-0.03").should route_to("projects/git/trees#show", name_with_owner: 'import/glib2.0-mib', treeish: 'lib2safe-0.03') }
it { get("/import/glib2.0-mib/tree/branch-with.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", owner_with_name: 'import/glib2.0-mib', treeish: 'branch-with.dot', path: 'folder_with.dot/path-with.dot') } it { get("/import/glib2.0-mib/tree/branch-with.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", name_with_owner: 'import/glib2.0-mib', treeish: 'branch-with.dot', path: 'folder_with.dot/path-with.dot') }
# it { get("/import/glib2.0-mib/tree/ветка-с.точкой/папка_с.точкой/путь-с.точкой").should route_to("projects/git/trees#show", owner_with_name: 'import/glib2.0-mib', treeish: 'ветка-с.точкой', path: 'папка_с.точкой/путь-с.точкой') } # it { get("/import/glib2.0-mib/tree/ветка-с.точкой/папка_с.точкой/путь-с.точкой").should route_to("projects/git/trees#show", name_with_owner: 'import/glib2.0-mib', treeish: 'ветка-с.точкой', path: 'папка_с.точкой/путь-с.точкой') }
# TODO: ??? # TODO: ???
# it { get("/import/glib2.0-mib/tree/branch-with/slash.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", owner_with_name: 'import/glib2.0-mib', treeish: 'branch-with/slash.dot', path: 'folder_with.dot/path-with.dot') } # it { get("/import/glib2.0-mib/tree/branch-with/slash.dot/folder_with.dot/path-with.dot").should route_to("projects/git/trees#show", name_with_owner: 'import/glib2.0-mib', treeish: 'branch-with/slash.dot', path: 'folder_with.dot/path-with.dot') }
it { get("/import/glib2.0-mib/tree/tag13.52-5").should route_to("projects/git/trees#show", owner_with_name: 'import/glib2.0-mib', treeish: 'tag13.52-5') } it { get("/import/glib2.0-mib/tree/tag13.52-5").should route_to("projects/git/trees#show", name_with_owner: 'import/glib2.0-mib', treeish: 'tag13.52-5') }
end end
# TODO write more specs also with slash in branch name! # TODO write more specs also with slash in branch name!