Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
This commit is contained in:
parent
de1c450abd
commit
0c4a70a306
|
|
@ -4,4 +4,4 @@ begin
|
|||
rescue LoadError
|
||||
end
|
||||
require 'bundler/setup'
|
||||
load Gem.bin_path('rspec', 'rspec')
|
||||
load Gem.bin_path('rspec-core', 'rspec')
|
||||
|
|
|
|||
|
|
@ -7,26 +7,26 @@ describe ApplicationController do
|
|||
|
||||
it 'should redirect if the user is over their password expiry' do
|
||||
user.password_expires_at = Time.new(2002)
|
||||
user.ldap_user?.should be_false
|
||||
controller.stub(:current_user).and_return(user)
|
||||
controller.should_receive(:redirect_to)
|
||||
controller.should_receive(:new_profile_password_path)
|
||||
expect(user.ldap_user?).to be_falsey
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
expect(controller).to receive(:redirect_to)
|
||||
expect(controller).to receive(:new_profile_password_path)
|
||||
controller.send(:check_password_expiration)
|
||||
end
|
||||
|
||||
it 'should not redirect if the user is under their password expiry' do
|
||||
user.password_expires_at = Time.now + 20010101
|
||||
user.ldap_user?.should be_false
|
||||
controller.stub(:current_user).and_return(user)
|
||||
controller.should_not_receive(:redirect_to)
|
||||
expect(user.ldap_user?).to be_falsey
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
expect(controller).not_to receive(:redirect_to)
|
||||
controller.send(:check_password_expiration)
|
||||
end
|
||||
|
||||
it 'should not redirect if the user is over their password expiry but they are an ldap user' do
|
||||
user.password_expires_at = Time.new(2002)
|
||||
user.stub(:ldap_user?).and_return(true)
|
||||
controller.stub(:current_user).and_return(user)
|
||||
controller.should_not_receive(:redirect_to)
|
||||
allow(user).to receive(:ldap_user?).and_return(true)
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
expect(controller).not_to receive(:redirect_to)
|
||||
controller.send(:check_password_expiration)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ describe Projects::BlobController do
|
|||
|
||||
project.team << [user, :master]
|
||||
|
||||
project.stub(:branches).and_return(['master', 'foo/bar/baz'])
|
||||
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
|
||||
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
|
||||
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
|
||||
controller.instance_variable_set(:@project, project)
|
||||
end
|
||||
|
||||
|
|
@ -21,17 +21,17 @@ describe Projects::BlobController do
|
|||
|
||||
context "valid branch, valid file" do
|
||||
let(:id) { 'master/README.md' }
|
||||
it { should respond_with(:success) }
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
context "valid branch, invalid file" do
|
||||
let(:id) { 'master/invalid-path.rb' }
|
||||
it { should respond_with(:not_found) }
|
||||
it { is_expected.to respond_with(:not_found) }
|
||||
end
|
||||
|
||||
context "invalid branch, valid file" do
|
||||
let(:id) { 'invalid-branch/README.md' }
|
||||
it { should respond_with(:not_found) }
|
||||
it { is_expected.to respond_with(:not_found) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ describe Projects::BlobController do
|
|||
|
||||
context 'redirect to tree' do
|
||||
let(:id) { 'markdown/doc' }
|
||||
it { should redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") }
|
||||
it { is_expected.to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ describe Projects::BranchesController do
|
|||
|
||||
project.team << [user, :master]
|
||||
|
||||
project.stub(:branches).and_return(['master', 'foo/bar/baz'])
|
||||
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
|
||||
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
|
||||
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
|
||||
controller.instance_variable_set(:@project, project)
|
||||
end
|
||||
|
||||
|
|
@ -27,25 +27,25 @@ describe Projects::BranchesController do
|
|||
context "valid branch name, valid source" do
|
||||
let(:branch) { "merge_branch" }
|
||||
let(:ref) { "master" }
|
||||
it { should redirect_to("/#{project.path_with_namespace}/tree/merge_branch") }
|
||||
it { is_expected.to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") }
|
||||
end
|
||||
|
||||
context "invalid branch name, valid ref" do
|
||||
let(:branch) { "<script>alert('merge');</script>" }
|
||||
let(:ref) { "master" }
|
||||
it { should redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") }
|
||||
it { is_expected.to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") }
|
||||
end
|
||||
|
||||
context "valid branch name, invalid ref" do
|
||||
let(:branch) { "merge_branch" }
|
||||
let(:ref) { "<script>alert('ref');</script>" }
|
||||
it { should render_template("new") }
|
||||
it { is_expected.to render_template("new") }
|
||||
end
|
||||
|
||||
context "invalid branch name, invalid ref" do
|
||||
let(:branch) { "<script>alert('merge');</script>" }
|
||||
let(:ref) { "<script>alert('ref');</script>" }
|
||||
it { should render_template("new") }
|
||||
it { is_expected.to render_template("new") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe Projects::CommitController do
|
|||
end
|
||||
|
||||
it "should generate it" do
|
||||
Commit.any_instance.should_receive(:"to_#{format}")
|
||||
expect_any_instance_of(Commit).to receive(:"to_#{format}")
|
||||
|
||||
get :show, project_id: project.to_param, id: commit.id, format: format
|
||||
end
|
||||
|
|
@ -31,7 +31,7 @@ describe Projects::CommitController do
|
|||
end
|
||||
|
||||
it "should not escape Html" do
|
||||
Commit.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
|
||||
allow_any_instance_of(Commit).to receive(:"to_#{format}").and_return('HTML entities &<>" ')
|
||||
|
||||
get :show, project_id: project.to_param, id: commit.id, format: format
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ describe Projects::CommitsController do
|
|||
context "as atom feed" do
|
||||
it "should render as atom" do
|
||||
get :show, project_id: project.to_param, id: "master", format: "atom"
|
||||
response.should be_success
|
||||
response.content_type.should == 'application/atom+xml'
|
||||
expect(response).to be_success
|
||||
expect(response.content_type).to eq('application/atom+xml')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ describe Import::GithubController do
|
|||
describe "GET callback" do
|
||||
it "updates access token" do
|
||||
token = "asdasd12345"
|
||||
Gitlab::GithubImport::Client.any_instance.stub(:get_token).and_return(token)
|
||||
allow_any_instance_of(Gitlab::GithubImport::Client).to receive(:get_token).and_return(token)
|
||||
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123", app_secret: "asd123", name: "github")
|
||||
|
||||
get :callback
|
||||
|
||||
user.reload.github_access_token.should == token
|
||||
controller.should redirect_to(status_import_github_url)
|
||||
expect(user.reload.github_access_token).to eq(token)
|
||||
expect(controller).to redirect_to(status_import_github_url)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ describe Import::GithubController do
|
|||
|
||||
it "takes already existing namespace" do
|
||||
namespace = create(:namespace, name: "john", owner: user)
|
||||
Gitlab::GithubImport::ProjectCreator.should_receive(:new).with(@repo, namespace, user).
|
||||
expect(Gitlab::GithubImport::ProjectCreator).to receive(:new).with(@repo, namespace, user).
|
||||
and_return(double(execute: true))
|
||||
controller.stub_chain(:client, :repo).and_return(@repo)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ describe Import::GitlabController do
|
|||
|
||||
get :callback
|
||||
|
||||
user.reload.gitlab_access_token.should == token
|
||||
controller.should redirect_to(status_import_gitlab_url)
|
||||
expect(user.reload.gitlab_access_token).to eq(token)
|
||||
expect(controller).to redirect_to(status_import_gitlab_url)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ describe Import::GitlabController do
|
|||
|
||||
it "takes already existing namespace" do
|
||||
namespace = create(:namespace, name: "john", owner: user)
|
||||
Gitlab::GitlabImport::ProjectCreator.should_receive(:new).with(@repo, namespace, user).
|
||||
expect(Gitlab::GitlabImport::ProjectCreator).to receive(:new).with(@repo, namespace, user).
|
||||
and_return(double(execute: true))
|
||||
controller.stub_chain(:client, :project).and_return(@repo)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe Projects::MergeRequestsController do
|
|||
end
|
||||
|
||||
it "should generate it" do
|
||||
MergeRequest.any_instance.should_receive(:"to_#{format}")
|
||||
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
|
||||
|
||||
get :show, project_id: project.to_param, id: merge_request.iid, format: format
|
||||
end
|
||||
|
|
@ -31,7 +31,7 @@ describe Projects::MergeRequestsController do
|
|||
end
|
||||
|
||||
it "should not escape Html" do
|
||||
MergeRequest.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
|
||||
allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").and_return('HTML entities &<>" ')
|
||||
|
||||
get :show, project_id: project.to_param, id: merge_request.iid, format: format
|
||||
|
||||
|
|
|
|||
|
|
@ -45,18 +45,18 @@ describe ProjectsController do
|
|||
describe "POST #toggle_star" do
|
||||
it "toggles star if user is signed in" do
|
||||
sign_in(user)
|
||||
expect(user.starred?(public_project)).to be_false
|
||||
expect(user.starred?(public_project)).to be_falsey
|
||||
post :toggle_star, id: public_project.to_param
|
||||
expect(user.starred?(public_project)).to be_true
|
||||
expect(user.starred?(public_project)).to be_truthy
|
||||
post :toggle_star, id: public_project.to_param
|
||||
expect(user.starred?(public_project)).to be_false
|
||||
expect(user.starred?(public_project)).to be_falsey
|
||||
end
|
||||
|
||||
it "does nothing if user is not signed in" do
|
||||
post :toggle_star, id: public_project.to_param
|
||||
expect(user.starred?(public_project)).to be_false
|
||||
expect(user.starred?(public_project)).to be_falsey
|
||||
post :toggle_star, id: public_project.to_param
|
||||
expect(user.starred?(public_project)).to be_false
|
||||
expect(user.starred?(public_project)).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ describe Projects::TreeController do
|
|||
|
||||
project.team << [user, :master]
|
||||
|
||||
project.stub(:branches).and_return(['master', 'foo/bar/baz'])
|
||||
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
|
||||
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
|
||||
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
|
||||
controller.instance_variable_set(:@project, project)
|
||||
end
|
||||
|
||||
|
|
@ -22,22 +22,22 @@ describe Projects::TreeController do
|
|||
|
||||
context "valid branch, no path" do
|
||||
let(:id) { 'master' }
|
||||
it { should respond_with(:success) }
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
context "valid branch, valid path" do
|
||||
let(:id) { 'master/encoding/' }
|
||||
it { should respond_with(:success) }
|
||||
it { is_expected.to respond_with(:success) }
|
||||
end
|
||||
|
||||
context "valid branch, invalid path" do
|
||||
let(:id) { 'master/invalid-path/' }
|
||||
it { should respond_with(:not_found) }
|
||||
it { is_expected.to respond_with(:not_found) }
|
||||
end
|
||||
|
||||
context "invalid branch, valid path" do
|
||||
let(:id) { 'invalid-branch/encoding/' }
|
||||
it { should respond_with(:not_found) }
|
||||
it { is_expected.to respond_with(:not_found) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ describe Projects::TreeController do
|
|||
|
||||
context 'redirect to blob' do
|
||||
let(:id) { 'master/README.md' }
|
||||
it { should redirect_to("/#{project.path_with_namespace}/blob/master/README.md") }
|
||||
it { is_expected.to redirect_to("/#{project.path_with_namespace}/blob/master/README.md") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ FactoryGirl.factories.map(&:name).each do |factory_name|
|
|||
next if INVALID_FACTORIES.include?(factory_name)
|
||||
describe "#{factory_name} factory" do
|
||||
it 'should be valid' do
|
||||
build(factory_name).should be_valid
|
||||
expect(build(factory_name)).to be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ describe "Admin::Hooks", feature: true do
|
|||
within ".sidebar-wrapper" do
|
||||
click_on "Hooks"
|
||||
end
|
||||
current_path.should == admin_hooks_path
|
||||
expect(current_path).to eq(admin_hooks_path)
|
||||
end
|
||||
|
||||
it "should have hooks list" do
|
||||
visit admin_hooks_path
|
||||
page.should have_content(@system_hook.url)
|
||||
expect(page).to have_content(@system_hook.url)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,8 +33,8 @@ describe "Admin::Hooks", feature: true do
|
|||
end
|
||||
|
||||
it "should open new hook popup" do
|
||||
current_path.should == admin_hooks_path
|
||||
page.should have_content(@url)
|
||||
expect(current_path).to eq(admin_hooks_path)
|
||||
expect(page).to have_content(@url)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ describe "Admin::Hooks", feature: true do
|
|||
click_link "Test Hook"
|
||||
end
|
||||
|
||||
it { current_path.should == admin_hooks_path }
|
||||
it { expect(current_path).to eq(admin_hooks_path) }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ describe "Admin::Projects", feature: true do
|
|||
end
|
||||
|
||||
it "should be ok" do
|
||||
current_path.should == admin_projects_path
|
||||
expect(current_path).to eq(admin_projects_path)
|
||||
end
|
||||
|
||||
it "should have projects list" do
|
||||
page.should have_content(@project.name)
|
||||
expect(page).to have_content(@project.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -27,8 +27,8 @@ describe "Admin::Projects", feature: true do
|
|||
end
|
||||
|
||||
it "should have project info" do
|
||||
page.should have_content(@project.path)
|
||||
page.should have_content(@project.name)
|
||||
expect(page).to have_content(@project.path)
|
||||
expect(page).to have_content(@project.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ describe "Admin::Users", feature: true do
|
|||
end
|
||||
|
||||
it "should be ok" do
|
||||
current_path.should == admin_users_path
|
||||
expect(current_path).to eq(admin_users_path)
|
||||
end
|
||||
|
||||
it "should have users list" do
|
||||
page.should have_content(@user.email)
|
||||
page.should have_content(@user.name)
|
||||
expect(page).to have_content(@user.email)
|
||||
expect(page).to have_content(@user.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,19 +33,19 @@ describe "Admin::Users", feature: true do
|
|||
it "should apply defaults to user" do
|
||||
click_button "Create user"
|
||||
user = User.find_by(username: 'bang')
|
||||
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
|
||||
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
|
||||
expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit)
|
||||
expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group)
|
||||
end
|
||||
|
||||
it "should create user with valid data" do
|
||||
click_button "Create user"
|
||||
user = User.find_by(username: 'bang')
|
||||
user.name.should == "Big Bang"
|
||||
user.email.should == "bigbang@mail.com"
|
||||
expect(user.name).to eq("Big Bang")
|
||||
expect(user.email).to eq("bigbang@mail.com")
|
||||
end
|
||||
|
||||
it "should call send mail" do
|
||||
Notify.should_receive(:new_user_email)
|
||||
expect(Notify).to receive(:new_user_email)
|
||||
|
||||
click_button "Create user"
|
||||
end
|
||||
|
|
@ -54,9 +54,9 @@ describe "Admin::Users", feature: true do
|
|||
click_button "Create user"
|
||||
user = User.find_by(username: 'bang')
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
email.subject.should have_content("Account was created")
|
||||
email.text_part.body.should have_content(user.email)
|
||||
email.text_part.body.should have_content('password')
|
||||
expect(email.subject).to have_content("Account was created")
|
||||
expect(email.text_part.body).to have_content(user.email)
|
||||
expect(email.text_part.body).to have_content('password')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -67,8 +67,8 @@ describe "Admin::Users", feature: true do
|
|||
end
|
||||
|
||||
it "should have user info" do
|
||||
page.should have_content(@user.email)
|
||||
page.should have_content(@user.name)
|
||||
expect(page).to have_content(@user.email)
|
||||
expect(page).to have_content(@user.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -80,8 +80,8 @@ describe "Admin::Users", feature: true do
|
|||
end
|
||||
|
||||
it "should have user edit page" do
|
||||
page.should have_content("Name")
|
||||
page.should have_content("Password")
|
||||
expect(page).to have_content("Name")
|
||||
expect(page).to have_content("Password")
|
||||
end
|
||||
|
||||
describe "Update user" do
|
||||
|
|
@ -93,14 +93,14 @@ describe "Admin::Users", feature: true do
|
|||
end
|
||||
|
||||
it "should show page with new data" do
|
||||
page.should have_content("bigbang@mail.com")
|
||||
page.should have_content("Big Bang")
|
||||
expect(page).to have_content("bigbang@mail.com")
|
||||
expect(page).to have_content("Big Bang")
|
||||
end
|
||||
|
||||
it "should change user entry" do
|
||||
@simple_user.reload
|
||||
@simple_user.name.should == "Big Bang"
|
||||
@simple_user.is_admin?.should be_true
|
||||
expect(@simple_user.name).to eq("Big Bang")
|
||||
expect(@simple_user.is_admin?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,24 +4,24 @@ describe "Admin::Projects", feature: true do
|
|||
describe "GET /admin/projects" do
|
||||
subject { admin_projects_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /admin/users" do
|
||||
subject { admin_users_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /admin/hooks" do
|
||||
subject { admin_hooks_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ describe "Dashboard Issues Feed", feature: true do
|
|||
it "should render atom feed via private token" do
|
||||
visit issues_dashboard_path(:atom, private_token: user.private_token)
|
||||
|
||||
response_headers['Content-Type'].should have_content("application/atom+xml")
|
||||
body.should have_selector("title", text: "#{user.name} issues")
|
||||
body.should have_selector("author email", text: issue1.author_email)
|
||||
body.should have_selector("entry summary", text: issue1.title)
|
||||
body.should have_selector("author email", text: issue2.author_email)
|
||||
body.should have_selector("entry summary", text: issue2.title)
|
||||
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
|
||||
expect(body).to have_selector("title", text: "#{user.name} issues")
|
||||
expect(body).to have_selector("author email", text: issue1.author_email)
|
||||
expect(body).to have_selector("entry summary", text: issue1.title)
|
||||
expect(body).to have_selector("author email", text: issue2.author_email)
|
||||
expect(body).to have_selector("entry summary", text: issue2.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,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)
|
||||
body.should have_selector("feed title")
|
||||
expect(body).to have_selector("feed title")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -24,11 +24,11 @@ describe "Dashboard Feed", feature: true do
|
|||
end
|
||||
|
||||
it "should have issue opened event" do
|
||||
body.should have_content("#{user.name} opened issue ##{issue.iid}")
|
||||
expect(body).to have_content("#{user.name} opened issue ##{issue.iid}")
|
||||
end
|
||||
|
||||
it "should have issue comment event" do
|
||||
body.should have_content("#{user.name} commented on issue ##{issue.iid}")
|
||||
expect(body).to have_content("#{user.name} commented on issue ##{issue.iid}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ describe "Issues Feed", feature: true do
|
|||
login_with user
|
||||
visit project_issues_path(project, :atom)
|
||||
|
||||
response_headers['Content-Type'].should have_content("application/atom+xml")
|
||||
body.should have_selector("title", text: "#{project.name} issues")
|
||||
body.should have_selector("author email", text: issue.author_email)
|
||||
body.should have_selector("entry summary", text: issue.title)
|
||||
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
|
||||
expect(body).to have_selector("title", text: "#{project.name} issues")
|
||||
expect(body).to have_selector("author email", text: issue.author_email)
|
||||
expect(body).to have_selector("entry summary", text: issue.title)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -24,10 +24,10 @@ describe "Issues Feed", feature: true do
|
|||
it "should render atom feed" do
|
||||
visit project_issues_path(project, :atom, private_token: user.private_token)
|
||||
|
||||
response_headers['Content-Type'].should have_content("application/atom+xml")
|
||||
body.should have_selector("title", text: "#{project.name} issues")
|
||||
body.should have_selector("author email", text: issue.author_email)
|
||||
body.should have_selector("entry summary", text: issue.title)
|
||||
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
|
||||
expect(body).to have_selector("title", text: "#{project.name} issues")
|
||||
expect(body).to have_selector("author email", text: issue.author_email)
|
||||
expect(body).to have_selector("entry summary", text: issue.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ describe "User Feed", feature: true do
|
|||
context "user atom feed via private token" do
|
||||
it "should render user atom feed" do
|
||||
visit user_path(user, :atom, private_token: user.private_token)
|
||||
body.should have_selector("feed title")
|
||||
expect(body).to have_selector("feed title")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -25,25 +25,25 @@ describe "GitLab Flavored Markdown", feature: true do
|
|||
it "should render title in commits#index" do
|
||||
visit project_commits_path(project, 'master', limit: 1)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
|
||||
it "should render title in commits#show" do
|
||||
visit project_commit_path(project, commit)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
|
||||
it "should render description in commits#show" do
|
||||
visit project_commit_path(project, commit)
|
||||
|
||||
page.should have_link("@#{fred.username}")
|
||||
expect(page).to have_link("@#{fred.username}")
|
||||
end
|
||||
|
||||
it "should render title in repositories#branches" do
|
||||
visit project_branches_path(project)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -64,19 +64,19 @@ describe "GitLab Flavored Markdown", feature: true do
|
|||
it "should render subject in issues#index" do
|
||||
visit project_issues_path(project)
|
||||
|
||||
page.should have_link("##{@other_issue.iid}")
|
||||
expect(page).to have_link("##{@other_issue.iid}")
|
||||
end
|
||||
|
||||
it "should render subject in issues#show" do
|
||||
visit project_issue_path(project, @issue)
|
||||
|
||||
page.should have_link("##{@other_issue.iid}")
|
||||
expect(page).to have_link("##{@other_issue.iid}")
|
||||
end
|
||||
|
||||
it "should render details in issues#show" do
|
||||
visit project_issue_path(project, @issue)
|
||||
|
||||
page.should have_link("@#{fred.username}")
|
||||
expect(page).to have_link("@#{fred.username}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -89,13 +89,13 @@ describe "GitLab Flavored Markdown", feature: true do
|
|||
it "should render title in merge_requests#index" do
|
||||
visit project_merge_requests_path(project)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
|
||||
it "should render title in merge_requests#show" do
|
||||
visit project_merge_request_path(project, @merge_request)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -111,19 +111,19 @@ describe "GitLab Flavored Markdown", feature: true do
|
|||
it "should render title in milestones#index" do
|
||||
visit project_milestones_path(project)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
|
||||
it "should render title in milestones#show" do
|
||||
visit project_milestone_path(project, @milestone)
|
||||
|
||||
page.should have_link("##{issue.iid}")
|
||||
expect(page).to have_link("##{issue.iid}")
|
||||
end
|
||||
|
||||
it "should render description in milestones#show" do
|
||||
visit project_milestone_path(project, @milestone)
|
||||
|
||||
page.should have_link("@#{fred.username}")
|
||||
expect(page).to have_link("@#{fred.username}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ describe 'Help Pages', feature: true do
|
|||
end
|
||||
it 'replace the variable $your_email with the email of the user' do
|
||||
visit help_page_path(category: 'ssh', file: 'README.md')
|
||||
page.should have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
|
||||
expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ describe "Issues", feature: true do
|
|||
end
|
||||
|
||||
it "should open new issue popup" do
|
||||
page.should have_content("Issue ##{issue.iid}")
|
||||
expect(page).to have_content("Issue ##{issue.iid}")
|
||||
end
|
||||
|
||||
describe "fill in" do
|
||||
|
|
@ -40,9 +40,9 @@ describe "Issues", feature: true do
|
|||
it "should update issue fields" do
|
||||
click_button "Save changes"
|
||||
|
||||
page.should have_content @user.name
|
||||
page.should have_content "bug 345"
|
||||
page.should have_content project.name
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content "bug 345"
|
||||
expect(page).to have_content project.name
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ describe "Issues", feature: true do
|
|||
it 'allows user to select unasigned', :js => true do
|
||||
visit edit_project_issue_path(project, issue)
|
||||
|
||||
page.should have_content "Assign to #{@user.name}"
|
||||
expect(page).to have_content "Assign to #{@user.name}"
|
||||
|
||||
first('#s2id_issue_assignee_id').click
|
||||
sleep 2 # wait for ajax stuff to complete
|
||||
|
|
@ -67,8 +67,8 @@ describe "Issues", feature: true do
|
|||
|
||||
click_button "Save changes"
|
||||
|
||||
page.should have_content 'Assignee: none'
|
||||
issue.reload.assignee.should be_nil
|
||||
expect(page).to have_content 'Assignee: none'
|
||||
expect(issue.reload.assignee).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -93,33 +93,33 @@ describe "Issues", feature: true do
|
|||
it "should allow filtering by issues with no specified milestone" do
|
||||
visit project_issues_path(project, milestone_id: '0')
|
||||
|
||||
page.should_not have_content 'foobar'
|
||||
page.should have_content 'barbaz'
|
||||
page.should have_content 'gitlab'
|
||||
expect(page).not_to have_content 'foobar'
|
||||
expect(page).to have_content 'barbaz'
|
||||
expect(page).to have_content 'gitlab'
|
||||
end
|
||||
|
||||
it "should allow filtering by a specified milestone" do
|
||||
visit project_issues_path(project, milestone_id: issue.milestone.id)
|
||||
|
||||
page.should have_content 'foobar'
|
||||
page.should_not have_content 'barbaz'
|
||||
page.should_not have_content 'gitlab'
|
||||
expect(page).to have_content 'foobar'
|
||||
expect(page).not_to have_content 'barbaz'
|
||||
expect(page).not_to have_content 'gitlab'
|
||||
end
|
||||
|
||||
it "should allow filtering by issues with no specified assignee" do
|
||||
visit project_issues_path(project, assignee_id: '0')
|
||||
|
||||
page.should have_content 'foobar'
|
||||
page.should_not have_content 'barbaz'
|
||||
page.should_not have_content 'gitlab'
|
||||
expect(page).to have_content 'foobar'
|
||||
expect(page).not_to have_content 'barbaz'
|
||||
expect(page).not_to have_content 'gitlab'
|
||||
end
|
||||
|
||||
it "should allow filtering by a specified assignee" do
|
||||
visit project_issues_path(project, assignee_id: @user.id)
|
||||
|
||||
page.should_not have_content 'foobar'
|
||||
page.should have_content 'barbaz'
|
||||
page.should have_content 'gitlab'
|
||||
expect(page).not_to have_content 'foobar'
|
||||
expect(page).to have_content 'barbaz'
|
||||
expect(page).to have_content 'gitlab'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -134,15 +134,15 @@ describe "Issues", feature: true do
|
|||
it 'sorts by newest' do
|
||||
visit project_issues_path(project, sort: sort_value_recently_created)
|
||||
|
||||
first_issue.should include("foo")
|
||||
last_issue.should include("baz")
|
||||
expect(first_issue).to include("foo")
|
||||
expect(last_issue).to include("baz")
|
||||
end
|
||||
|
||||
it 'sorts by oldest' do
|
||||
visit project_issues_path(project, sort: sort_value_oldest_created)
|
||||
|
||||
first_issue.should include("baz")
|
||||
last_issue.should include("foo")
|
||||
expect(first_issue).to include("baz")
|
||||
expect(last_issue).to include("foo")
|
||||
end
|
||||
|
||||
it 'sorts by most recently updated' do
|
||||
|
|
@ -150,7 +150,7 @@ describe "Issues", feature: true do
|
|||
baz.save
|
||||
visit project_issues_path(project, sort: sort_value_recently_updated)
|
||||
|
||||
first_issue.should include("baz")
|
||||
expect(first_issue).to include("baz")
|
||||
end
|
||||
|
||||
it 'sorts by least recently updated' do
|
||||
|
|
@ -158,7 +158,7 @@ describe "Issues", feature: true do
|
|||
baz.save
|
||||
visit project_issues_path(project, sort: sort_value_oldest_updated)
|
||||
|
||||
first_issue.should include("baz")
|
||||
expect(first_issue).to include("baz")
|
||||
end
|
||||
|
||||
describe 'sorting by milestone' do
|
||||
|
|
@ -172,13 +172,13 @@ describe "Issues", feature: true do
|
|||
it 'sorts by recently due milestone' do
|
||||
visit project_issues_path(project, sort: sort_value_milestone_soon)
|
||||
|
||||
first_issue.should include("foo")
|
||||
expect(first_issue).to include("foo")
|
||||
end
|
||||
|
||||
it 'sorts by least recently due milestone' do
|
||||
visit project_issues_path(project, sort: sort_value_milestone_later)
|
||||
|
||||
first_issue.should include("bar")
|
||||
expect(first_issue).to include("bar")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -195,9 +195,9 @@ describe "Issues", feature: true do
|
|||
it 'sorts with a filter applied' do
|
||||
visit project_issues_path(project, sort: sort_value_oldest_created, assignee_id: user2.id)
|
||||
|
||||
first_issue.should include("bar")
|
||||
last_issue.should include("foo")
|
||||
page.should_not have_content 'baz'
|
||||
expect(first_issue).to include("bar")
|
||||
expect(last_issue).to include("foo")
|
||||
expect(page).not_to have_content 'baz'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -213,7 +213,7 @@ describe "Issues", feature: true do
|
|||
find('.edit-issue.inline-update #issue_assignee_id').set project.team.members.first.id
|
||||
click_button 'Update Issue'
|
||||
|
||||
page.should have_content "Assignee:"
|
||||
expect(page).to have_content "Assignee:"
|
||||
has_select?('issue_assignee_id', :selected => project.team.members.first.name)
|
||||
end
|
||||
end
|
||||
|
|
@ -233,7 +233,7 @@ describe "Issues", feature: true do
|
|||
login_with guest
|
||||
|
||||
visit project_issue_path(project, issue)
|
||||
page.should have_content issue.assignee.name
|
||||
expect(page).to have_content issue.assignee.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -250,8 +250,8 @@ describe "Issues", feature: true do
|
|||
find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id')
|
||||
click_button 'Update Issue'
|
||||
|
||||
page.should have_content "Milestone changed to #{milestone.title}"
|
||||
page.should have_content "Milestone: #{milestone.title}"
|
||||
expect(page).to have_content "Milestone changed to #{milestone.title}"
|
||||
expect(page).to have_content "Milestone: #{milestone.title}"
|
||||
has_select?('issue_assignee_id', :selected => milestone.title)
|
||||
end
|
||||
end
|
||||
|
|
@ -270,7 +270,7 @@ describe "Issues", feature: true do
|
|||
login_with guest
|
||||
|
||||
visit project_issue_path(project, issue)
|
||||
page.should have_content milestone.title
|
||||
expect(page).to have_content milestone.title
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -284,15 +284,15 @@ describe "Issues", feature: true do
|
|||
|
||||
it 'allows user to remove assignee', :js => true do
|
||||
visit project_issue_path(project, issue)
|
||||
page.should have_content "Assignee: #{user2.name}"
|
||||
expect(page).to have_content "Assignee: #{user2.name}"
|
||||
|
||||
first('#s2id_issue_assignee_id').click
|
||||
sleep 2 # wait for ajax stuff to complete
|
||||
first('.user-result').click
|
||||
|
||||
page.should have_content 'Assignee: none'
|
||||
expect(page).to have_content 'Assignee: none'
|
||||
sleep 2 # wait for ajax stuff to complete
|
||||
issue.reload.assignee.should be_nil
|
||||
expect(issue.reload.assignee).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ describe 'Comments' do
|
|||
|
||||
describe "the note form" do
|
||||
it 'should be valid' do
|
||||
should have_css(".js-main-target-form", visible: true, count: 1)
|
||||
find(".js-main-target-form input[type=submit]").value.should == "Add Comment"
|
||||
is_expected.to have_css(".js-main-target-form", visible: true, count: 1)
|
||||
expect(find(".js-main-target-form input[type=submit]").value).to eq("Add Comment")
|
||||
within('.js-main-target-form') do
|
||||
expect(page).not_to have_link('Cancel')
|
||||
end
|
||||
|
|
@ -50,18 +50,18 @@ describe 'Comments' do
|
|||
end
|
||||
|
||||
it 'should be added and form reset' do
|
||||
should have_content("This is awsome!")
|
||||
is_expected.to have_content("This is awsome!")
|
||||
within('.js-main-target-form') do
|
||||
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
|
||||
expect(page).to have_css('.js-md-preview', visible: :hidden)
|
||||
end
|
||||
within(".js-main-target-form") { should have_css(".js-note-text", visible: true) }
|
||||
within(".js-main-target-form") { is_expected.to have_css(".js-note-text", visible: true) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "when editing a note", js: true do
|
||||
it "should contain the hidden edit form" do
|
||||
within("#note_#{note.id}") { should have_css(".note-edit-form", visible: false) }
|
||||
within("#note_#{note.id}") { is_expected.to have_css(".note-edit-form", visible: false) }
|
||||
end
|
||||
|
||||
describe "editing the note" do
|
||||
|
|
@ -72,9 +72,9 @@ describe 'Comments' do
|
|||
|
||||
it "should show the note edit form and hide the note body" do
|
||||
within("#note_#{note.id}") do
|
||||
find(".current-note-edit-form", visible: true).should be_visible
|
||||
find(".note-edit-form", visible: true).should be_visible
|
||||
find(:css, ".note-text", visible: false).should_not be_visible
|
||||
expect(find(".current-note-edit-form", visible: true)).to be_visible
|
||||
expect(find(".note-edit-form", visible: true)).to be_visible
|
||||
expect(find(:css, ".note-text", visible: false)).not_to be_visible
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -94,8 +94,8 @@ describe 'Comments' do
|
|||
end
|
||||
|
||||
within("#note_#{note.id}") do
|
||||
should have_css(".note_edited_ago")
|
||||
find(".note_edited_ago").text.should match(/less than a minute ago/)
|
||||
is_expected.to have_css(".note_edited_ago")
|
||||
expect(find(".note_edited_ago").text).to match(/less than a minute ago/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -108,14 +108,14 @@ describe 'Comments' do
|
|||
|
||||
it "shows the delete link" do
|
||||
within(".note-attachment") do
|
||||
should have_css(".js-note-attachment-delete")
|
||||
is_expected.to have_css(".js-note-attachment-delete")
|
||||
end
|
||||
end
|
||||
|
||||
it "removes the attachment div and resets the edit form" do
|
||||
find(".js-note-attachment-delete").click
|
||||
should_not have_css(".note-attachment")
|
||||
find(".current-note-edit-form", visible: false).should_not be_visible
|
||||
is_expected.not_to have_css(".note-attachment")
|
||||
expect(find(".current-note-edit-form", visible: false)).not_to be_visible
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -138,16 +138,16 @@ describe 'Comments' do
|
|||
end
|
||||
|
||||
describe "the notes holder" do
|
||||
it { should have_css(".js-temp-notes-holder") }
|
||||
it { is_expected.to have_css(".js-temp-notes-holder") }
|
||||
|
||||
it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
|
||||
it { within(".js-temp-notes-holder") { is_expected.to have_css(".new_note") } }
|
||||
end
|
||||
|
||||
describe "the note form" do
|
||||
it "shouldn't add a second form for same row" do
|
||||
click_diff_line
|
||||
|
||||
should have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form", count: 1)
|
||||
is_expected.to have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form", count: 1)
|
||||
end
|
||||
|
||||
it "should be removed when canceled" do
|
||||
|
|
@ -155,7 +155,7 @@ describe 'Comments' do
|
|||
find(".js-close-discussion-note-form").trigger("click")
|
||||
end
|
||||
|
||||
should have_no_css(".js-temp-notes-holder")
|
||||
is_expected.to have_no_css(".js-temp-notes-holder")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -166,7 +166,7 @@ describe 'Comments' do
|
|||
click_diff_line(line_code_2)
|
||||
end
|
||||
|
||||
it { should have_css(".js-temp-notes-holder", count: 2) }
|
||||
it { is_expected.to have_css(".js-temp-notes-holder", count: 2) }
|
||||
|
||||
describe "previewing them separately" do
|
||||
before do
|
||||
|
|
@ -191,10 +191,10 @@ describe 'Comments' do
|
|||
end
|
||||
|
||||
it 'should be added as discussion' do
|
||||
should have_content("Another comment on line 10")
|
||||
should have_css(".notes_holder")
|
||||
should have_css(".notes_holder .note", count: 1)
|
||||
should have_button('Reply')
|
||||
is_expected.to have_content("Another comment on line 10")
|
||||
is_expected.to have_css(".notes_holder")
|
||||
is_expected.to have_css(".notes_holder .note", count: 1)
|
||||
is_expected.to have_button('Reply')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ describe "Profile account page", feature: true do
|
|||
visit profile_account_path
|
||||
end
|
||||
|
||||
it { page.should have_content("Remove account") }
|
||||
it { expect(page).to have_content("Remove account") }
|
||||
|
||||
it "should delete the account" do
|
||||
expect { click_link "Delete account" }.to change {User.count}.by(-1)
|
||||
current_path.should == new_user_session_path
|
||||
expect(current_path).to eq(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ describe "Profile account page", feature: true do
|
|||
end
|
||||
|
||||
it "should not have option to remove account" do
|
||||
page.should_not have_content("Remove account")
|
||||
current_path.should == profile_account_path
|
||||
expect(page).not_to have_content("Remove account")
|
||||
expect(current_path).to eq(profile_account_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ describe "Search", feature: true do
|
|||
end
|
||||
|
||||
it "should show project in search results" do
|
||||
page.should have_content @project.name
|
||||
expect(page).to have_content @project.name
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,52 +4,52 @@ describe "Dashboard access", feature: true do
|
|||
describe "GET /dashboard" do
|
||||
subject { dashboard_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /dashboard/issues" do
|
||||
subject { issues_dashboard_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /dashboard/merge_requests" do
|
||||
subject { merge_requests_dashboard_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /dashboard/projects" do
|
||||
subject { projects_dashboard_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /help" do
|
||||
subject { help_path }
|
||||
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /projects/new" do
|
||||
it { new_project_path.should be_allowed_for :admin }
|
||||
it { new_project_path.should be_allowed_for :user }
|
||||
it { new_project_path.should be_denied_for :visitor }
|
||||
it { expect(new_project_path).to be_allowed_for :admin }
|
||||
it { expect(new_project_path).to be_allowed_for :user }
|
||||
it { expect(new_project_path).to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/new" do
|
||||
it { new_group_path.should be_allowed_for :admin }
|
||||
it { new_group_path.should be_allowed_for :user }
|
||||
it { new_group_path.should be_denied_for :visitor }
|
||||
it { expect(new_group_path).to be_allowed_for :admin }
|
||||
it { expect(new_group_path).to be_allowed_for :user }
|
||||
it { expect(new_group_path).to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ require 'spec_helper'
|
|||
|
||||
describe "Group access", feature: true do
|
||||
describe "GET /projects/new" do
|
||||
it { new_group_path.should be_allowed_for :admin }
|
||||
it { new_group_path.should be_allowed_for :user }
|
||||
it { new_group_path.should be_denied_for :visitor }
|
||||
it { expect(new_group_path).to be_allowed_for :admin }
|
||||
it { expect(new_group_path).to be_allowed_for :user }
|
||||
it { expect(new_group_path).to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "Group" do
|
||||
|
|
@ -26,73 +26,73 @@ describe "Group access", feature: true do
|
|||
describe "GET /groups/:path" do
|
||||
subject { group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/issues" do
|
||||
subject { issues_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/merge_requests" do
|
||||
subject { merge_requests_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/members" do
|
||||
subject { members_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/edit" do
|
||||
subject { edit_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_denied_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_denied_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/projects" do
|
||||
subject { projects_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_denied_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_denied_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,61 +22,61 @@ describe "Group with internal project access", feature: true do
|
|||
describe "GET /groups/:path" do
|
||||
subject { group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/issues" do
|
||||
subject { issues_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/merge_requests" do
|
||||
subject { merge_requests_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/members" do
|
||||
subject { members_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/edit" do
|
||||
subject { edit_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_denied_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_denied_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,61 +23,61 @@ describe "Group access", feature: true do
|
|||
describe "GET /groups/:path" do
|
||||
subject { group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/issues" do
|
||||
subject { issues_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/merge_requests" do
|
||||
subject { merge_requests_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/members" do
|
||||
subject { members_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/edit" do
|
||||
subject { edit_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_denied_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_denied_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,61 +22,61 @@ describe "Group with public project access", feature: true do
|
|||
describe "GET /groups/:path" do
|
||||
subject { group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/issues" do
|
||||
subject { issues_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/merge_requests" do
|
||||
subject { merge_requests_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/members" do
|
||||
subject { members_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /groups/:path/edit" do
|
||||
subject { edit_group_path(group) }
|
||||
|
||||
it { should be_allowed_for owner }
|
||||
it { should be_denied_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for owner }
|
||||
it { is_expected.to be_denied_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,70 +7,70 @@ describe "Users Security", feature: true do
|
|||
end
|
||||
|
||||
describe "GET /login" do
|
||||
it { new_user_session_path.should_not be_404_for :visitor }
|
||||
it { expect(new_user_session_path).not_to be_404_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile/keys" do
|
||||
subject { profile_keys_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile" do
|
||||
subject { profile_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile/account" do
|
||||
subject { profile_account_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile/design" do
|
||||
subject { design_profile_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile/history" do
|
||||
subject { history_profile_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile/notifications" do
|
||||
subject { profile_notifications_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /profile/groups" do
|
||||
subject { profile_groups_path }
|
||||
|
||||
it { should be_allowed_for @u1 }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for @u1 }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,73 +18,76 @@ describe "Internal Project Access", feature: true do
|
|||
describe "Project should be internal" do
|
||||
subject { project }
|
||||
|
||||
its(:internal?) { should be_true }
|
||||
describe '#internal?' do
|
||||
subject { super().internal? }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /:project_path" do
|
||||
subject { project_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/tree/master" do
|
||||
subject { project_tree_path(project, project.repository.root_ref) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/commits/master" do
|
||||
subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/commit/:sha" do
|
||||
subject { project_commit_path(project, project.repository.commit) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/compare" do
|
||||
subject { project_compare_index_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/team" do
|
||||
subject { project_team_index_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/blob" do
|
||||
|
|
@ -94,89 +97,89 @@ describe "Internal Project Access", feature: true do
|
|||
@blob_path = project_blob_path(project, File.join(commit.id, path))
|
||||
end
|
||||
|
||||
it { @blob_path.should be_allowed_for master }
|
||||
it { @blob_path.should be_allowed_for reporter }
|
||||
it { @blob_path.should be_allowed_for :admin }
|
||||
it { @blob_path.should be_allowed_for guest }
|
||||
it { @blob_path.should be_allowed_for :user }
|
||||
it { @blob_path.should be_denied_for :visitor }
|
||||
it { expect(@blob_path).to be_allowed_for master }
|
||||
it { expect(@blob_path).to be_allowed_for reporter }
|
||||
it { expect(@blob_path).to be_allowed_for :admin }
|
||||
it { expect(@blob_path).to be_allowed_for guest }
|
||||
it { expect(@blob_path).to be_allowed_for :user }
|
||||
it { expect(@blob_path).to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/edit" do
|
||||
subject { edit_project_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/deploy_keys" do
|
||||
subject { project_deploy_keys_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/issues" do
|
||||
subject { project_issues_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/snippets" do
|
||||
subject { project_snippets_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/snippets/new" do
|
||||
subject { new_project_snippet_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/merge_requests" do
|
||||
subject { project_merge_requests_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/merge_requests/new" do
|
||||
subject { new_project_merge_request_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/branches" do
|
||||
|
|
@ -184,15 +187,15 @@ describe "Internal Project Access", feature: true do
|
|||
|
||||
before do
|
||||
# Speed increase
|
||||
Project.any_instance.stub(:branches).and_return([])
|
||||
allow_any_instance_of(Project).to receive(:branches).and_return([])
|
||||
end
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/tags" do
|
||||
|
|
@ -200,25 +203,25 @@ describe "Internal Project Access", feature: true do
|
|||
|
||||
before do
|
||||
# Speed increase
|
||||
Project.any_instance.stub(:tags).and_return([])
|
||||
allow_any_instance_of(Project).to receive(:tags).and_return([])
|
||||
end
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/hooks" do
|
||||
subject { project_hooks_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,73 +18,76 @@ describe "Private Project Access", feature: true do
|
|||
describe "Project should be private" do
|
||||
subject { project }
|
||||
|
||||
its(:private?) { should be_true }
|
||||
describe '#private?' do
|
||||
subject { super().private? }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /:project_path" do
|
||||
subject { project_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/tree/master" do
|
||||
subject { project_tree_path(project, project.repository.root_ref) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/commits/master" do
|
||||
subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/commit/:sha" do
|
||||
subject { project_commit_path(project, project.repository.commit) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/compare" do
|
||||
subject { project_compare_index_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/team" do
|
||||
subject { project_team_index_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/blob" do
|
||||
|
|
@ -94,67 +97,67 @@ describe "Private Project Access", feature: true do
|
|||
@blob_path = project_blob_path(project, File.join(commit.id, path))
|
||||
end
|
||||
|
||||
it { @blob_path.should be_allowed_for master }
|
||||
it { @blob_path.should be_allowed_for reporter }
|
||||
it { @blob_path.should be_allowed_for :admin }
|
||||
it { @blob_path.should be_denied_for guest }
|
||||
it { @blob_path.should be_denied_for :user }
|
||||
it { @blob_path.should be_denied_for :visitor }
|
||||
it { expect(@blob_path).to be_allowed_for master }
|
||||
it { expect(@blob_path).to be_allowed_for reporter }
|
||||
it { expect(@blob_path).to be_allowed_for :admin }
|
||||
it { expect(@blob_path).to be_denied_for guest }
|
||||
it { expect(@blob_path).to be_denied_for :user }
|
||||
it { expect(@blob_path).to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/edit" do
|
||||
subject { edit_project_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/deploy_keys" do
|
||||
subject { project_deploy_keys_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/issues" do
|
||||
subject { project_issues_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/snippets" do
|
||||
subject { project_snippets_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/merge_requests" do
|
||||
subject { project_merge_requests_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/branches" do
|
||||
|
|
@ -162,15 +165,15 @@ describe "Private Project Access", feature: true do
|
|||
|
||||
before do
|
||||
# Speed increase
|
||||
Project.any_instance.stub(:branches).and_return([])
|
||||
allow_any_instance_of(Project).to receive(:branches).and_return([])
|
||||
end
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/tags" do
|
||||
|
|
@ -178,25 +181,25 @@ describe "Private Project Access", feature: true do
|
|||
|
||||
before do
|
||||
# Speed increase
|
||||
Project.any_instance.stub(:tags).and_return([])
|
||||
allow_any_instance_of(Project).to receive(:tags).and_return([])
|
||||
end
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/hooks" do
|
||||
subject { project_hooks_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,73 +23,76 @@ describe "Public Project Access", feature: true do
|
|||
describe "Project should be public" do
|
||||
subject { project }
|
||||
|
||||
its(:public?) { should be_true }
|
||||
describe '#public?' do
|
||||
subject { super().public? }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /:project_path" do
|
||||
subject { project_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/tree/master" do
|
||||
subject { project_tree_path(project, project.repository.root_ref) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/commits/master" do
|
||||
subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/commit/:sha" do
|
||||
subject { project_commit_path(project, project.repository.commit) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/compare" do
|
||||
subject { project_compare_index_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/team" do
|
||||
subject { project_team_index_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/blob" do
|
||||
|
|
@ -99,89 +102,89 @@ describe "Public Project Access", feature: true do
|
|||
@blob_path = project_blob_path(project, File.join(commit.id, path))
|
||||
end
|
||||
|
||||
it { @blob_path.should be_allowed_for master }
|
||||
it { @blob_path.should be_allowed_for reporter }
|
||||
it { @blob_path.should be_allowed_for :admin }
|
||||
it { @blob_path.should be_allowed_for guest }
|
||||
it { @blob_path.should be_allowed_for :user }
|
||||
it { @blob_path.should be_allowed_for :visitor }
|
||||
it { expect(@blob_path).to be_allowed_for master }
|
||||
it { expect(@blob_path).to be_allowed_for reporter }
|
||||
it { expect(@blob_path).to be_allowed_for :admin }
|
||||
it { expect(@blob_path).to be_allowed_for guest }
|
||||
it { expect(@blob_path).to be_allowed_for :user }
|
||||
it { expect(@blob_path).to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/edit" do
|
||||
subject { edit_project_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/deploy_keys" do
|
||||
subject { project_deploy_keys_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/issues" do
|
||||
subject { project_issues_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/snippets" do
|
||||
subject { project_snippets_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/snippets/new" do
|
||||
subject { new_project_snippet_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/merge_requests" do
|
||||
subject { project_merge_requests_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/merge_requests/new" do
|
||||
subject { new_project_merge_request_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/branches" do
|
||||
|
|
@ -189,15 +192,15 @@ describe "Public Project Access", feature: true do
|
|||
|
||||
before do
|
||||
# Speed increase
|
||||
Project.any_instance.stub(:branches).and_return([])
|
||||
allow_any_instance_of(Project).to receive(:branches).and_return([])
|
||||
end
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/tags" do
|
||||
|
|
@ -205,25 +208,25 @@ describe "Public Project Access", feature: true do
|
|||
|
||||
before do
|
||||
# Speed increase
|
||||
Project.any_instance.stub(:tags).and_return([])
|
||||
allow_any_instance_of(Project).to receive(:tags).and_return([])
|
||||
end
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_allowed_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_allowed_for guest }
|
||||
it { should be_allowed_for :user }
|
||||
it { should be_allowed_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_allowed_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_allowed_for guest }
|
||||
it { is_expected.to be_allowed_for :user }
|
||||
it { is_expected.to be_allowed_for :visitor }
|
||||
end
|
||||
|
||||
describe "GET /:project_path/hooks" do
|
||||
subject { project_hooks_path(project) }
|
||||
|
||||
it { should be_allowed_for master }
|
||||
it { should be_denied_for reporter }
|
||||
it { should be_allowed_for :admin }
|
||||
it { should be_denied_for guest }
|
||||
it { should be_denied_for :user }
|
||||
it { should be_denied_for :visitor }
|
||||
it { is_expected.to be_allowed_for master }
|
||||
it { is_expected.to be_denied_for reporter }
|
||||
it { is_expected.to be_allowed_for :admin }
|
||||
it { is_expected.to be_denied_for guest }
|
||||
it { is_expected.to be_denied_for :user }
|
||||
it { is_expected.to be_denied_for :visitor }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,40 +27,40 @@ describe IssuesFinder do
|
|||
it 'should filter by all' do
|
||||
params = { scope: "all", state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(user, params)
|
||||
issues.size.should == 3
|
||||
expect(issues.size).to eq(3)
|
||||
end
|
||||
|
||||
it 'should filter by assignee id' do
|
||||
params = { scope: "all", assignee_id: user.id, state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(user, params)
|
||||
issues.size.should == 2
|
||||
expect(issues.size).to eq(2)
|
||||
end
|
||||
|
||||
it 'should filter by author id' do
|
||||
params = { scope: "all", author_id: user2.id, state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(user, params)
|
||||
issues.should == [issue3]
|
||||
expect(issues).to eq([issue3])
|
||||
end
|
||||
|
||||
it 'should filter by milestone id' do
|
||||
params = { scope: "all", milestone_id: milestone.id, state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(user, params)
|
||||
issues.should == [issue1]
|
||||
expect(issues).to eq([issue1])
|
||||
end
|
||||
|
||||
it 'should be empty for unauthorized user' do
|
||||
params = { scope: "all", state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(nil, params)
|
||||
issues.size.should be_zero
|
||||
expect(issues.size).to be_zero
|
||||
end
|
||||
|
||||
it 'should not include unauthorized issues' do
|
||||
params = { scope: "all", state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(user2, params)
|
||||
issues.size.should == 2
|
||||
issues.should_not include(issue1)
|
||||
issues.should include(issue2)
|
||||
issues.should include(issue3)
|
||||
expect(issues.size).to eq(2)
|
||||
expect(issues).not_to include(issue1)
|
||||
expect(issues).to include(issue2)
|
||||
expect(issues).to include(issue3)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -68,13 +68,13 @@ describe IssuesFinder do
|
|||
it 'should filter by assignee' do
|
||||
params = { scope: "assigned-to-me", state: 'opened' }
|
||||
issues = IssuesFinder.new.execute(user, params)
|
||||
issues.size.should == 2
|
||||
expect(issues.size).to eq(2)
|
||||
end
|
||||
|
||||
it 'should filter by project' do
|
||||
params = { scope: "assigned-to-me", state: 'opened', project_id: project1.id }
|
||||
issues = IssuesFinder.new.execute(user, params)
|
||||
issues.size.should == 1
|
||||
expect(issues.size).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ describe MergeRequestsFinder do
|
|||
it 'should filter by scope' do
|
||||
params = { scope: 'authored', state: 'opened' }
|
||||
merge_requests = MergeRequestsFinder.new.execute(user, params)
|
||||
merge_requests.size.should == 2
|
||||
expect(merge_requests.size).to eq(2)
|
||||
end
|
||||
|
||||
it 'should filter by project' do
|
||||
params = { project_id: project1.id, scope: 'authored', state: 'opened' }
|
||||
merge_requests = MergeRequestsFinder.new.execute(user, params)
|
||||
merge_requests.size.should == 1
|
||||
expect(merge_requests.size).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe NotesFinder do
|
|||
|
||||
it 'should find all notes' do
|
||||
notes = NotesFinder.new.execute(project, user, params)
|
||||
notes.size.should eq(2)
|
||||
expect(notes.size).to eq(2)
|
||||
end
|
||||
|
||||
it 'should raise an exception for an invalid target_type' do
|
||||
|
|
@ -32,7 +32,7 @@ describe NotesFinder do
|
|||
it 'filters out old notes' do
|
||||
note2.update_attribute(:updated_at, 2.hours.ago)
|
||||
notes = NotesFinder.new.execute(project, user, params)
|
||||
notes.should eq([note1])
|
||||
expect(notes).to eq([note1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ describe ProjectsFinder do
|
|||
context 'non authenticated' do
|
||||
subject { ProjectsFinder.new.execute(nil, group: group) }
|
||||
|
||||
it { should include(project1) }
|
||||
it { should_not include(project2) }
|
||||
it { should_not include(project3) }
|
||||
it { should_not include(project4) }
|
||||
it { is_expected.to include(project1) }
|
||||
it { is_expected.not_to include(project2) }
|
||||
it { is_expected.not_to include(project3) }
|
||||
it { is_expected.not_to include(project4) }
|
||||
end
|
||||
|
||||
context 'authenticated' do
|
||||
subject { ProjectsFinder.new.execute(user, group: group) }
|
||||
|
||||
it { should include(project1) }
|
||||
it { should include(project2) }
|
||||
it { should_not include(project3) }
|
||||
it { should_not include(project4) }
|
||||
it { is_expected.to include(project1) }
|
||||
it { is_expected.to include(project2) }
|
||||
it { is_expected.not_to include(project3) }
|
||||
it { is_expected.not_to include(project4) }
|
||||
end
|
||||
|
||||
context 'authenticated, project member' do
|
||||
|
|
@ -32,10 +32,10 @@ describe ProjectsFinder do
|
|||
|
||||
subject { ProjectsFinder.new.execute(user, group: group) }
|
||||
|
||||
it { should include(project1) }
|
||||
it { should include(project2) }
|
||||
it { should include(project3) }
|
||||
it { should_not include(project4) }
|
||||
it { is_expected.to include(project1) }
|
||||
it { is_expected.to include(project2) }
|
||||
it { is_expected.to include(project3) }
|
||||
it { is_expected.not_to include(project4) }
|
||||
end
|
||||
|
||||
context 'authenticated, group member' do
|
||||
|
|
@ -43,9 +43,9 @@ describe ProjectsFinder do
|
|||
|
||||
subject { ProjectsFinder.new.execute(user, group: group) }
|
||||
|
||||
it { should include(project1) }
|
||||
it { should include(project2) }
|
||||
it { should include(project3) }
|
||||
it { should include(project4) }
|
||||
it { is_expected.to include(project1) }
|
||||
it { is_expected.to include(project2) }
|
||||
it { is_expected.to include(project3) }
|
||||
it { is_expected.to include(project4) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ describe SnippetsFinder do
|
|||
|
||||
it "returns all private and internal snippets" do
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :all)
|
||||
snippets.should include(@snippet2, @snippet3)
|
||||
snippets.should_not include(@snippet1)
|
||||
expect(snippets).to include(@snippet2, @snippet3)
|
||||
expect(snippets).not_to include(@snippet1)
|
||||
end
|
||||
|
||||
it "returns all public snippets" do
|
||||
snippets = SnippetsFinder.new.execute(nil, filter: :all)
|
||||
snippets.should include(@snippet3)
|
||||
snippets.should_not include(@snippet1, @snippet2)
|
||||
expect(snippets).to include(@snippet3)
|
||||
expect(snippets).not_to include(@snippet1, @snippet2)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -38,37 +38,37 @@ describe SnippetsFinder do
|
|||
|
||||
it "returns all public and internal snippets" do
|
||||
snippets = SnippetsFinder.new.execute(user1, filter: :by_user, user: user)
|
||||
snippets.should include(@snippet2, @snippet3)
|
||||
snippets.should_not include(@snippet1)
|
||||
expect(snippets).to include(@snippet2, @snippet3)
|
||||
expect(snippets).not_to include(@snippet1)
|
||||
end
|
||||
|
||||
it "returns internal snippets" do
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_internal")
|
||||
snippets.should include(@snippet2)
|
||||
snippets.should_not include(@snippet1, @snippet3)
|
||||
expect(snippets).to include(@snippet2)
|
||||
expect(snippets).not_to include(@snippet1, @snippet3)
|
||||
end
|
||||
|
||||
it "returns private snippets" do
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_private")
|
||||
snippets.should include(@snippet1)
|
||||
snippets.should_not include(@snippet2, @snippet3)
|
||||
expect(snippets).to include(@snippet1)
|
||||
expect(snippets).not_to include(@snippet2, @snippet3)
|
||||
end
|
||||
|
||||
it "returns public snippets" do
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_public")
|
||||
snippets.should include(@snippet3)
|
||||
snippets.should_not include(@snippet1, @snippet2)
|
||||
expect(snippets).to include(@snippet3)
|
||||
expect(snippets).not_to include(@snippet1, @snippet2)
|
||||
end
|
||||
|
||||
it "returns all snippets" do
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user)
|
||||
snippets.should include(@snippet1, @snippet2, @snippet3)
|
||||
expect(snippets).to include(@snippet1, @snippet2, @snippet3)
|
||||
end
|
||||
|
||||
it "returns only public snippets if unauthenticated user" do
|
||||
snippets = SnippetsFinder.new.execute(nil, filter: :by_user, user: user)
|
||||
snippets.should include(@snippet3)
|
||||
snippets.should_not include(@snippet2, @snippet1)
|
||||
expect(snippets).to include(@snippet3)
|
||||
expect(snippets).not_to include(@snippet2, @snippet1)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -82,20 +82,20 @@ describe SnippetsFinder do
|
|||
|
||||
it "returns public snippets for unauthorized user" do
|
||||
snippets = SnippetsFinder.new.execute(nil, filter: :by_project, project: project1)
|
||||
snippets.should include(@snippet3)
|
||||
snippets.should_not include(@snippet1, @snippet2)
|
||||
expect(snippets).to include(@snippet3)
|
||||
expect(snippets).not_to include(@snippet1, @snippet2)
|
||||
end
|
||||
|
||||
it "returns public and internal snippets for none project members" do
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1)
|
||||
snippets.should include(@snippet2, @snippet3)
|
||||
snippets.should_not include(@snippet1)
|
||||
expect(snippets).to include(@snippet2, @snippet3)
|
||||
expect(snippets).not_to include(@snippet1)
|
||||
end
|
||||
|
||||
it "returns all snippets for project members" do
|
||||
project1.team << [user, :developer]
|
||||
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1)
|
||||
snippets.should include(@snippet1, @snippet2, @snippet3)
|
||||
expect(snippets).to include(@snippet1, @snippet2, @snippet3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@ require 'spec_helper'
|
|||
describe ApplicationHelper do
|
||||
describe 'current_controller?' do
|
||||
before do
|
||||
controller.stub(:controller_name).and_return('foo')
|
||||
allow(controller).to receive(:controller_name).and_return('foo')
|
||||
end
|
||||
|
||||
it 'returns true when controller matches argument' do
|
||||
current_controller?(:foo).should be_true
|
||||
expect(current_controller?(:foo)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false when controller does not match argument' do
|
||||
current_controller?(:bar).should_not be_true
|
||||
expect(current_controller?(:bar)).not_to be_truthy
|
||||
end
|
||||
|
||||
it 'should take any number of arguments' do
|
||||
current_controller?(:baz, :bar).should_not be_true
|
||||
current_controller?(:baz, :bar, :foo).should be_true
|
||||
expect(current_controller?(:baz, :bar)).not_to be_truthy
|
||||
expect(current_controller?(:baz, :bar, :foo)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -26,16 +26,16 @@ describe ApplicationHelper do
|
|||
end
|
||||
|
||||
it 'returns true when action matches argument' do
|
||||
current_action?(:foo).should be_true
|
||||
expect(current_action?(:foo)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false when action does not match argument' do
|
||||
current_action?(:bar).should_not be_true
|
||||
expect(current_action?(:bar)).not_to be_truthy
|
||||
end
|
||||
|
||||
it 'should take any number of arguments' do
|
||||
current_action?(:baz, :bar).should_not be_true
|
||||
current_action?(:baz, :bar, :foo).should be_true
|
||||
expect(current_action?(:baz, :bar)).not_to be_truthy
|
||||
expect(current_action?(:baz, :bar, :foo)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ describe ApplicationHelper do
|
|||
group = create(:group)
|
||||
group.avatar = File.open(avatar_file_path)
|
||||
group.save!
|
||||
group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
|
||||
expect(group_icon(group.path).to_s).to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
|
||||
end
|
||||
|
||||
it 'should give default avatar_icon when no avatar is present' do
|
||||
group = create(:group)
|
||||
group.save!
|
||||
group_icon(group.path).should match('group_avatar.png')
|
||||
expect(group_icon(group.path)).to match('group_avatar.png')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -63,17 +63,18 @@ describe ApplicationHelper do
|
|||
project = create(:project)
|
||||
project.avatar = File.open(avatar_file_path)
|
||||
project.save!
|
||||
project_icon(project.to_param).to_s.should ==
|
||||
expect(project_icon(project.to_param).to_s).to eq(
|
||||
"<img alt=\"Gitlab logo\" src=\"/uploads/project/avatar/#{ project.id }/gitlab_logo.png\" />"
|
||||
)
|
||||
end
|
||||
|
||||
it 'should give uploaded icon when present' do
|
||||
project = create(:project)
|
||||
project.save!
|
||||
|
||||
Project.any_instance.stub(:avatar_in_git).and_return(true)
|
||||
allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true)
|
||||
|
||||
project_icon(project.to_param).to_s.should match(
|
||||
expect(project_icon(project.to_param).to_s).to match(
|
||||
image_tag(project_avatar_path(project)))
|
||||
end
|
||||
end
|
||||
|
|
@ -85,7 +86,7 @@ describe ApplicationHelper do
|
|||
user = create(:user)
|
||||
user.avatar = File.open(avatar_file_path)
|
||||
user.save!
|
||||
avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
|
||||
expect(avatar_icon(user.email).to_s).to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
|
||||
end
|
||||
|
||||
it 'should return an url for the avatar with relative url' do
|
||||
|
|
@ -95,13 +96,13 @@ describe ApplicationHelper do
|
|||
user = create(:user)
|
||||
user.avatar = File.open(avatar_file_path)
|
||||
user.save!
|
||||
avatar_icon(user.email).to_s.should match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
|
||||
expect(avatar_icon(user.email).to_s).to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
|
||||
end
|
||||
|
||||
it 'should call gravatar_icon when no avatar is present' do
|
||||
user = create(:user, email: 'test@example.com')
|
||||
user.save!
|
||||
avatar_icon(user.email).to_s.should == 'http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon'
|
||||
expect(avatar_icon(user.email).to_s).to eq('http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -110,42 +111,42 @@ describe ApplicationHelper do
|
|||
|
||||
it 'should return a generic avatar path when Gravatar is disabled' do
|
||||
ApplicationSetting.any_instance.stub(gravatar_enabled?: false)
|
||||
gravatar_icon(user_email).should match('no_avatar.png')
|
||||
expect(gravatar_icon(user_email)).to match('no_avatar.png')
|
||||
end
|
||||
|
||||
it 'should return a generic avatar path when email is blank' do
|
||||
gravatar_icon('').should match('no_avatar.png')
|
||||
expect(gravatar_icon('')).to match('no_avatar.png')
|
||||
end
|
||||
|
||||
it 'should return default gravatar url' do
|
||||
Gitlab.config.gitlab.stub(https: false)
|
||||
gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
|
||||
expect(gravatar_icon(user_email)).to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
|
||||
end
|
||||
|
||||
it 'should use SSL when appropriate' do
|
||||
Gitlab.config.gitlab.stub(https: true)
|
||||
gravatar_icon(user_email).should match('https://secure.gravatar.com')
|
||||
expect(gravatar_icon(user_email)).to match('https://secure.gravatar.com')
|
||||
end
|
||||
|
||||
it 'should return custom gravatar path when gravatar_url is set' do
|
||||
allow(self).to receive(:request).and_return(double(:ssl? => false))
|
||||
Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
|
||||
gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
|
||||
allow(Gitlab.config.gravatar).to receive(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
|
||||
expect(gravatar_icon(user_email, 20)).to eq('http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118')
|
||||
end
|
||||
|
||||
it 'should accept a custom size' do
|
||||
allow(self).to receive(:request).and_return(double(:ssl? => false))
|
||||
gravatar_icon(user_email, 64).should match(/\?s=64/)
|
||||
expect(gravatar_icon(user_email, 64)).to match(/\?s=64/)
|
||||
end
|
||||
|
||||
it 'should use default size when size is wrong' do
|
||||
allow(self).to receive(:request).and_return(double(:ssl? => false))
|
||||
gravatar_icon(user_email, nil).should match(/\?s=40/)
|
||||
expect(gravatar_icon(user_email, nil)).to match(/\?s=40/)
|
||||
end
|
||||
|
||||
it 'should be case insensitive' do
|
||||
allow(self).to receive(:request).and_return(double(:ssl? => false))
|
||||
gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + ' ')
|
||||
expect(gravatar_icon(user_email)).to eq(gravatar_icon(user_email.upcase + ' '))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -163,28 +164,28 @@ describe ApplicationHelper do
|
|||
end
|
||||
|
||||
it 'includes a list of branch names' do
|
||||
options[0][0].should == 'Branches'
|
||||
options[0][1].should include('master', 'feature')
|
||||
expect(options[0][0]).to eq('Branches')
|
||||
expect(options[0][1]).to include('master', 'feature')
|
||||
end
|
||||
|
||||
it 'includes a list of tag names' do
|
||||
options[1][0].should == 'Tags'
|
||||
options[1][1].should include('v1.0.0','v1.1.0')
|
||||
expect(options[1][0]).to eq('Tags')
|
||||
expect(options[1][1]).to include('v1.0.0','v1.1.0')
|
||||
end
|
||||
|
||||
it 'includes a specific commit ref if defined' do
|
||||
# Must be an instance variable
|
||||
@ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
|
||||
|
||||
options[2][0].should == 'Commit'
|
||||
options[2][1].should == [@ref]
|
||||
expect(options[2][0]).to eq('Commit')
|
||||
expect(options[2][1]).to eq([@ref])
|
||||
end
|
||||
|
||||
it 'sorts tags in a natural order' do
|
||||
# Stub repository.tag_names to make sure we get some valid testing data
|
||||
expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
|
||||
|
||||
options[1][1].should == ['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9']
|
||||
expect(options[1][1]).to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -192,7 +193,7 @@ describe ApplicationHelper do
|
|||
context 'with current_user is nil' do
|
||||
it 'should return a string' do
|
||||
allow(self).to receive(:current_user).and_return(nil)
|
||||
user_color_scheme_class.should be_kind_of(String)
|
||||
expect(user_color_scheme_class).to be_kind_of(String)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ describe ApplicationHelper do
|
|||
it 'should return a string' do
|
||||
current_user = double(:color_scheme_id => color_scheme_id)
|
||||
allow(self).to receive(:current_user).and_return(current_user)
|
||||
user_color_scheme_class.should be_kind_of(String)
|
||||
expect(user_color_scheme_class).to be_kind_of(String)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -213,17 +214,17 @@ describe ApplicationHelper do
|
|||
let(:a_tag) { '<a href="#">Foo</a>' }
|
||||
|
||||
it 'allows the a tag' do
|
||||
simple_sanitize(a_tag).should == a_tag
|
||||
expect(simple_sanitize(a_tag)).to eq(a_tag)
|
||||
end
|
||||
|
||||
it 'allows the span tag' do
|
||||
input = '<span class="foo">Bar</span>'
|
||||
simple_sanitize(input).should == input
|
||||
expect(simple_sanitize(input)).to eq(input)
|
||||
end
|
||||
|
||||
it 'disallows other tags' do
|
||||
input = "<strike><b>#{a_tag}</b></strike>"
|
||||
simple_sanitize(input).should == a_tag
|
||||
expect(simple_sanitize(input)).to eq(a_tag)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -254,7 +255,7 @@ describe ApplicationHelper do
|
|||
let(:content) { 'Noël' }
|
||||
|
||||
it 'should preserve encoding' do
|
||||
content.encoding.name.should == 'UTF-8'
|
||||
expect(content.encoding.name).to eq('UTF-8')
|
||||
expect(render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe BroadcastMessagesHelper do
|
|||
|
||||
context "default style" do
|
||||
it "should have no style" do
|
||||
broadcast_styling(broadcast_message).should match('')
|
||||
expect(broadcast_styling(broadcast_message)).to match('')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ describe BroadcastMessagesHelper do
|
|||
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
|
||||
|
||||
it "should have a customized style" do
|
||||
broadcast_styling(broadcast_message).should match('background-color:#f2dede;color:#b94a48')
|
||||
expect(broadcast_styling(broadcast_message)).to match('background-color:#f2dede;color:#b94a48')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,58 +10,58 @@ describe DiffHelper do
|
|||
|
||||
describe 'diff_hard_limit_enabled?' do
|
||||
it 'should return true if param is provided' do
|
||||
controller.stub(:params).and_return { { :force_show_diff => true } }
|
||||
diff_hard_limit_enabled?.should be_true
|
||||
allow(controller).to receive(:params) { { :force_show_diff => true } }
|
||||
expect(diff_hard_limit_enabled?).to be_truthy
|
||||
end
|
||||
|
||||
it 'should return false if param is not provided' do
|
||||
diff_hard_limit_enabled?.should be_false
|
||||
expect(diff_hard_limit_enabled?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe 'allowed_diff_size' do
|
||||
it 'should return hard limit for a diff if force diff is true' do
|
||||
controller.stub(:params).and_return { { :force_show_diff => true } }
|
||||
allowed_diff_size.should eq(1000)
|
||||
allow(controller).to receive(:params) { { :force_show_diff => true } }
|
||||
expect(allowed_diff_size).to eq(1000)
|
||||
end
|
||||
|
||||
it 'should return safe limit for a diff if force diff is false' do
|
||||
allowed_diff_size.should eq(100)
|
||||
expect(allowed_diff_size).to eq(100)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'parallel_diff' do
|
||||
it 'should return an array of arrays containing the parsed diff' do
|
||||
parallel_diff(diff_file, 0).should match_array(parallel_diff_result_array)
|
||||
expect(parallel_diff(diff_file, 0)).to match_array(parallel_diff_result_array)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'generate_line_code' do
|
||||
it 'should generate correct line code' do
|
||||
generate_line_code(diff_file.file_path, diff_file.diff_lines.first).should == '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6'
|
||||
expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'unfold_bottom_class' do
|
||||
it 'should return empty string when bottom line shouldnt be unfolded' do
|
||||
unfold_bottom_class(false).should == ''
|
||||
expect(unfold_bottom_class(false)).to eq('')
|
||||
end
|
||||
|
||||
it 'should return js class when bottom lines should be unfolded' do
|
||||
unfold_bottom_class(true).should == 'js-unfold-bottom'
|
||||
expect(unfold_bottom_class(true)).to eq('js-unfold-bottom')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'diff_line_content' do
|
||||
|
||||
it 'should return non breaking space when line is empty' do
|
||||
diff_line_content(nil).should eq(" ")
|
||||
expect(diff_line_content(nil)).to eq(" ")
|
||||
end
|
||||
|
||||
it 'should return the line itself' do
|
||||
diff_line_content(diff_file.diff_lines.first.text).should eq("@@ -6,12 +6,18 @@ module Popen")
|
||||
diff_line_content(diff_file.diff_lines.first.type).should eq("match")
|
||||
diff_line_content(diff_file.diff_lines.first.new_pos).should eq(6)
|
||||
expect(diff_line_content(diff_file.diff_lines.first.text)).to eq("@@ -6,12 +6,18 @@ module Popen")
|
||||
expect(diff_line_content(diff_file.diff_lines.first.type)).to eq("match")
|
||||
expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -30,26 +30,26 @@ describe GitlabMarkdownHelper do
|
|||
it "should return unaltered text if project is nil" do
|
||||
actual = "Testing references: ##{issue.iid}"
|
||||
|
||||
gfm(actual).should_not == actual
|
||||
expect(gfm(actual)).not_to eq(actual)
|
||||
|
||||
@project = nil
|
||||
gfm(actual).should == actual
|
||||
expect(gfm(actual)).to eq(actual)
|
||||
end
|
||||
|
||||
it "should not alter non-references" do
|
||||
actual = expected = "_Please_ *stop* 'helping' and all the other b*$#%' you do."
|
||||
gfm(actual).should == expected
|
||||
expect(gfm(actual)).to eq(expected)
|
||||
end
|
||||
|
||||
it "should not touch HTML entities" do
|
||||
@project.issues.stub(:where).with(id: '39').and_return([issue])
|
||||
allow(@project.issues).to receive(:where).with(id: '39').and_return([issue])
|
||||
actual = 'We'll accept good pull requests.'
|
||||
gfm(actual).should == "We'll accept good pull requests."
|
||||
expect(gfm(actual)).to eq("We'll accept good pull requests.")
|
||||
end
|
||||
|
||||
it "should forward HTML options to links" do
|
||||
gfm("Fixed in #{commit.id}", @project, class: 'foo').
|
||||
should have_selector('a.gfm.foo')
|
||||
expect(gfm("Fixed in #{commit.id}", @project, class: 'foo')).
|
||||
to have_selector('a.gfm.foo')
|
||||
end
|
||||
|
||||
describe "referencing a commit" do
|
||||
|
|
@ -57,38 +57,38 @@ describe GitlabMarkdownHelper do
|
|||
|
||||
it "should link using a full id" do
|
||||
actual = "Reverts #{commit.id}"
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link using a short id" do
|
||||
actual = "Backported from #{commit.short_id}"
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link with adjacent text" do
|
||||
actual = "Reverted (see #{commit.id})"
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should keep whitespace intact" do
|
||||
actual = "Changes #{commit.id} dramatically"
|
||||
expected = /Changes <a.+>#{commit.id}<\/a> dramatically/
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not link with an invalid id" do
|
||||
actual = expected = "What happened in #{commit.id.reverse}"
|
||||
gfm(actual).should == expected
|
||||
expect(gfm(actual)).to eq(expected)
|
||||
end
|
||||
|
||||
it "should include a title attribute" do
|
||||
actual = "Reverts #{commit.id}"
|
||||
gfm(actual).should match(/title="#{commit.link_title}"/)
|
||||
expect(gfm(actual)).to match(/title="#{commit.link_title}"/)
|
||||
end
|
||||
|
||||
it "should include standard gfm classes" do
|
||||
actual = "Reverts #{commit.id}"
|
||||
gfm(actual).should match(/class="\s?gfm gfm-commit\s?"/)
|
||||
expect(gfm(actual)).to match(/class="\s?gfm gfm-commit\s?"/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -101,37 +101,37 @@ describe GitlabMarkdownHelper do
|
|||
end
|
||||
|
||||
it "should link using a simple name" do
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link using a name with dots" do
|
||||
user.update_attributes(name: "alphA.Beta")
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link using name with underscores" do
|
||||
user.update_attributes(name: "ping_pong_king")
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link with adjacent text" do
|
||||
actual = "Mail the admin (@#{user.username})"
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should keep whitespace intact" do
|
||||
actual = "Yes, @#{user.username} is right."
|
||||
expected = /Yes, <a.+>@#{user.username}<\/a> is right/
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not link with an invalid id" do
|
||||
actual = expected = "@#{user.username.reverse} you are right."
|
||||
gfm(actual).should == expected
|
||||
expect(gfm(actual)).to eq(expected)
|
||||
end
|
||||
|
||||
it "should include standard gfm classes" do
|
||||
gfm(actual).should match(/class="\s?gfm gfm-team_member\s?"/)
|
||||
expect(gfm(actual)).to match(/class="\s?gfm gfm-team_member\s?"/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -148,37 +148,37 @@ describe GitlabMarkdownHelper do
|
|||
let(:expected) { polymorphic_path([project, object]) }
|
||||
|
||||
it "should link using a valid id" do
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link with adjacent text" do
|
||||
# Wrap the reference in parenthesis
|
||||
gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
|
||||
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
|
||||
|
||||
# Append some text to the end of the reference
|
||||
gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
|
||||
expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
|
||||
end
|
||||
|
||||
it "should keep whitespace intact" do
|
||||
actual = "Referenced #{reference} already."
|
||||
expected = /Referenced <a.+>[^\s]+<\/a> already/
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not link with an invalid id" do
|
||||
# Modify the reference string so it's still parsed, but is invalid
|
||||
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
|
||||
gfm(actual).should == actual
|
||||
expect(gfm(actual)).to eq(actual)
|
||||
end
|
||||
|
||||
it "should include a title attribute" do
|
||||
title = "#{object.class.to_s.titlecase}: #{object.title}"
|
||||
gfm(actual).should match(/title="#{title}"/)
|
||||
expect(gfm(actual)).to match(/title="#{title}"/)
|
||||
end
|
||||
|
||||
it "should include standard gfm classes" do
|
||||
css = object.class.to_s.underscore
|
||||
gfm(actual).should match(/class="\s?gfm gfm-#{css}\s?"/)
|
||||
expect(gfm(actual)).to match(/class="\s?gfm gfm-#{css}\s?"/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -204,19 +204,19 @@ describe GitlabMarkdownHelper do
|
|||
end
|
||||
|
||||
it 'should link using a valid id' do
|
||||
gfm(actual).should match(
|
||||
expect(gfm(actual)).to match(
|
||||
/#{expected}.*#{Regexp.escape(full_reference)}/
|
||||
)
|
||||
end
|
||||
|
||||
it 'should link with adjacent text' do
|
||||
# Wrap the reference in parenthesis
|
||||
gfm(actual.gsub(full_reference, "(#{full_reference})")).should(
|
||||
expect(gfm(actual.gsub(full_reference, "(#{full_reference})"))).to(
|
||||
match(expected)
|
||||
)
|
||||
|
||||
# Append some text to the end of the reference
|
||||
gfm(actual.gsub(full_reference, "#{full_reference}, right?")).should(
|
||||
expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).to(
|
||||
match(expected)
|
||||
)
|
||||
end
|
||||
|
|
@ -224,7 +224,7 @@ describe GitlabMarkdownHelper do
|
|||
it 'should keep whitespace intact' do
|
||||
actual = "Referenced #{full_reference} already."
|
||||
expected = /Referenced <a.+>[^\s]+<\/a> already/
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it 'should not link with an invalid id' do
|
||||
|
|
@ -234,7 +234,7 @@ describe GitlabMarkdownHelper do
|
|||
else
|
||||
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
|
||||
end
|
||||
gfm(actual).should == actual
|
||||
expect(gfm(actual)).to eq(actual)
|
||||
end
|
||||
|
||||
it 'should include a title attribute' do
|
||||
|
|
@ -243,12 +243,12 @@ describe GitlabMarkdownHelper do
|
|||
else
|
||||
title = "#{object.class.to_s.titlecase}: #{object.title}"
|
||||
end
|
||||
gfm(actual).should match(/title="#{title}"/)
|
||||
expect(gfm(actual)).to match(/title="#{title}"/)
|
||||
end
|
||||
|
||||
it 'should include standard gfm classes' do
|
||||
css = object.class.to_s.underscore
|
||||
gfm(actual).should match(/class="\s?gfm gfm-#{css}\s?"/)
|
||||
expect(gfm(actual)).to match(/class="\s?gfm gfm-#{css}\s?"/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -307,36 +307,36 @@ describe GitlabMarkdownHelper do
|
|||
end
|
||||
|
||||
it "should link using a valid id" do
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link with adjacent text" do
|
||||
# Wrap the reference in parenthesis
|
||||
gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
|
||||
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
|
||||
|
||||
# Append some text to the end of the reference
|
||||
gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
|
||||
expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
|
||||
end
|
||||
|
||||
it "should keep whitespace intact" do
|
||||
actual = "Referenced #{reference} already."
|
||||
expected = /Referenced <a.+>[^\s]+<\/a> already/
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not link with an invalid id" do
|
||||
# Modify the reference string so it's still parsed, but is invalid
|
||||
invalid_reference = actual.gsub(/(\d+)$/, "r45")
|
||||
gfm(invalid_reference).should == invalid_reference
|
||||
expect(gfm(invalid_reference)).to eq(invalid_reference)
|
||||
end
|
||||
|
||||
it "should include a title attribute" do
|
||||
title = "Issue in JIRA tracker"
|
||||
gfm(actual).should match(/title="#{title}"/)
|
||||
expect(gfm(actual)).to match(/title="#{title}"/)
|
||||
end
|
||||
|
||||
it "should include standard gfm classes" do
|
||||
gfm(actual).should match(/class="\s?gfm gfm-issue\s?"/)
|
||||
expect(gfm(actual)).to match(/class="\s?gfm gfm-issue\s?"/)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -354,37 +354,37 @@ describe GitlabMarkdownHelper do
|
|||
let(:expected) { project_snippet_path(project, object) }
|
||||
|
||||
it "should link using a valid id" do
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link with adjacent text" do
|
||||
# Wrap the reference in parenthesis
|
||||
gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
|
||||
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
|
||||
|
||||
# Append some text to the end of the reference
|
||||
gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
|
||||
expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
|
||||
end
|
||||
|
||||
it "should keep whitespace intact" do
|
||||
actual = "Referenced #{reference} already."
|
||||
expected = /Referenced <a.+>[^\s]+<\/a> already/
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not link with an invalid id" do
|
||||
# Modify the reference string so it's still parsed, but is invalid
|
||||
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
|
||||
gfm(actual).should == actual
|
||||
expect(gfm(actual)).to eq(actual)
|
||||
end
|
||||
|
||||
it "should include a title attribute" do
|
||||
title = "Snippet: #{object.title}"
|
||||
gfm(actual).should match(/title="#{title}"/)
|
||||
expect(gfm(actual)).to match(/title="#{title}"/)
|
||||
end
|
||||
|
||||
it "should include standard gfm classes" do
|
||||
css = object.class.to_s.underscore
|
||||
gfm(actual).should match(/class="\s?gfm gfm-snippet\s?"/)
|
||||
expect(gfm(actual)).to match(/class="\s?gfm gfm-snippet\s?"/)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -394,63 +394,63 @@ describe GitlabMarkdownHelper do
|
|||
|
||||
it "should link to the merge request" do
|
||||
expected = project_merge_request_path(project, merge_request)
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link to the commit" do
|
||||
expected = project_commit_path(project, commit)
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should link to the issue" do
|
||||
expected = project_issue_path(project, issue)
|
||||
gfm(actual).should match(expected)
|
||||
expect(gfm(actual)).to match(expected)
|
||||
end
|
||||
end
|
||||
|
||||
describe "emoji" do
|
||||
it "matches at the start of a string" do
|
||||
gfm(":+1:").should match(/<img/)
|
||||
expect(gfm(":+1:")).to match(/<img/)
|
||||
end
|
||||
|
||||
it "matches at the end of a string" do
|
||||
gfm("This gets a :-1:").should match(/<img/)
|
||||
expect(gfm("This gets a :-1:")).to match(/<img/)
|
||||
end
|
||||
|
||||
it "matches with adjacent text" do
|
||||
gfm("+1 (:+1:)").should match(/<img/)
|
||||
expect(gfm("+1 (:+1:)")).to match(/<img/)
|
||||
end
|
||||
|
||||
it "has a title attribute" do
|
||||
gfm(":-1:").should match(/title=":-1:"/)
|
||||
expect(gfm(":-1:")).to match(/title=":-1:"/)
|
||||
end
|
||||
|
||||
it "has an alt attribute" do
|
||||
gfm(":-1:").should match(/alt=":-1:"/)
|
||||
expect(gfm(":-1:")).to match(/alt=":-1:"/)
|
||||
end
|
||||
|
||||
it "has an emoji class" do
|
||||
gfm(":+1:").should match('class="emoji"')
|
||||
expect(gfm(":+1:")).to match('class="emoji"')
|
||||
end
|
||||
|
||||
it "sets height and width" do
|
||||
actual = gfm(":+1:")
|
||||
actual.should match(/width="20"/)
|
||||
actual.should match(/height="20"/)
|
||||
expect(actual).to match(/width="20"/)
|
||||
expect(actual).to match(/height="20"/)
|
||||
end
|
||||
|
||||
it "keeps whitespace intact" do
|
||||
gfm('This deserves a :+1: big time.').
|
||||
should match(/deserves a <img.+> big time/)
|
||||
expect(gfm('This deserves a :+1: big time.')).
|
||||
to match(/deserves a <img.+> big time/)
|
||||
end
|
||||
|
||||
it "ignores invalid emoji" do
|
||||
gfm(":invalid-emoji:").should_not match(/<img/)
|
||||
expect(gfm(":invalid-emoji:")).not_to match(/<img/)
|
||||
end
|
||||
|
||||
it "should work independent of reference links (i.e. without @project being set)" do
|
||||
@project = nil
|
||||
gfm(":+1:").should match(/<img/)
|
||||
expect(gfm(":+1:")).to match(/<img/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -467,34 +467,34 @@ describe GitlabMarkdownHelper do
|
|||
groups = actual.split("</a>")
|
||||
|
||||
# Leading commit link
|
||||
groups[0].should match(/href="#{commit_path}"/)
|
||||
groups[0].should match(/This should finally fix $/)
|
||||
expect(groups[0]).to match(/href="#{commit_path}"/)
|
||||
expect(groups[0]).to match(/This should finally fix $/)
|
||||
|
||||
# First issue link
|
||||
groups[1].should match(/href="#{project_issue_url(project, issues[0])}"/)
|
||||
groups[1].should match(/##{issues[0].iid}$/)
|
||||
expect(groups[1]).to match(/href="#{project_issue_url(project, issues[0])}"/)
|
||||
expect(groups[1]).to match(/##{issues[0].iid}$/)
|
||||
|
||||
# Internal commit link
|
||||
groups[2].should match(/href="#{commit_path}"/)
|
||||
groups[2].should match(/ and /)
|
||||
expect(groups[2]).to match(/href="#{commit_path}"/)
|
||||
expect(groups[2]).to match(/ and /)
|
||||
|
||||
# Second issue link
|
||||
groups[3].should match(/href="#{project_issue_url(project, issues[1])}"/)
|
||||
groups[3].should match(/##{issues[1].iid}$/)
|
||||
expect(groups[3]).to match(/href="#{project_issue_url(project, issues[1])}"/)
|
||||
expect(groups[3]).to match(/##{issues[1].iid}$/)
|
||||
|
||||
# Trailing commit link
|
||||
groups[4].should match(/href="#{commit_path}"/)
|
||||
groups[4].should match(/ for real$/)
|
||||
expect(groups[4]).to match(/href="#{commit_path}"/)
|
||||
expect(groups[4]).to match(/ for real$/)
|
||||
end
|
||||
|
||||
it "should forward HTML options" do
|
||||
actual = link_to_gfm("Fixed in #{commit.id}", commit_path, class: 'foo')
|
||||
actual.should have_selector 'a.gfm.gfm-commit.foo'
|
||||
expect(actual).to have_selector 'a.gfm.gfm-commit.foo'
|
||||
end
|
||||
|
||||
it "escapes HTML passed in as the body" do
|
||||
actual = "This is a <h1>test</h1> - see ##{issues[0].iid}"
|
||||
link_to_gfm(actual, commit_path).should match('<h1>test</h1>')
|
||||
expect(link_to_gfm(actual, commit_path)).to match('<h1>test</h1>')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -502,25 +502,25 @@ describe GitlabMarkdownHelper do
|
|||
it "should handle references in paragraphs" do
|
||||
actual = "\n\nLorem ipsum dolor sit amet. #{commit.id} Nam pulvinar sapien eget.\n"
|
||||
expected = project_commit_path(project, commit)
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should handle references in headers" do
|
||||
actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}"
|
||||
|
||||
markdown(actual, {no_header_anchors:true}).should match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
|
||||
markdown(actual, {no_header_anchors:true}).should match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
|
||||
expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
|
||||
expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
|
||||
end
|
||||
|
||||
it "should add ids and links to headers" do
|
||||
# Test every rule except nested tags.
|
||||
text = '..Ab_c-d. e..'
|
||||
id = 'ab_c-d-e'
|
||||
markdown("# #{text}").should match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
|
||||
markdown("# #{text}", {no_header_anchors:true}).should == "<h1>#{text}</h1>"
|
||||
expect(markdown("# #{text}")).to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
|
||||
expect(markdown("# #{text}", {no_header_anchors:true})).to eq("<h1>#{text}</h1>")
|
||||
|
||||
id = 'link-text'
|
||||
markdown("# [link text](url) ").should match(
|
||||
expect(markdown("# [link text](url) ")).to match(
|
||||
%r{<h1 id="#{id}"><a href="[^"]*url">link text</a> <img[^>]*><a href="[^"]*##{id}"></a></h1>}
|
||||
)
|
||||
end
|
||||
|
|
@ -530,32 +530,32 @@ describe GitlabMarkdownHelper do
|
|||
|
||||
actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}"
|
||||
|
||||
markdown(actual).should match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
|
||||
markdown(actual).should match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
|
||||
expect(markdown(actual)).to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
|
||||
expect(markdown(actual)).to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
|
||||
end
|
||||
|
||||
it "should not link the apostrophe to issue 39" do
|
||||
project.team << [user, :master]
|
||||
project.issues.stub(:where).with(iid: '39').and_return([issue])
|
||||
allow(project.issues).to receive(:where).with(iid: '39').and_return([issue])
|
||||
|
||||
actual = "Yes, it is @#{member.user.username}'s task."
|
||||
expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not link the apostrophe to issue 39 in code blocks" do
|
||||
project.team << [user, :master]
|
||||
project.issues.stub(:where).with(iid: '39').and_return([issue])
|
||||
allow(project.issues).to receive(:where).with(iid: '39').and_return([issue])
|
||||
|
||||
actual = "Yes, `it is @#{member.user.username}'s task.`"
|
||||
expected = /Yes, <code>it is @gfm\'s task.<\/code>/
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should handle references in <em>" do
|
||||
actual = "Apply _!#{merge_request.iid}_ ASAP"
|
||||
|
||||
markdown(actual).should match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
|
||||
expect(markdown(actual)).to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
|
||||
end
|
||||
|
||||
it "should handle tables" do
|
||||
|
|
@ -564,91 +564,92 @@ describe GitlabMarkdownHelper do
|
|||
| cell 1 | cell 2 |
|
||||
| cell 3 | cell 4 |}
|
||||
|
||||
markdown(actual).should match(/\A<table/)
|
||||
expect(markdown(actual)).to match(/\A<table/)
|
||||
end
|
||||
|
||||
it "should leave code blocks untouched" do
|
||||
helper.stub(:user_color_scheme_class).and_return(:white)
|
||||
allow(helper).to receive(:user_color_scheme_class).and_return(:white)
|
||||
|
||||
target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
|
||||
|
||||
helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html
|
||||
helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html
|
||||
expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).to eq(target_html)
|
||||
expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).to eq(target_html)
|
||||
end
|
||||
|
||||
it "should leave inline code untouched" do
|
||||
markdown("\nDon't use `$#{snippet.id}` here.\n").should ==
|
||||
expect(markdown("\nDon't use `$#{snippet.id}` here.\n")).to eq(
|
||||
"<p>Don't use <code>$#{snippet.id}</code> here.</p>\n"
|
||||
)
|
||||
end
|
||||
|
||||
it "should leave ref-like autolinks untouched" do
|
||||
markdown("look at http://example.tld/#!#{merge_request.iid}").should == "<p>look at <a href=\"http://example.tld/#!#{merge_request.iid}\">http://example.tld/#!#{merge_request.iid}</a></p>\n"
|
||||
expect(markdown("look at http://example.tld/#!#{merge_request.iid}")).to eq("<p>look at <a href=\"http://example.tld/#!#{merge_request.iid}\">http://example.tld/#!#{merge_request.iid}</a></p>\n")
|
||||
end
|
||||
|
||||
it "should leave ref-like href of 'manual' links untouched" do
|
||||
markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})").should == "<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a class=\"gfm gfm-merge_request \" href=\"#{project_merge_request_url(project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n"
|
||||
expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a class=\"gfm gfm-merge_request \" href=\"#{project_merge_request_url(project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n")
|
||||
end
|
||||
|
||||
it "should leave ref-like src of images untouched" do
|
||||
markdown("screen shot: ").should == "<p>screen shot: <img src=\"http://example.tld/#!#{merge_request.iid}\" alt=\"some image\"></p>\n"
|
||||
expect(markdown("screen shot: ")).to eq("<p>screen shot: <img src=\"http://example.tld/#!#{merge_request.iid}\" alt=\"some image\"></p>\n")
|
||||
end
|
||||
|
||||
it "should generate absolute urls for refs" do
|
||||
markdown("##{issue.iid}").should include(project_issue_url(project, issue))
|
||||
expect(markdown("##{issue.iid}")).to include(project_issue_url(project, issue))
|
||||
end
|
||||
|
||||
it "should generate absolute urls for emoji" do
|
||||
markdown(':smile:').should(
|
||||
expect(markdown(':smile:')).to(
|
||||
include(%(src="#{Gitlab.config.gitlab.url}/assets/emoji/smile.png))
|
||||
)
|
||||
end
|
||||
|
||||
it "should generate absolute urls for emoji if relative url is present" do
|
||||
Gitlab.config.gitlab.stub(:url).and_return('http://localhost/gitlab/root')
|
||||
markdown(":smile:").should include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
|
||||
allow(Gitlab.config.gitlab).to receive(:url).and_return('http://localhost/gitlab/root')
|
||||
expect(markdown(":smile:")).to include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
|
||||
end
|
||||
|
||||
it "should generate absolute urls for emoji if asset_host is present" do
|
||||
Gitlab::Application.config.stub(:asset_host).and_return("https://cdn.example.com")
|
||||
allow(Gitlab::Application.config).to receive(:asset_host).and_return("https://cdn.example.com")
|
||||
ActionView::Base.any_instance.stub_chain(:config, :asset_host).and_return("https://cdn.example.com")
|
||||
markdown(":smile:").should include("src=\"https://cdn.example.com/assets/emoji/smile.png")
|
||||
expect(markdown(":smile:")).to include("src=\"https://cdn.example.com/assets/emoji/smile.png")
|
||||
end
|
||||
|
||||
|
||||
it "should handle relative urls for a file in master" do
|
||||
actual = "[GitLab API doc](doc/api/README.md)\n"
|
||||
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should handle relative urls for a directory in master" do
|
||||
actual = "[GitLab API doc](doc/api)\n"
|
||||
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc</a></p>\n"
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should handle absolute urls" do
|
||||
actual = "[GitLab](https://www.gitlab.com)\n"
|
||||
expected = "<p><a href=\"https://www.gitlab.com\">GitLab</a></p>\n"
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should handle relative urls in reference links for a file in master" do
|
||||
actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n"
|
||||
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should handle relative urls in reference links for a directory in master" do
|
||||
actual = "[GitLab API doc directory][GitLab readmes]\n [GitLab readmes]: doc/api/\n"
|
||||
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc directory</a></p>\n"
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
|
||||
it "should not handle malformed relative urls in reference links for a file in master" do
|
||||
actual = "[GitLab readme]: doc/api/README.md\n"
|
||||
expected = ""
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -661,29 +662,29 @@ describe GitlabMarkdownHelper do
|
|||
it "should not touch relative urls" do
|
||||
actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n"
|
||||
expected = "<p><a href=\"doc/api/README.md\">GitLab API doc</a></p>\n"
|
||||
markdown(actual).should match(expected)
|
||||
expect(markdown(actual)).to match(expected)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#render_wiki_content" do
|
||||
before do
|
||||
@wiki = double('WikiPage')
|
||||
@wiki.stub(:content).and_return('wiki content')
|
||||
allow(@wiki).to receive(:content).and_return('wiki content')
|
||||
end
|
||||
|
||||
it "should use GitLab Flavored Markdown for markdown files" do
|
||||
@wiki.stub(:format).and_return(:markdown)
|
||||
allow(@wiki).to receive(:format).and_return(:markdown)
|
||||
|
||||
helper.should_receive(:markdown).with('wiki content')
|
||||
expect(helper).to receive(:markdown).with('wiki content')
|
||||
|
||||
helper.render_wiki_content(@wiki)
|
||||
end
|
||||
|
||||
it "should use the Gollum renderer for all other file types" do
|
||||
@wiki.stub(:format).and_return(:rdoc)
|
||||
allow(@wiki).to receive(:format).and_return(:rdoc)
|
||||
formatted_content_stub = double('formatted_content')
|
||||
formatted_content_stub.should_receive(:html_safe)
|
||||
@wiki.stub(:formatted_content).and_return(formatted_content_stub)
|
||||
expect(formatted_content_stub).to receive(:html_safe)
|
||||
allow(@wiki).to receive(:formatted_content).and_return(formatted_content_stub)
|
||||
|
||||
helper.render_wiki_content(@wiki)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@ describe IssuesHelper do
|
|||
describe "title_for_issue" do
|
||||
it "should return issue title if used internal tracker" do
|
||||
@project = project
|
||||
title_for_issue(issue.iid).should eq issue.title
|
||||
expect(title_for_issue(issue.iid)).to eq issue.title
|
||||
end
|
||||
|
||||
it "should always return empty string if used external tracker" do
|
||||
@project = ext_project
|
||||
title_for_issue(rand(100)).should eq ""
|
||||
expect(title_for_issue(rand(100))).to eq ""
|
||||
end
|
||||
|
||||
it "should always return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
title_for_issue(rand(100)).should eq ""
|
||||
expect(title_for_issue(rand(100))).to eq ""
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,29 +33,29 @@ describe IssuesHelper do
|
|||
|
||||
it "should return internal path if used internal tracker" do
|
||||
@project = project
|
||||
url_for_project_issues.should match(int_expected)
|
||||
expect(url_for_project_issues).to match(int_expected)
|
||||
end
|
||||
|
||||
it "should return path to external tracker" do
|
||||
@project = ext_project
|
||||
|
||||
url_for_project_issues.should match(ext_expected)
|
||||
expect(url_for_project_issues).to match(ext_expected)
|
||||
end
|
||||
|
||||
it "should return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
url_for_project_issues.should eq ""
|
||||
expect(url_for_project_issues).to eq ""
|
||||
end
|
||||
|
||||
describe "when external tracker was enabled and then config removed" do
|
||||
before do
|
||||
@project = ext_project
|
||||
Gitlab.config.stub(:issues_tracker).and_return(nil)
|
||||
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
|
||||
end
|
||||
|
||||
it "should return path to external tracker" do
|
||||
url_for_project_issues.should match(ext_expected)
|
||||
expect(url_for_project_issues).to match(ext_expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -71,34 +71,34 @@ describe IssuesHelper do
|
|||
|
||||
it "should return internal path if used internal tracker" do
|
||||
@project = project
|
||||
url_for_issue(issue.iid).should match(int_expected)
|
||||
expect(url_for_issue(issue.iid)).to match(int_expected)
|
||||
end
|
||||
|
||||
it "should return path to external tracker" do
|
||||
@project = ext_project
|
||||
|
||||
url_for_issue(issue.iid).should match(ext_expected)
|
||||
expect(url_for_issue(issue.iid)).to match(ext_expected)
|
||||
end
|
||||
|
||||
it "should return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
url_for_issue(issue.iid).should eq ""
|
||||
expect(url_for_issue(issue.iid)).to eq ""
|
||||
end
|
||||
|
||||
describe "when external tracker was enabled and then config removed" do
|
||||
before do
|
||||
@project = ext_project
|
||||
Gitlab.config.stub(:issues_tracker).and_return(nil)
|
||||
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
|
||||
end
|
||||
|
||||
it "should return external path" do
|
||||
url_for_issue(issue.iid).should match(ext_expected)
|
||||
expect(url_for_issue(issue.iid)).to match(ext_expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe :url_for_new_issue do
|
||||
describe '#url_for_new_issue' do
|
||||
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
|
||||
let(:ext_expected) do
|
||||
issues_url.gsub(':project_id', ext_project.id.to_s)
|
||||
|
|
@ -108,29 +108,29 @@ describe IssuesHelper do
|
|||
|
||||
it "should return internal path if used internal tracker" do
|
||||
@project = project
|
||||
url_for_new_issue.should match(int_expected)
|
||||
expect(url_for_new_issue).to match(int_expected)
|
||||
end
|
||||
|
||||
it "should return path to external tracker" do
|
||||
@project = ext_project
|
||||
|
||||
url_for_new_issue.should match(ext_expected)
|
||||
expect(url_for_new_issue).to match(ext_expected)
|
||||
end
|
||||
|
||||
it "should return empty string if project nil" do
|
||||
@project = nil
|
||||
|
||||
url_for_new_issue.should eq ""
|
||||
expect(url_for_new_issue).to eq ""
|
||||
end
|
||||
|
||||
describe "when external tracker was enabled and then config removed" do
|
||||
before do
|
||||
@project = ext_project
|
||||
Gitlab.config.stub(:issues_tracker).and_return(nil)
|
||||
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
|
||||
end
|
||||
|
||||
it "should return internal path" do
|
||||
url_for_new_issue.should match(ext_expected)
|
||||
expect(url_for_new_issue).to match(ext_expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ describe MergeRequestsHelper do
|
|||
[build(:issue, iid: 1), build(:issue, iid: 2), build(:issue, iid: 3)]
|
||||
end
|
||||
|
||||
it { should eq('#1, #2, and #3') }
|
||||
it { is_expected.to eq('#1, #2, and #3') }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe NotificationsHelper do
|
|||
before { notification.stub(disabled?: true) }
|
||||
|
||||
it "has a red icon" do
|
||||
notification_icon(notification).should match('class="fa fa-volume-off ns-mute"')
|
||||
expect(notification_icon(notification)).to match('class="fa fa-volume-off ns-mute"')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ describe NotificationsHelper do
|
|||
before { notification.stub(participating?: true) }
|
||||
|
||||
it "has a blue icon" do
|
||||
notification_icon(notification).should match('class="fa fa-volume-down ns-part"')
|
||||
expect(notification_icon(notification)).to match('class="fa fa-volume-down ns-part"')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -27,12 +27,12 @@ describe NotificationsHelper do
|
|||
before { notification.stub(watch?: true) }
|
||||
|
||||
it "has a green icon" do
|
||||
notification_icon(notification).should match('class="fa fa-volume-up ns-watch"')
|
||||
expect(notification_icon(notification)).to match('class="fa fa-volume-up ns-watch"')
|
||||
end
|
||||
end
|
||||
|
||||
it "has a blue icon" do
|
||||
notification_icon(notification).should match('class="fa fa-circle-o ns-default"')
|
||||
expect(notification_icon(notification)).to match('class="fa fa-circle-o ns-default"')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ describe OauthHelper do
|
|||
describe "additional_providers" do
|
||||
it 'returns all enabled providers' do
|
||||
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :github] }
|
||||
helper.additional_providers.should include(*[:twitter, :github])
|
||||
expect(helper.additional_providers).to include(*[:twitter, :github])
|
||||
end
|
||||
|
||||
it 'does not return ldap provider' do
|
||||
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :ldapmain] }
|
||||
helper.additional_providers.should include(:twitter)
|
||||
expect(helper.additional_providers).to include(:twitter)
|
||||
end
|
||||
|
||||
it 'returns empty array' do
|
||||
allow(helper).to receive(:enabled_oauth_providers) { [] }
|
||||
helper.additional_providers.should == []
|
||||
expect(helper.additional_providers).to eq([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -3,9 +3,9 @@ require 'spec_helper'
|
|||
describe ProjectsHelper do
|
||||
describe "#project_status_css_class" do
|
||||
it "returns appropriate class" do
|
||||
project_status_css_class("started").should == "active"
|
||||
project_status_css_class("failed").should == "danger"
|
||||
project_status_css_class("finished").should == "success"
|
||||
expect(project_status_css_class("started")).to eq("active")
|
||||
expect(project_status_css_class("failed")).to eq("danger")
|
||||
expect(project_status_css_class("finished")).to eq("success")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ describe SearchHelper do
|
|||
end
|
||||
|
||||
it "it returns nil" do
|
||||
search_autocomplete_opts("q").should be_nil
|
||||
expect(search_autocomplete_opts("q")).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -25,29 +25,29 @@ describe SearchHelper do
|
|||
end
|
||||
|
||||
it "includes Help sections" do
|
||||
search_autocomplete_opts("hel").size.should == 9
|
||||
expect(search_autocomplete_opts("hel").size).to eq(9)
|
||||
end
|
||||
|
||||
it "includes default sections" do
|
||||
search_autocomplete_opts("adm").size.should == 1
|
||||
expect(search_autocomplete_opts("adm").size).to eq(1)
|
||||
end
|
||||
|
||||
it "includes the user's groups" do
|
||||
create(:group).add_owner(user)
|
||||
search_autocomplete_opts("gro").size.should == 1
|
||||
expect(search_autocomplete_opts("gro").size).to eq(1)
|
||||
end
|
||||
|
||||
it "includes the user's projects" do
|
||||
project = create(:project, namespace: create(:namespace, owner: user))
|
||||
search_autocomplete_opts(project.name).size.should == 1
|
||||
expect(search_autocomplete_opts(project.name).size).to eq(1)
|
||||
end
|
||||
|
||||
context "with a current project" do
|
||||
before { @project = create(:project) }
|
||||
|
||||
it "includes project-specific sections" do
|
||||
search_autocomplete_opts("Files").size.should == 1
|
||||
search_autocomplete_opts("Commits").size.should == 1
|
||||
expect(search_autocomplete_opts("Files").size).to eq(1)
|
||||
expect(search_autocomplete_opts("Commits").size).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,28 +19,28 @@ describe SubmoduleHelper do
|
|||
Gitlab.config.gitlab_shell.stub(ssh_port: 22) # set this just to be sure
|
||||
Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix))
|
||||
stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join(''))
|
||||
submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
|
||||
expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
|
||||
end
|
||||
|
||||
it 'should detect ssh on non-standard port' do
|
||||
Gitlab.config.gitlab_shell.stub(ssh_port: 2222)
|
||||
Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix))
|
||||
stub_url([ 'ssh://', config.user, '@', config.host, ':2222/gitlab-org/gitlab-ce.git' ].join(''))
|
||||
submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
|
||||
expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
|
||||
end
|
||||
|
||||
it 'should detect http on standard port' do
|
||||
Gitlab.config.gitlab.stub(port: 80)
|
||||
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
|
||||
stub_url([ 'http://', config.host, '/gitlab-org/gitlab-ce.git' ].join(''))
|
||||
submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
|
||||
expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
|
||||
end
|
||||
|
||||
it 'should detect http on non-standard port' do
|
||||
Gitlab.config.gitlab.stub(port: 3000)
|
||||
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
|
||||
stub_url([ 'http://', config.host, ':3000/gitlab-org/gitlab-ce.git' ].join(''))
|
||||
submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
|
||||
expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
|
||||
end
|
||||
|
||||
it 'should work with relative_url_root' do
|
||||
|
|
@ -48,67 +48,67 @@ describe SubmoduleHelper do
|
|||
Gitlab.config.gitlab.stub(relative_url_root: '/gitlab/root')
|
||||
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
|
||||
stub_url([ 'http://', config.host, '/gitlab/root/gitlab-org/gitlab-ce.git' ].join(''))
|
||||
submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
|
||||
expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
|
||||
end
|
||||
end
|
||||
|
||||
context 'submodule on github.com' do
|
||||
it 'should detect ssh' do
|
||||
stub_url('git@github.com:gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ]
|
||||
expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
|
||||
end
|
||||
|
||||
it 'should detect http' do
|
||||
stub_url('http://github.com/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ]
|
||||
expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
|
||||
end
|
||||
|
||||
it 'should detect https' do
|
||||
stub_url('https://github.com/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ]
|
||||
expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
|
||||
end
|
||||
|
||||
it 'should return original with non-standard url' do
|
||||
stub_url('http://github.com/gitlab-org/gitlab-ce')
|
||||
submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
|
||||
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
|
||||
|
||||
stub_url('http://github.com/another/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
|
||||
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
|
||||
end
|
||||
end
|
||||
|
||||
context 'submodule on gitlab.com' do
|
||||
it 'should detect ssh' do
|
||||
stub_url('git@gitlab.com:gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ]
|
||||
expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
|
||||
end
|
||||
|
||||
it 'should detect http' do
|
||||
stub_url('http://gitlab.com/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ]
|
||||
expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
|
||||
end
|
||||
|
||||
it 'should detect https' do
|
||||
stub_url('https://gitlab.com/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ]
|
||||
expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
|
||||
end
|
||||
|
||||
it 'should return original with non-standard url' do
|
||||
stub_url('http://gitlab.com/gitlab-org/gitlab-ce')
|
||||
submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
|
||||
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
|
||||
|
||||
stub_url('http://gitlab.com/another/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
|
||||
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
|
||||
end
|
||||
end
|
||||
|
||||
context 'submodule on unsupported' do
|
||||
it 'should return original' do
|
||||
stub_url('http://mygitserver.com/gitlab-org/gitlab-ce')
|
||||
submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
|
||||
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
|
||||
|
||||
stub_url('http://mygitserver.com/gitlab-org/gitlab-ce.git')
|
||||
submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
|
||||
expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,40 +5,40 @@ describe TabHelper do
|
|||
|
||||
describe 'nav_link' do
|
||||
before do
|
||||
controller.stub(:controller_name).and_return('foo')
|
||||
allow(controller).to receive(:controller_name).and_return('foo')
|
||||
allow(self).to receive(:action_name).and_return('foo')
|
||||
end
|
||||
|
||||
it "captures block output" do
|
||||
nav_link { "Testing Blocks" }.should match(/Testing Blocks/)
|
||||
expect(nav_link { "Testing Blocks" }).to match(/Testing Blocks/)
|
||||
end
|
||||
|
||||
it "performs checks on the current controller" do
|
||||
nav_link(controller: :foo).should match(/<li class="active">/)
|
||||
nav_link(controller: :bar).should_not match(/active/)
|
||||
nav_link(controller: [:foo, :bar]).should match(/active/)
|
||||
expect(nav_link(controller: :foo)).to match(/<li class="active">/)
|
||||
expect(nav_link(controller: :bar)).not_to match(/active/)
|
||||
expect(nav_link(controller: [:foo, :bar])).to match(/active/)
|
||||
end
|
||||
|
||||
it "performs checks on the current action" do
|
||||
nav_link(action: :foo).should match(/<li class="active">/)
|
||||
nav_link(action: :bar).should_not match(/active/)
|
||||
nav_link(action: [:foo, :bar]).should match(/active/)
|
||||
expect(nav_link(action: :foo)).to match(/<li class="active">/)
|
||||
expect(nav_link(action: :bar)).not_to match(/active/)
|
||||
expect(nav_link(action: [:foo, :bar])).to match(/active/)
|
||||
end
|
||||
|
||||
it "performs checks on both controller and action when both are present" do
|
||||
nav_link(controller: :bar, action: :foo).should_not match(/active/)
|
||||
nav_link(controller: :foo, action: :bar).should_not match(/active/)
|
||||
nav_link(controller: :foo, action: :foo).should match(/active/)
|
||||
expect(nav_link(controller: :bar, action: :foo)).not_to match(/active/)
|
||||
expect(nav_link(controller: :foo, action: :bar)).not_to match(/active/)
|
||||
expect(nav_link(controller: :foo, action: :foo)).to match(/active/)
|
||||
end
|
||||
|
||||
it "accepts a path shorthand" do
|
||||
nav_link(path: 'foo#bar').should_not match(/active/)
|
||||
nav_link(path: 'foo#foo').should match(/active/)
|
||||
expect(nav_link(path: 'foo#bar')).not_to match(/active/)
|
||||
expect(nav_link(path: 'foo#foo')).to match(/active/)
|
||||
end
|
||||
|
||||
it "passes extra html options to the list element" do
|
||||
nav_link(action: :foo, html_options: {class: 'home'}).should match(/<li class="home active">/)
|
||||
nav_link(html_options: {class: 'active'}).should match(/<li class="active">/)
|
||||
expect(nav_link(action: :foo, html_options: {class: 'home'})).to match(/<li class="home active">/)
|
||||
expect(nav_link(html_options: {class: 'active'})).to match(/<li class="active">/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ describe TreeHelper do
|
|||
let(:tree_item) { double(name: "files", path: "files") }
|
||||
|
||||
it "should return the directory name" do
|
||||
flatten_tree(tree_item).should match('files')
|
||||
expect(flatten_tree(tree_item)).to match('files')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ describe TreeHelper do
|
|||
let(:tree_item) { double(name: "foo", path: "foo") }
|
||||
|
||||
it "should return the flattened path" do
|
||||
flatten_tree(tree_item).should match('foo/bar')
|
||||
expect(flatten_tree(tree_item)).to match('foo/bar')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe DisableEmailInterceptor do
|
|||
end
|
||||
|
||||
it 'should not send emails' do
|
||||
Gitlab.config.gitlab.stub(:email_enabled).and_return(false)
|
||||
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
|
||||
expect {
|
||||
deliver_mail
|
||||
}.not_to change(ActionMailer::Base.deliveries, :count)
|
||||
|
|
|
|||
|
|
@ -14,44 +14,46 @@ describe ExtractsPath do
|
|||
describe '#extract_ref' do
|
||||
it "returns an empty pair when no @project is set" do
|
||||
@project = nil
|
||||
extract_ref('master/CHANGELOG').should == ['', '']
|
||||
expect(extract_ref('master/CHANGELOG')).to eq(['', ''])
|
||||
end
|
||||
|
||||
context "without a path" do
|
||||
it "extracts a valid branch" do
|
||||
extract_ref('master').should == ['master', '']
|
||||
expect(extract_ref('master')).to eq(['master', ''])
|
||||
end
|
||||
|
||||
it "extracts a valid tag" do
|
||||
extract_ref('v2.0.0').should == ['v2.0.0', '']
|
||||
expect(extract_ref('v2.0.0')).to eq(['v2.0.0', ''])
|
||||
end
|
||||
|
||||
it "extracts a valid commit ref without a path" do
|
||||
extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062').should ==
|
||||
expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062')).to eq(
|
||||
['f4b14494ef6abf3d144c28e4af0c20143383e062', '']
|
||||
)
|
||||
end
|
||||
|
||||
it "falls back to a primitive split for an invalid ref" do
|
||||
extract_ref('stable').should == ['stable', '']
|
||||
expect(extract_ref('stable')).to eq(['stable', ''])
|
||||
end
|
||||
end
|
||||
|
||||
context "with a path" do
|
||||
it "extracts a valid branch" do
|
||||
extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG']
|
||||
expect(extract_ref('foo/bar/baz/CHANGELOG')).to eq(['foo/bar/baz', 'CHANGELOG'])
|
||||
end
|
||||
|
||||
it "extracts a valid tag" do
|
||||
extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG']
|
||||
expect(extract_ref('v2.0.0/CHANGELOG')).to eq(['v2.0.0', 'CHANGELOG'])
|
||||
end
|
||||
|
||||
it "extracts a valid commit SHA" do
|
||||
extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should ==
|
||||
expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG')).to eq(
|
||||
['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG']
|
||||
)
|
||||
end
|
||||
|
||||
it "falls back to a primitive split for an invalid ref" do
|
||||
extract_ref('stable/CHANGELOG').should == ['stable', 'CHANGELOG']
|
||||
expect(extract_ref('stable/CHANGELOG')).to eq(['stable', 'CHANGELOG'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::GitRefValidator do
|
||||
it { Gitlab::GitRefValidator.validate('feature/new').should be_true }
|
||||
it { Gitlab::GitRefValidator.validate('implement_@all').should be_true }
|
||||
it { Gitlab::GitRefValidator.validate('my_new_feature').should be_true }
|
||||
it { Gitlab::GitRefValidator.validate('#1').should be_true }
|
||||
it { Gitlab::GitRefValidator.validate('feature/~new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/^new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/:new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/?new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/*new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/[new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/new/').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature/new.').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature\@{').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature\new').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature//new').should be_false }
|
||||
it { Gitlab::GitRefValidator.validate('feature new').should be_false }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/new')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/?new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/*new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/[new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/new/')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature/new.')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature\@{')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey }
|
||||
it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ describe Gitlab::Shell do
|
|||
Project.stub(find: project)
|
||||
end
|
||||
|
||||
it { should respond_to :add_key }
|
||||
it { should respond_to :remove_key }
|
||||
it { should respond_to :add_repository }
|
||||
it { should respond_to :remove_repository }
|
||||
it { should respond_to :fork_repository }
|
||||
it { is_expected.to respond_to :add_key }
|
||||
it { is_expected.to respond_to :remove_key }
|
||||
it { is_expected.to respond_to :add_repository }
|
||||
it { is_expected.to respond_to :remove_repository }
|
||||
it { is_expected.to respond_to :fork_repository }
|
||||
|
||||
it { gitlab_shell.url_to_repo('diaspora').should == Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git" }
|
||||
it { expect(gitlab_shell.url_to_repo('diaspora')).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git") }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,122 +9,122 @@ describe Gitlab::ClosingIssueExtractor do
|
|||
context 'with a single reference' do
|
||||
it do
|
||||
message = "Awesome commit (Closes ##{iid1})"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Awesome commit (closes ##{iid1})"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Closed ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "closed ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Closing ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "closing ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Close ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "close ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Awesome commit (Fixes ##{iid1})"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Awesome commit (fixes ##{iid1})"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Fixed ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "fixed ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Fixing ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "fixing ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Fix ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "fix ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Awesome commit (Resolves ##{iid1})"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Awesome commit (resolves ##{iid1})"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Resolved ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "resolved ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Resolving ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "resolving ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "Resolve ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
|
||||
it do
|
||||
message = "resolve ##{iid1}"
|
||||
subject.closed_by_message_in_project(message, project).should == [issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).to eq([issue])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -137,37 +137,37 @@ describe Gitlab::ClosingIssueExtractor do
|
|||
it 'fetches issues in single line message' do
|
||||
message = "Closes ##{iid1} and fix ##{iid2}"
|
||||
|
||||
subject.closed_by_message_in_project(message, project).
|
||||
should == [issue, other_issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).
|
||||
to eq([issue, other_issue])
|
||||
end
|
||||
|
||||
it 'fetches comma-separated issues references in single line message' do
|
||||
message = "Closes ##{iid1}, closes ##{iid2}"
|
||||
|
||||
subject.closed_by_message_in_project(message, project).
|
||||
should == [issue, other_issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).
|
||||
to eq([issue, other_issue])
|
||||
end
|
||||
|
||||
it 'fetches comma-separated issues numbers in single line message' do
|
||||
message = "Closes ##{iid1}, ##{iid2} and ##{iid3}"
|
||||
|
||||
subject.closed_by_message_in_project(message, project).
|
||||
should == [issue, other_issue, third_issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).
|
||||
to eq([issue, other_issue, third_issue])
|
||||
end
|
||||
|
||||
it 'fetches issues in multi-line message' do
|
||||
message = "Awesome commit (closes ##{iid1})\nAlso fixes ##{iid2}"
|
||||
|
||||
subject.closed_by_message_in_project(message, project).
|
||||
should == [issue, other_issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).
|
||||
to eq([issue, other_issue])
|
||||
end
|
||||
|
||||
it 'fetches issues in hybrid message' do
|
||||
message = "Awesome commit (closes ##{iid1})\n"\
|
||||
"Also fixing issues ##{iid2}, ##{iid3} and #4"
|
||||
|
||||
subject.closed_by_message_in_project(message, project).
|
||||
should == [issue, other_issue, third_issue]
|
||||
expect(subject.closed_by_message_in_project(message, project)).
|
||||
to eq([issue, other_issue, third_issue])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ describe Gitlab::Diff::File do
|
|||
describe :diff_lines do
|
||||
let(:diff_lines) { diff_file.diff_lines }
|
||||
|
||||
it { diff_lines.size.should == 30 }
|
||||
it { diff_lines.first.should be_kind_of(Gitlab::Diff::Line) }
|
||||
it { expect(diff_lines.size).to eq(30) }
|
||||
it { expect(diff_lines.first).to be_kind_of(Gitlab::Diff::Line) }
|
||||
end
|
||||
|
||||
describe :mode_changed? do
|
||||
it { diff_file.mode_changed?.should be_false }
|
||||
it { expect(diff_file.mode_changed?).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,43 +50,43 @@ eos
|
|||
@lines = parser.parse(diff.lines)
|
||||
end
|
||||
|
||||
it { @lines.size.should == 30 }
|
||||
it { expect(@lines.size).to eq(30) }
|
||||
|
||||
describe 'lines' do
|
||||
describe 'first line' do
|
||||
let(:line) { @lines.first }
|
||||
|
||||
it { line.type.should == 'match' }
|
||||
it { line.old_pos.should == 6 }
|
||||
it { line.new_pos.should == 6 }
|
||||
it { line.text.should == '@@ -6,12 +6,18 @@ module Popen' }
|
||||
it { expect(line.type).to eq('match') }
|
||||
it { expect(line.old_pos).to eq(6) }
|
||||
it { expect(line.new_pos).to eq(6) }
|
||||
it { expect(line.text).to eq('@@ -6,12 +6,18 @@ module Popen') }
|
||||
end
|
||||
|
||||
describe 'removal line' do
|
||||
let(:line) { @lines[10] }
|
||||
|
||||
it { line.type.should == 'old' }
|
||||
it { line.old_pos.should == 14 }
|
||||
it { line.new_pos.should == 13 }
|
||||
it { line.text.should == '- options = { chdir: path }' }
|
||||
it { expect(line.type).to eq('old') }
|
||||
it { expect(line.old_pos).to eq(14) }
|
||||
it { expect(line.new_pos).to eq(13) }
|
||||
it { expect(line.text).to eq('- options = { chdir: path }') }
|
||||
end
|
||||
|
||||
describe 'addition line' do
|
||||
let(:line) { @lines[16] }
|
||||
|
||||
it { line.type.should == 'new' }
|
||||
it { line.old_pos.should == 15 }
|
||||
it { line.new_pos.should == 18 }
|
||||
it { line.text.should == '+ options = {' }
|
||||
it { expect(line.type).to eq('new') }
|
||||
it { expect(line.old_pos).to eq(15) }
|
||||
it { expect(line.new_pos).to eq(18) }
|
||||
it { expect(line.text).to eq('+ options = {') }
|
||||
end
|
||||
|
||||
describe 'unchanged line' do
|
||||
let(:line) { @lines.last }
|
||||
|
||||
it { line.type.should == nil }
|
||||
it { line.old_pos.should == 24 }
|
||||
it { line.new_pos.should == 31 }
|
||||
it { line.text.should == ' @cmd_output << stderr.read' }
|
||||
it { expect(line.type).to eq(nil) }
|
||||
it { expect(line.old_pos).to eq(24) }
|
||||
it { expect(line.new_pos).to eq(31) }
|
||||
it { expect(line.text).to eq(' @cmd_output << stderr.read') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@ describe Gitlab::GitAccess do
|
|||
describe 'push to none protected branch' do
|
||||
it "returns true if user is a master" do
|
||||
project.team << [user, :master]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_true
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true if user is a developer" do
|
||||
project.team << [user, :developer]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_true
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false if user is a reporter" do
|
||||
project.team << [user, :reporter]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_false
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -30,17 +30,17 @@ describe Gitlab::GitAccess do
|
|||
|
||||
it "returns true if user is a master" do
|
||||
project.team << [user, :master]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false if user is a developer" do
|
||||
project.team << [user, :developer]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey
|
||||
end
|
||||
|
||||
it "returns false if user is a reporter" do
|
||||
project.team << [user, :reporter]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -51,17 +51,17 @@ describe Gitlab::GitAccess do
|
|||
|
||||
it "returns true if user is a master" do
|
||||
project.team << [user, :master]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true if user is a developer" do
|
||||
project.team << [user, :developer]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false if user is a reporter" do
|
||||
project.team << [user, :reporter]
|
||||
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false
|
||||
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ describe Gitlab::GitAccess do
|
|||
context 'pull code' do
|
||||
subject { access.download_access_check(user, project) }
|
||||
|
||||
it { subject.allowed?.should be_true }
|
||||
it { expect(subject.allowed?).to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ describe Gitlab::GitAccess do
|
|||
context 'pull code' do
|
||||
subject { access.download_access_check(user, project) }
|
||||
|
||||
it { subject.allowed?.should be_false }
|
||||
it { expect(subject.allowed?).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ describe Gitlab::GitAccess do
|
|||
context 'pull code' do
|
||||
subject { access.download_access_check(user, project) }
|
||||
|
||||
it { subject.allowed?.should be_false }
|
||||
it { expect(subject.allowed?).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ describe Gitlab::GitAccess do
|
|||
context 'pull code' do
|
||||
subject { access.download_access_check(user, project) }
|
||||
|
||||
it { subject.allowed?.should be_false }
|
||||
it { expect(subject.allowed?).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -117,13 +117,13 @@ describe Gitlab::GitAccess do
|
|||
before { key.projects << project }
|
||||
subject { access.download_access_check(key, project) }
|
||||
|
||||
it { subject.allowed?.should be_true }
|
||||
it { expect(subject.allowed?).to be_truthy }
|
||||
end
|
||||
|
||||
context 'denied' do
|
||||
subject { access.download_access_check(key, project) }
|
||||
|
||||
it { subject.allowed?.should be_false }
|
||||
it { expect(subject.allowed?).to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -207,7 +207,7 @@ describe Gitlab::GitAccess do
|
|||
context action do
|
||||
subject { access.push_access_check(user, project, changes[action]) }
|
||||
|
||||
it { subject.allowed?.should allowed ? be_true : be_false }
|
||||
it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -223,7 +223,7 @@ describe Gitlab::GitAccess do
|
|||
context action do
|
||||
subject { access.push_access_check(user, project, changes[action]) }
|
||||
|
||||
it { subject.allowed?.should allowed ? be_true : be_false }
|
||||
it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ describe Gitlab::GitAccessWiki do
|
|||
|
||||
subject { access.push_access_check(user, project, changes) }
|
||||
|
||||
it { subject.allowed?.should be_true }
|
||||
it { expect(subject.allowed?).to be_truthy }
|
||||
end
|
||||
|
||||
def changes
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ describe Gitlab::Github::ProjectCreator do
|
|||
let(:namespace){ create(:namespace) }
|
||||
|
||||
it 'creates project' do
|
||||
Project.any_instance.stub(:add_import_job)
|
||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||
|
||||
project_creator = Gitlab::Github::ProjectCreator.new(repo, namespace, user)
|
||||
project_creator.execute
|
||||
project = Project.last
|
||||
|
||||
project.import_url.should == "https://asdffg@gitlab.com/asd/vim.git"
|
||||
project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE
|
||||
expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git")
|
||||
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ describe Gitlab::GitlabImport::ProjectCreator do
|
|||
let(:namespace){ create(:namespace) }
|
||||
|
||||
it 'creates project' do
|
||||
Project.any_instance.stub(:add_import_job)
|
||||
allow_any_instance_of(Project).to receive(:add_import_job)
|
||||
|
||||
project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user)
|
||||
project_creator.execute
|
||||
project = Project.last
|
||||
|
||||
project.import_url.should == "https://oauth2:asdffg@gitlab.com/asd/vim.git"
|
||||
project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE
|
||||
expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
|
||||
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,24 +5,24 @@ describe Gitlab::MarkdownHelper do
|
|||
%w(textile rdoc org creole wiki
|
||||
mediawiki rst adoc asciidoc asc).each do |type|
|
||||
it "returns true for #{type} files" do
|
||||
Gitlab::MarkdownHelper.markup?("README.#{type}").should be_true
|
||||
expect(Gitlab::MarkdownHelper.markup?("README.#{type}")).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns false when given a non-markup filename' do
|
||||
Gitlab::MarkdownHelper.markup?('README.rb').should_not be_true
|
||||
expect(Gitlab::MarkdownHelper.markup?('README.rb')).not_to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe '#gitlab_markdown?' do
|
||||
%w(mdown md markdown).each do |type|
|
||||
it "returns true for #{type} files" do
|
||||
Gitlab::MarkdownHelper.gitlab_markdown?("README.#{type}").should be_true
|
||||
expect(Gitlab::MarkdownHelper.gitlab_markdown?("README.#{type}")).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns false when given a non-markdown filename' do
|
||||
Gitlab::MarkdownHelper.gitlab_markdown?('README.rb').should_not be_true
|
||||
expect(Gitlab::MarkdownHelper.gitlab_markdown?('README.rb')).not_to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe Gitlab::LDAP::Access do
|
|||
context 'when the user cannot be found' do
|
||||
before { Gitlab::LDAP::Person.stub(find_by_dn: nil) }
|
||||
|
||||
it { should be_false }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'when the user is found' do
|
||||
|
|
@ -19,13 +19,13 @@ describe Gitlab::LDAP::Access do
|
|||
context 'and the user is diabled via active directory' do
|
||||
before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: true) }
|
||||
|
||||
it { should be_false }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
context 'and has no disabled flag in active diretory' do
|
||||
before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false) }
|
||||
|
||||
it { should be_true }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'without ActiveDirectory enabled' do
|
||||
|
|
@ -34,7 +34,7 @@ describe Gitlab::LDAP::Access do
|
|||
Gitlab::LDAP::Config.any_instance.stub(active_directory: false)
|
||||
end
|
||||
|
||||
it { should be_true }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,20 +12,20 @@ describe Gitlab::LDAP::Adapter do
|
|||
context "and the result is non-empty" do
|
||||
before { ldap.stub(search: [:foo]) }
|
||||
|
||||
it { should be_true }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context "and the result is empty" do
|
||||
before { ldap.stub(search: []) }
|
||||
|
||||
it { should be_false }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
context "when the search encounters an error" do
|
||||
before { ldap.stub(search: nil, get_operation_result: double(code: 1, message: 'some error')) }
|
||||
|
||||
it { should be_false }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe Gitlab::LDAP::Authentication do
|
|||
klass.any_instance.stub(adapter: double(:adapter,
|
||||
bind_as: double(:ldap_user, dn: dn)
|
||||
))
|
||||
expect(klass.login(login, password)).to be_true
|
||||
expect(klass.login(login, password)).to be_truthy
|
||||
end
|
||||
|
||||
it "is false if the user does not exist" do
|
||||
|
|
@ -27,27 +27,27 @@ describe Gitlab::LDAP::Authentication do
|
|||
klass.any_instance.stub(adapter: double(:adapter,
|
||||
bind_as: double(:ldap_user, dn: dn)
|
||||
))
|
||||
expect(klass.login(login, password)).to be_false
|
||||
expect(klass.login(login, password)).to be_falsey
|
||||
end
|
||||
|
||||
it "is false if authentication fails" do
|
||||
user
|
||||
# try only to fake the LDAP call
|
||||
klass.any_instance.stub(adapter: double(:adapter, bind_as: nil))
|
||||
expect(klass.login(login, password)).to be_false
|
||||
expect(klass.login(login, password)).to be_falsey
|
||||
end
|
||||
|
||||
it "fails if ldap is disabled" do
|
||||
Gitlab::LDAP::Config.stub(enabled?: false)
|
||||
expect(klass.login(login, password)).to be_false
|
||||
expect(klass.login(login, password)).to be_falsey
|
||||
end
|
||||
|
||||
it "fails if no login is supplied" do
|
||||
expect(klass.login('', password)).to be_false
|
||||
expect(klass.login('', password)).to be_falsey
|
||||
end
|
||||
|
||||
it "fails if no password is supplied" do
|
||||
expect(klass.login(login, '')).to be_false
|
||||
expect(klass.login(login, '')).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -4,7 +4,7 @@ describe Gitlab::LDAP::Config do
|
|||
let(:config) { Gitlab::LDAP::Config.new provider }
|
||||
let(:provider) { 'ldapmain' }
|
||||
|
||||
describe :initalize do
|
||||
describe '#initalize' do
|
||||
it 'requires a provider' do
|
||||
expect{ Gitlab::LDAP::Config.new }.to raise_error ArgumentError
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ describe Gitlab::LDAP::User do
|
|||
describe :changed? do
|
||||
it "marks existing ldap user as changed" do
|
||||
existing_user = create(:omniauth_user, extern_uid: 'my-uid', provider: 'ldapmain')
|
||||
expect(gl_user.changed?).to be_true
|
||||
expect(gl_user.changed?).to be_truthy
|
||||
end
|
||||
|
||||
it "marks existing non-ldap user if the email matches as changed" do
|
||||
existing_user = create(:user, email: 'john@example.com')
|
||||
expect(gl_user.changed?).to be_true
|
||||
expect(gl_user.changed?).to be_truthy
|
||||
end
|
||||
|
||||
it "dont marks existing ldap user as changed" do
|
||||
existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain')
|
||||
expect(gl_user.changed?).to be_false
|
||||
expect(gl_user.changed?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ describe Gitlab::OAuth::User do
|
|||
|
||||
it "finds an existing user based on uid and provider (facebook)" do
|
||||
auth = double(info: double(name: 'John'), uid: 'my-uid', provider: 'my-provider')
|
||||
expect( oauth_user.persisted? ).to be_true
|
||||
expect( oauth_user.persisted? ).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false if use is not found in database" do
|
||||
auth_hash.stub(uid: 'non-existing')
|
||||
expect( oauth_user.persisted? ).to be_false
|
||||
expect( oauth_user.persisted? ).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -62,8 +62,8 @@ describe Gitlab::OAuth::User do
|
|||
|
||||
it do
|
||||
oauth_user.save
|
||||
gl_user.should be_valid
|
||||
gl_user.should_not be_blocked
|
||||
expect(gl_user).to be_valid
|
||||
expect(gl_user).not_to be_blocked
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -72,8 +72,8 @@ describe Gitlab::OAuth::User do
|
|||
|
||||
it do
|
||||
oauth_user.save
|
||||
gl_user.should be_valid
|
||||
gl_user.should be_blocked
|
||||
expect(gl_user).to be_valid
|
||||
expect(gl_user).to be_blocked
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -89,8 +89,8 @@ describe Gitlab::OAuth::User do
|
|||
|
||||
it do
|
||||
oauth_user.save
|
||||
gl_user.should be_valid
|
||||
gl_user.should_not be_blocked
|
||||
expect(gl_user).to be_valid
|
||||
expect(gl_user).not_to be_blocked
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -99,8 +99,8 @@ describe Gitlab::OAuth::User do
|
|||
|
||||
it do
|
||||
oauth_user.save
|
||||
gl_user.should be_valid
|
||||
gl_user.should_not be_blocked
|
||||
expect(gl_user).to be_valid
|
||||
expect(gl_user).not_to be_blocked
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ describe 'Gitlab::Popen', no_db: true do
|
|||
@output, @status = @klass.new.popen(%W(ls), path)
|
||||
end
|
||||
|
||||
it { @status.should be_zero }
|
||||
it { @output.should include('cache') }
|
||||
it { expect(@status).to be_zero }
|
||||
it { expect(@output).to include('cache') }
|
||||
end
|
||||
|
||||
context 'non-zero status' do
|
||||
|
|
@ -22,8 +22,8 @@ describe 'Gitlab::Popen', no_db: true do
|
|||
@output, @status = @klass.new.popen(%W(cat NOTHING), path)
|
||||
end
|
||||
|
||||
it { @status.should == 1 }
|
||||
it { @output.should include('No such file or directory') }
|
||||
it { expect(@status).to eq(1) }
|
||||
it { expect(@output).to include('No such file or directory') }
|
||||
end
|
||||
|
||||
context 'unsafe string command' do
|
||||
|
|
@ -37,8 +37,8 @@ describe 'Gitlab::Popen', no_db: true do
|
|||
@output, @status = @klass.new.popen(%W(ls))
|
||||
end
|
||||
|
||||
it { @status.should be_zero }
|
||||
it { @output.should include('spec') }
|
||||
it { expect(@status).to be_zero }
|
||||
it { expect(@output).to include('spec') }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ describe 'Gitlab::PushDataBuilder' do
|
|||
describe :build_sample do
|
||||
let(:data) { Gitlab::PushDataBuilder.build_sample(project, user) }
|
||||
|
||||
it { data.should be_a(Hash) }
|
||||
it { data[:before].should == '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' }
|
||||
it { data[:after].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
|
||||
it { data[:ref].should == 'refs/heads/master' }
|
||||
it { data[:commits].size.should == 3 }
|
||||
it { data[:total_commits_count].should == 3 }
|
||||
it { expect(data).to be_a(Hash) }
|
||||
it { expect(data[:before]).to eq('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
|
||||
it { expect(data[:after]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
|
||||
it { expect(data[:ref]).to eq('refs/heads/master') }
|
||||
it { expect(data[:commits].size).to eq(3) }
|
||||
it { expect(data[:total_commits_count]).to eq(3) }
|
||||
end
|
||||
|
||||
describe :build do
|
||||
|
|
@ -25,12 +25,12 @@ describe 'Gitlab::PushDataBuilder' do
|
|||
'refs/tags/v1.1.0')
|
||||
end
|
||||
|
||||
it { data.should be_a(Hash) }
|
||||
it { data[:before].should == Gitlab::Git::BLANK_SHA }
|
||||
it { data[:checkout_sha].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
|
||||
it { data[:after].should == '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b' }
|
||||
it { data[:ref].should == 'refs/tags/v1.1.0' }
|
||||
it { data[:commits].should be_empty }
|
||||
it { data[:total_commits_count].should be_zero }
|
||||
it { expect(data).to be_a(Hash) }
|
||||
it { expect(data[:before]).to eq(Gitlab::Git::BLANK_SHA) }
|
||||
it { expect(data[:checkout_sha]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
|
||||
it { expect(data[:after]).to eq('8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b') }
|
||||
it { expect(data[:ref]).to eq('refs/tags/v1.1.0') }
|
||||
it { expect(data[:commits]).to be_empty }
|
||||
it { expect(data[:total_commits_count]).to be_zero }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,51 +3,51 @@ require 'spec_helper'
|
|||
describe Gitlab::ReferenceExtractor do
|
||||
it 'extracts username references' do
|
||||
subject.analyze('this contains a @user reference', nil)
|
||||
subject.users.should == [{ project: nil, id: 'user' }]
|
||||
expect(subject.users).to eq([{ project: nil, id: 'user' }])
|
||||
end
|
||||
|
||||
it 'extracts issue references' do
|
||||
subject.analyze('this one talks about issue #1234', nil)
|
||||
subject.issues.should == [{ project: nil, id: '1234' }]
|
||||
expect(subject.issues).to eq([{ project: nil, id: '1234' }])
|
||||
end
|
||||
|
||||
it 'extracts JIRA issue references' do
|
||||
subject.analyze('this one talks about issue JIRA-1234', nil)
|
||||
subject.issues.should == [{ project: nil, id: 'JIRA-1234' }]
|
||||
expect(subject.issues).to eq([{ project: nil, id: 'JIRA-1234' }])
|
||||
end
|
||||
|
||||
it 'extracts merge request references' do
|
||||
subject.analyze("and here's !43, a merge request", nil)
|
||||
subject.merge_requests.should == [{ project: nil, id: '43' }]
|
||||
expect(subject.merge_requests).to eq([{ project: nil, id: '43' }])
|
||||
end
|
||||
|
||||
it 'extracts snippet ids' do
|
||||
subject.analyze('snippets like $12 get extracted as well', nil)
|
||||
subject.snippets.should == [{ project: nil, id: '12' }]
|
||||
expect(subject.snippets).to eq([{ project: nil, id: '12' }])
|
||||
end
|
||||
|
||||
it 'extracts commit shas' do
|
||||
subject.analyze('commit shas 98cf0ae3 are pulled out as Strings', nil)
|
||||
subject.commits.should == [{ project: nil, id: '98cf0ae3' }]
|
||||
expect(subject.commits).to eq([{ project: nil, id: '98cf0ae3' }])
|
||||
end
|
||||
|
||||
it 'extracts multiple references and preserves their order' do
|
||||
subject.analyze('@me and @you both care about this', nil)
|
||||
subject.users.should == [
|
||||
expect(subject.users).to eq([
|
||||
{ project: nil, id: 'me' },
|
||||
{ project: nil, id: 'you' }
|
||||
]
|
||||
])
|
||||
end
|
||||
|
||||
it 'leaves the original note unmodified' do
|
||||
text = 'issue #123 is just the worst, @user'
|
||||
subject.analyze(text, nil)
|
||||
text.should == 'issue #123 is just the worst, @user'
|
||||
expect(text).to eq('issue #123 is just the worst, @user')
|
||||
end
|
||||
|
||||
it 'handles all possible kinds of references' do
|
||||
accessors = Gitlab::Markdown::TYPES.map { |t| "#{t}s".to_sym }
|
||||
subject.should respond_to(*accessors)
|
||||
expect(subject).to respond_to(*accessors)
|
||||
end
|
||||
|
||||
context 'with a project' do
|
||||
|
|
@ -62,7 +62,7 @@ describe Gitlab::ReferenceExtractor do
|
|||
project.team << [@u_bar, :guest]
|
||||
|
||||
subject.analyze('@foo, @baduser, @bar, and @offteam', project)
|
||||
subject.users_for(project).should == [@u_foo, @u_bar]
|
||||
expect(subject.users_for(project)).to eq([@u_foo, @u_bar])
|
||||
end
|
||||
|
||||
it 'accesses valid issue objects' do
|
||||
|
|
@ -70,7 +70,7 @@ describe Gitlab::ReferenceExtractor do
|
|||
@i1 = create(:issue, project: project)
|
||||
|
||||
subject.analyze("##{@i0.iid}, ##{@i1.iid}, and #999.", project)
|
||||
subject.issues_for(project).should == [@i0, @i1]
|
||||
expect(subject.issues_for(project)).to eq([@i0, @i1])
|
||||
end
|
||||
|
||||
it 'accesses valid merge requests' do
|
||||
|
|
@ -78,7 +78,7 @@ describe Gitlab::ReferenceExtractor do
|
|||
@m1 = create(:merge_request, source_project: project, target_project: project, source_branch: 'bbb')
|
||||
|
||||
subject.analyze("!999, !#{@m1.iid}, and !#{@m0.iid}.", project)
|
||||
subject.merge_requests_for(project).should == [@m1, @m0]
|
||||
expect(subject.merge_requests_for(project)).to eq([@m1, @m0])
|
||||
end
|
||||
|
||||
it 'accesses valid snippets' do
|
||||
|
|
@ -87,7 +87,7 @@ describe Gitlab::ReferenceExtractor do
|
|||
@s2 = create(:project_snippet)
|
||||
|
||||
subject.analyze("$#{@s0.id}, $999, $#{@s2.id}, $#{@s1.id}", project)
|
||||
subject.snippets_for(project).should == [@s0, @s1]
|
||||
expect(subject.snippets_for(project)).to eq([@s0, @s1])
|
||||
end
|
||||
|
||||
it 'accesses valid commits' do
|
||||
|
|
@ -96,9 +96,9 @@ describe Gitlab::ReferenceExtractor do
|
|||
subject.analyze("this references commits #{commit.sha[0..6]} and 012345",
|
||||
project)
|
||||
extracted = subject.commits_for(project)
|
||||
extracted.should have(1).item
|
||||
extracted[0].sha.should == commit.sha
|
||||
extracted[0].message.should == commit.message
|
||||
expect(extracted.size).to eq(1)
|
||||
expect(extracted[0].sha).to eq(commit.sha)
|
||||
expect(extracted[0].message).to eq(commit.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,20 +2,20 @@ require 'spec_helper'
|
|||
|
||||
describe Gitlab::Regex do
|
||||
describe 'path regex' do
|
||||
it { 'gitlab-ce'.should match(Gitlab::Regex.path_regex) }
|
||||
it { 'gitlab_git'.should match(Gitlab::Regex.path_regex) }
|
||||
it { '_underscore.js'.should match(Gitlab::Regex.path_regex) }
|
||||
it { '100px.com'.should match(Gitlab::Regex.path_regex) }
|
||||
it { '?gitlab'.should_not match(Gitlab::Regex.path_regex) }
|
||||
it { 'git lab'.should_not match(Gitlab::Regex.path_regex) }
|
||||
it { 'gitlab.git'.should_not match(Gitlab::Regex.path_regex) }
|
||||
it { expect('gitlab-ce').to match(Gitlab::Regex.path_regex) }
|
||||
it { expect('gitlab_git').to match(Gitlab::Regex.path_regex) }
|
||||
it { expect('_underscore.js').to match(Gitlab::Regex.path_regex) }
|
||||
it { expect('100px.com').to match(Gitlab::Regex.path_regex) }
|
||||
it { expect('?gitlab').not_to match(Gitlab::Regex.path_regex) }
|
||||
it { expect('git lab').not_to match(Gitlab::Regex.path_regex) }
|
||||
it { expect('gitlab.git').not_to match(Gitlab::Regex.path_regex) }
|
||||
end
|
||||
|
||||
describe 'project name regex' do
|
||||
it { 'gitlab-ce'.should match(Gitlab::Regex.project_name_regex) }
|
||||
it { 'GitLab CE'.should match(Gitlab::Regex.project_name_regex) }
|
||||
it { '100 lines'.should match(Gitlab::Regex.project_name_regex) }
|
||||
it { 'gitlab.git'.should match(Gitlab::Regex.project_name_regex) }
|
||||
it { '?gitlab'.should_not match(Gitlab::Regex.project_name_regex) }
|
||||
it { expect('gitlab-ce').to match(Gitlab::Regex.project_name_regex) }
|
||||
it { expect('GitLab CE').to match(Gitlab::Regex.project_name_regex) }
|
||||
it { expect('100 lines').to match(Gitlab::Regex.project_name_regex) }
|
||||
it { expect('gitlab.git').to match(Gitlab::Regex.project_name_regex) }
|
||||
it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ describe 'Gitlab::Satellite::Action' do
|
|||
|
||||
describe '#prepare_satellite!' do
|
||||
it 'should be able to fetch timeout from conf' do
|
||||
Gitlab::Satellite::Action::DEFAULT_OPTIONS[:git_timeout].should == 30.seconds
|
||||
expect(Gitlab::Satellite::Action::DEFAULT_OPTIONS[:git_timeout]).to eq(30.seconds)
|
||||
end
|
||||
|
||||
it 'create a repository with a parking branch and one remote: origin' do
|
||||
|
|
@ -15,22 +15,22 @@ describe 'Gitlab::Satellite::Action' do
|
|||
#now lets dirty it up
|
||||
|
||||
starting_remote_count = repo.git.list_remotes.size
|
||||
starting_remote_count.should >= 1
|
||||
expect(starting_remote_count).to be >= 1
|
||||
#kind of hookey way to add a second remote
|
||||
origin_uri = repo.git.remote({v: true}).split(" ")[1]
|
||||
begin
|
||||
repo.git.remote({raise: true}, 'add', 'another-remote', origin_uri)
|
||||
repo.git.branch({raise: true}, 'a-new-branch')
|
||||
|
||||
repo.heads.size.should > (starting_remote_count)
|
||||
repo.git.remote().split(" ").size.should > (starting_remote_count)
|
||||
expect(repo.heads.size).to be > (starting_remote_count)
|
||||
expect(repo.git.remote().split(" ").size).to be > (starting_remote_count)
|
||||
rescue
|
||||
end
|
||||
|
||||
repo.git.config({}, "user.name", "#{user.name} -- foo")
|
||||
repo.git.config({}, "user.email", "#{user.email} -- foo")
|
||||
repo.config['user.name'].should =="#{user.name} -- foo"
|
||||
repo.config['user.email'].should =="#{user.email} -- foo"
|
||||
expect(repo.config['user.name']).to eq("#{user.name} -- foo")
|
||||
expect(repo.config['user.email']).to eq("#{user.email} -- foo")
|
||||
|
||||
|
||||
#These must happen in the context of the satellite directory...
|
||||
|
|
@ -42,13 +42,13 @@ describe 'Gitlab::Satellite::Action' do
|
|||
|
||||
#verify it's clean
|
||||
heads = repo.heads.map(&:name)
|
||||
heads.size.should == 1
|
||||
heads.include?(Gitlab::Satellite::Satellite::PARKING_BRANCH).should == true
|
||||
expect(heads.size).to eq(1)
|
||||
expect(heads.include?(Gitlab::Satellite::Satellite::PARKING_BRANCH)).to eq(true)
|
||||
remotes = repo.git.remote().split(' ')
|
||||
remotes.size.should == 1
|
||||
remotes.include?('origin').should == true
|
||||
repo.config['user.name'].should ==user.name
|
||||
repo.config['user.email'].should ==user.email
|
||||
expect(remotes.size).to eq(1)
|
||||
expect(remotes.include?('origin')).to eq(true)
|
||||
expect(repo.config['user.name']).to eq(user.name)
|
||||
expect(repo.config['user.email']).to eq(user.email)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -61,16 +61,16 @@ describe 'Gitlab::Satellite::Action' do
|
|||
#set assumptions
|
||||
FileUtils.rm_f(project.satellite.lock_file)
|
||||
|
||||
File.exists?(project.satellite.lock_file).should be_false
|
||||
expect(File.exists?(project.satellite.lock_file)).to be_falsey
|
||||
|
||||
satellite_action = Gitlab::Satellite::Action.new(user, project)
|
||||
satellite_action.send(:in_locked_and_timed_satellite) do |sat_repo|
|
||||
repo.should == sat_repo
|
||||
(File.exists? project.satellite.lock_file).should be_true
|
||||
expect(repo).to eq(sat_repo)
|
||||
expect(File.exists? project.satellite.lock_file).to be_truthy
|
||||
called = true
|
||||
end
|
||||
|
||||
called.should be_true
|
||||
expect(called).to be_truthy
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -80,19 +80,19 @@ describe 'Gitlab::Satellite::Action' do
|
|||
|
||||
# Set base assumptions
|
||||
if File.exists? project.satellite.lock_file
|
||||
FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_false
|
||||
expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_falsey
|
||||
end
|
||||
|
||||
satellite_action = Gitlab::Satellite::Action.new(user, project)
|
||||
satellite_action.send(:in_locked_and_timed_satellite) do |sat_repo|
|
||||
called = true
|
||||
repo.should == sat_repo
|
||||
(File.exists? project.satellite.lock_file).should be_true
|
||||
FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_true
|
||||
expect(repo).to eq(sat_repo)
|
||||
expect(File.exists? project.satellite.lock_file).to be_truthy
|
||||
expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_truthy
|
||||
end
|
||||
|
||||
called.should be_true
|
||||
FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_false
|
||||
expect(called).to be_truthy
|
||||
expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_falsey
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ describe 'Gitlab::Satellite::MergeAction' do
|
|||
|
||||
describe '#commits_between' do
|
||||
def verify_commits(commits, first_commit_sha, last_commit_sha)
|
||||
commits.each { |commit| commit.class.should == Gitlab::Git::Commit }
|
||||
commits.first.id.should == first_commit_sha
|
||||
commits.last.id.should == last_commit_sha
|
||||
commits.each { |commit| expect(commit.class).to eq(Gitlab::Git::Commit) }
|
||||
expect(commits.first.id).to eq(first_commit_sha)
|
||||
expect(commits.last.id).to eq(last_commit_sha)
|
||||
end
|
||||
|
||||
context 'on fork' do
|
||||
|
|
@ -35,7 +35,7 @@ describe 'Gitlab::Satellite::MergeAction' do
|
|||
describe '#format_patch' do
|
||||
def verify_content(patch)
|
||||
sample_compare.commits.each do |commit|
|
||||
patch.include?(commit).should be_true
|
||||
expect(patch.include?(commit)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -57,11 +57,11 @@ describe 'Gitlab::Satellite::MergeAction' do
|
|||
describe '#diffs_between_satellite tested against diff_in_satellite' do
|
||||
def is_a_matching_diff(diff, diffs)
|
||||
diff_count = diff.scan('diff --git').size
|
||||
diff_count.should >= 1
|
||||
diffs.size.should == diff_count
|
||||
expect(diff_count).to be >= 1
|
||||
expect(diffs.size).to eq(diff_count)
|
||||
diffs.each do |a_diff|
|
||||
a_diff.class.should == Gitlab::Git::Diff
|
||||
(diff.include? a_diff.diff).should be_true
|
||||
expect(a_diff.class).to eq(Gitlab::Git::Diff)
|
||||
expect(diff.include? a_diff.diff).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -82,23 +82,23 @@ describe 'Gitlab::Satellite::MergeAction' do
|
|||
|
||||
describe '#can_be_merged?' do
|
||||
context 'on fork' do
|
||||
it { Gitlab::Satellite::MergeAction.new(
|
||||
it { expect(Gitlab::Satellite::MergeAction.new(
|
||||
merge_request_fork.author,
|
||||
merge_request_fork).can_be_merged?.should be_true }
|
||||
merge_request_fork).can_be_merged?).to be_truthy }
|
||||
|
||||
it { Gitlab::Satellite::MergeAction.new(
|
||||
it { expect(Gitlab::Satellite::MergeAction.new(
|
||||
merge_request_fork_with_conflict.author,
|
||||
merge_request_fork_with_conflict).can_be_merged?.should be_false }
|
||||
merge_request_fork_with_conflict).can_be_merged?).to be_falsey }
|
||||
end
|
||||
|
||||
context 'between branches' do
|
||||
it { Gitlab::Satellite::MergeAction.new(
|
||||
it { expect(Gitlab::Satellite::MergeAction.new(
|
||||
merge_request.author,
|
||||
merge_request).can_be_merged?.should be_true }
|
||||
merge_request).can_be_merged?).to be_truthy }
|
||||
|
||||
it { Gitlab::Satellite::MergeAction.new(
|
||||
it { expect(Gitlab::Satellite::MergeAction.new(
|
||||
merge_request_with_conflict.author,
|
||||
merge_request_with_conflict).can_be_merged?.should be_false }
|
||||
merge_request_with_conflict).can_be_merged?).to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,20 +5,20 @@ describe Gitlab::Upgrader do
|
|||
let(:current_version) { Gitlab::VERSION }
|
||||
|
||||
describe 'current_version_raw' do
|
||||
it { upgrader.current_version_raw.should == current_version }
|
||||
it { expect(upgrader.current_version_raw).to eq(current_version) }
|
||||
end
|
||||
|
||||
describe 'latest_version?' do
|
||||
it 'should be true if newest version' do
|
||||
upgrader.stub(latest_version_raw: current_version)
|
||||
upgrader.latest_version?.should be_true
|
||||
expect(upgrader.latest_version?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe 'latest_version_raw' do
|
||||
it 'should be latest version for GitLab 5' do
|
||||
upgrader.stub(current_version_raw: "5.3.0")
|
||||
upgrader.latest_version_raw.should == "v5.4.2"
|
||||
expect(upgrader.latest_version_raw).to eq("v5.4.2")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,58 +12,58 @@ describe 'Gitlab::VersionInfo', no_db: true do
|
|||
end
|
||||
|
||||
context '>' do
|
||||
it { @v2_0_0.should > @v1_1_0 }
|
||||
it { @v1_1_0.should > @v1_0_1 }
|
||||
it { @v1_0_1.should > @v1_0_0 }
|
||||
it { @v1_0_0.should > @v0_1_0 }
|
||||
it { @v0_1_0.should > @v0_0_1 }
|
||||
it { expect(@v2_0_0).to be > @v1_1_0 }
|
||||
it { expect(@v1_1_0).to be > @v1_0_1 }
|
||||
it { expect(@v1_0_1).to be > @v1_0_0 }
|
||||
it { expect(@v1_0_0).to be > @v0_1_0 }
|
||||
it { expect(@v0_1_0).to be > @v0_0_1 }
|
||||
end
|
||||
|
||||
context '>=' do
|
||||
it { @v2_0_0.should >= Gitlab::VersionInfo.new(2, 0, 0) }
|
||||
it { @v2_0_0.should >= @v1_1_0 }
|
||||
it { expect(@v2_0_0).to be >= Gitlab::VersionInfo.new(2, 0, 0) }
|
||||
it { expect(@v2_0_0).to be >= @v1_1_0 }
|
||||
end
|
||||
|
||||
context '<' do
|
||||
it { @v0_0_1.should < @v0_1_0 }
|
||||
it { @v0_1_0.should < @v1_0_0 }
|
||||
it { @v1_0_0.should < @v1_0_1 }
|
||||
it { @v1_0_1.should < @v1_1_0 }
|
||||
it { @v1_1_0.should < @v2_0_0 }
|
||||
it { expect(@v0_0_1).to be < @v0_1_0 }
|
||||
it { expect(@v0_1_0).to be < @v1_0_0 }
|
||||
it { expect(@v1_0_0).to be < @v1_0_1 }
|
||||
it { expect(@v1_0_1).to be < @v1_1_0 }
|
||||
it { expect(@v1_1_0).to be < @v2_0_0 }
|
||||
end
|
||||
|
||||
context '<=' do
|
||||
it { @v0_0_1.should <= Gitlab::VersionInfo.new(0, 0, 1) }
|
||||
it { @v0_0_1.should <= @v0_1_0 }
|
||||
it { expect(@v0_0_1).to be <= Gitlab::VersionInfo.new(0, 0, 1) }
|
||||
it { expect(@v0_0_1).to be <= @v0_1_0 }
|
||||
end
|
||||
|
||||
context '==' do
|
||||
it { @v0_0_1.should == Gitlab::VersionInfo.new(0, 0, 1) }
|
||||
it { @v0_1_0.should == Gitlab::VersionInfo.new(0, 1, 0) }
|
||||
it { @v1_0_0.should == Gitlab::VersionInfo.new(1, 0, 0) }
|
||||
it { expect(@v0_0_1).to eq(Gitlab::VersionInfo.new(0, 0, 1)) }
|
||||
it { expect(@v0_1_0).to eq(Gitlab::VersionInfo.new(0, 1, 0)) }
|
||||
it { expect(@v1_0_0).to eq(Gitlab::VersionInfo.new(1, 0, 0)) }
|
||||
end
|
||||
|
||||
context '!=' do
|
||||
it { @v0_0_1.should_not == @v0_1_0 }
|
||||
it { expect(@v0_0_1).not_to eq(@v0_1_0) }
|
||||
end
|
||||
|
||||
context 'unknown' do
|
||||
it { @unknown.should_not be @v0_0_1 }
|
||||
it { @unknown.should_not be Gitlab::VersionInfo.new }
|
||||
it { expect(@unknown).not_to be @v0_0_1 }
|
||||
it { expect(@unknown).not_to be Gitlab::VersionInfo.new }
|
||||
it { expect{@unknown > @v0_0_1}.to raise_error(ArgumentError) }
|
||||
it { expect{@unknown < @v0_0_1}.to raise_error(ArgumentError) }
|
||||
end
|
||||
|
||||
context 'parse' do
|
||||
it { Gitlab::VersionInfo.parse("1.0.0").should == @v1_0_0 }
|
||||
it { Gitlab::VersionInfo.parse("1.0.0.1").should == @v1_0_0 }
|
||||
it { Gitlab::VersionInfo.parse("git 1.0.0b1").should == @v1_0_0 }
|
||||
it { Gitlab::VersionInfo.parse("git 1.0b1").should_not be_valid }
|
||||
it { expect(Gitlab::VersionInfo.parse("1.0.0")).to eq(@v1_0_0) }
|
||||
it { expect(Gitlab::VersionInfo.parse("1.0.0.1")).to eq(@v1_0_0) }
|
||||
it { expect(Gitlab::VersionInfo.parse("git 1.0.0b1")).to eq(@v1_0_0) }
|
||||
it { expect(Gitlab::VersionInfo.parse("git 1.0b1")).not_to be_valid }
|
||||
end
|
||||
|
||||
context 'to_s' do
|
||||
it { @v1_0_0.to_s.should == "1.0.0" }
|
||||
it { @unknown.to_s.should == "Unknown" }
|
||||
it { expect(@v1_0_0.to_s).to eq("1.0.0") }
|
||||
it { expect(@unknown.to_s).to eq("Unknown") }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,107 +5,107 @@ describe Issue, 'Votes' do
|
|||
|
||||
describe "#upvotes" do
|
||||
it "with no notes has a 0/0 score" do
|
||||
issue.upvotes.should == 0
|
||||
expect(issue.upvotes).to eq(0)
|
||||
end
|
||||
|
||||
it "should recognize non-+1 notes" do
|
||||
add_note "No +1 here"
|
||||
issue.should have(1).note
|
||||
issue.notes.first.upvote?.should be_false
|
||||
issue.upvotes.should == 0
|
||||
expect(issue.notes.size).to eq(1)
|
||||
expect(issue.notes.first.upvote?).to be_falsey
|
||||
expect(issue.upvotes).to eq(0)
|
||||
end
|
||||
|
||||
it "should recognize a single +1 note" do
|
||||
add_note "+1 This is awesome"
|
||||
issue.upvotes.should == 1
|
||||
expect(issue.upvotes).to eq(1)
|
||||
end
|
||||
|
||||
it 'should recognize multiple +1 notes' do
|
||||
add_note '+1 This is awesome', create(:user)
|
||||
add_note '+1 I want this', create(:user)
|
||||
issue.upvotes.should == 2
|
||||
expect(issue.upvotes).to eq(2)
|
||||
end
|
||||
|
||||
it 'should not count 2 +1 votes from the same user' do
|
||||
add_note '+1 This is awesome'
|
||||
add_note '+1 I want this'
|
||||
issue.upvotes.should == 1
|
||||
expect(issue.upvotes).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#downvotes" do
|
||||
it "with no notes has a 0/0 score" do
|
||||
issue.downvotes.should == 0
|
||||
expect(issue.downvotes).to eq(0)
|
||||
end
|
||||
|
||||
it "should recognize non--1 notes" do
|
||||
add_note "Almost got a -1"
|
||||
issue.should have(1).note
|
||||
issue.notes.first.downvote?.should be_false
|
||||
issue.downvotes.should == 0
|
||||
expect(issue.notes.size).to eq(1)
|
||||
expect(issue.notes.first.downvote?).to be_falsey
|
||||
expect(issue.downvotes).to eq(0)
|
||||
end
|
||||
|
||||
it "should recognize a single -1 note" do
|
||||
add_note "-1 This is bad"
|
||||
issue.downvotes.should == 1
|
||||
expect(issue.downvotes).to eq(1)
|
||||
end
|
||||
|
||||
it "should recognize multiple -1 notes" do
|
||||
add_note('-1 This is bad', create(:user))
|
||||
add_note('-1 Away with this', create(:user))
|
||||
issue.downvotes.should == 2
|
||||
expect(issue.downvotes).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#votes_count" do
|
||||
it "with no notes has a 0/0 score" do
|
||||
issue.votes_count.should == 0
|
||||
expect(issue.votes_count).to eq(0)
|
||||
end
|
||||
|
||||
it "should recognize non notes" do
|
||||
add_note "No +1 here"
|
||||
issue.should have(1).note
|
||||
issue.votes_count.should == 0
|
||||
expect(issue.notes.size).to eq(1)
|
||||
expect(issue.votes_count).to eq(0)
|
||||
end
|
||||
|
||||
it "should recognize a single +1 note" do
|
||||
add_note "+1 This is awesome"
|
||||
issue.votes_count.should == 1
|
||||
expect(issue.votes_count).to eq(1)
|
||||
end
|
||||
|
||||
it "should recognize a single -1 note" do
|
||||
add_note "-1 This is bad"
|
||||
issue.votes_count.should == 1
|
||||
expect(issue.votes_count).to eq(1)
|
||||
end
|
||||
|
||||
it "should recognize multiple notes" do
|
||||
add_note('+1 This is awesome', create(:user))
|
||||
add_note('-1 This is bad', create(:user))
|
||||
add_note('+1 I want this', create(:user))
|
||||
issue.votes_count.should == 3
|
||||
expect(issue.votes_count).to eq(3)
|
||||
end
|
||||
|
||||
it 'should not count 2 -1 votes from the same user' do
|
||||
add_note '-1 This is suspicious'
|
||||
add_note '-1 This is bad'
|
||||
issue.votes_count.should == 1
|
||||
expect(issue.votes_count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#upvotes_in_percent" do
|
||||
it "with no notes has a 0% score" do
|
||||
issue.upvotes_in_percent.should == 0
|
||||
expect(issue.upvotes_in_percent).to eq(0)
|
||||
end
|
||||
|
||||
it "should count a single 1 note as 100%" do
|
||||
add_note "+1 This is awesome"
|
||||
issue.upvotes_in_percent.should == 100
|
||||
expect(issue.upvotes_in_percent).to eq(100)
|
||||
end
|
||||
|
||||
it 'should count multiple +1 notes as 100%' do
|
||||
add_note('+1 This is awesome', create(:user))
|
||||
add_note('+1 I want this', create(:user))
|
||||
issue.upvotes_in_percent.should == 100
|
||||
expect(issue.upvotes_in_percent).to eq(100)
|
||||
end
|
||||
|
||||
it 'should count fractions for multiple +1 and -1 notes correctly' do
|
||||
|
|
@ -113,24 +113,24 @@ describe Issue, 'Votes' do
|
|||
add_note('+1 I want this', create(:user))
|
||||
add_note('-1 This is bad', create(:user))
|
||||
add_note('+1 me too', create(:user))
|
||||
issue.upvotes_in_percent.should == 75
|
||||
expect(issue.upvotes_in_percent).to eq(75)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#downvotes_in_percent" do
|
||||
it "with no notes has a 0% score" do
|
||||
issue.downvotes_in_percent.should == 0
|
||||
expect(issue.downvotes_in_percent).to eq(0)
|
||||
end
|
||||
|
||||
it "should count a single -1 note as 100%" do
|
||||
add_note "-1 This is bad"
|
||||
issue.downvotes_in_percent.should == 100
|
||||
expect(issue.downvotes_in_percent).to eq(100)
|
||||
end
|
||||
|
||||
it 'should count multiple -1 notes as 100%' do
|
||||
add_note('-1 This is bad', create(:user))
|
||||
add_note('-1 Away with this', create(:user))
|
||||
issue.downvotes_in_percent.should == 100
|
||||
expect(issue.downvotes_in_percent).to eq(100)
|
||||
end
|
||||
|
||||
it 'should count fractions for multiple +1 and -1 notes correctly' do
|
||||
|
|
@ -138,7 +138,7 @@ describe Issue, 'Votes' do
|
|||
add_note('+1 I want this', create(:user))
|
||||
add_note('-1 This is bad', create(:user))
|
||||
add_note('+1 me too', create(:user))
|
||||
issue.downvotes_in_percent.should == 25
|
||||
expect(issue.downvotes_in_percent).to eq(25)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -151,8 +151,8 @@ describe Issue, 'Votes' do
|
|||
add_note('+1 this looks good now')
|
||||
add_note('+1 This is awesome', create(:user))
|
||||
add_note('+1 me too', create(:user))
|
||||
issue.downvotes.should == 0
|
||||
issue.upvotes.should == 5
|
||||
expect(issue.downvotes).to eq(0)
|
||||
expect(issue.upvotes).to eq(5)
|
||||
end
|
||||
|
||||
it 'should count each users vote only once' do
|
||||
|
|
@ -161,8 +161,8 @@ describe Issue, 'Votes' do
|
|||
add_note '+1 I still like this'
|
||||
add_note '+1 I really like this'
|
||||
add_note '+1 Give me this now!!!!'
|
||||
issue.downvotes.should == 0
|
||||
issue.upvotes.should == 1
|
||||
expect(issue.downvotes).to eq(0)
|
||||
expect(issue.upvotes).to eq(1)
|
||||
end
|
||||
|
||||
it 'should count a users vote only once without caring about comments' do
|
||||
|
|
@ -171,8 +171,8 @@ describe Issue, 'Votes' do
|
|||
add_note 'Another comment'
|
||||
add_note '+1 vote'
|
||||
add_note 'final comment'
|
||||
issue.downvotes.should == 0
|
||||
issue.upvotes.should == 1
|
||||
expect(issue.downvotes).to eq(0)
|
||||
expect(issue.upvotes).to eq(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,34 +16,34 @@ describe Notify do
|
|||
|
||||
shared_examples 'a multiple recipients email' do
|
||||
it 'is sent to the given recipient' do
|
||||
should deliver_to recipient.notification_email
|
||||
is_expected.to deliver_to recipient.notification_email
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'an email sent from GitLab' do
|
||||
it 'is sent from GitLab' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq('GitLab')
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq('GitLab')
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'an email starting a new thread' do |message_id_prefix|
|
||||
it 'has a discussion identifier' do
|
||||
should have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
|
||||
should have_header 'X-GitLab-Project', /#{project.name}/
|
||||
is_expected.to have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
|
||||
is_expected.to have_header 'X-GitLab-Project', /#{project.name}/
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'an answer to an existing thread' do |thread_id_prefix|
|
||||
it 'has a subject that begins with Re: ' do
|
||||
should have_subject /^Re: /
|
||||
is_expected.to have_subject /^Re: /
|
||||
end
|
||||
|
||||
it 'has headers that reference an existing thread' do
|
||||
should have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
|
||||
should have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
|
||||
should have_header 'X-GitLab-Project', /#{project.name}/
|
||||
is_expected.to have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
|
||||
is_expected.to have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
|
||||
is_expected.to have_header 'X-GitLab-Project', /#{project.name}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -58,30 +58,30 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'is sent to the new user' do
|
||||
should deliver_to new_user.email
|
||||
is_expected.to deliver_to new_user.email
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /^Account was created for you$/i
|
||||
is_expected.to have_subject /^Account was created for you$/i
|
||||
end
|
||||
|
||||
it 'contains the new user\'s login name' do
|
||||
should have_body_text /#{new_user.email}/
|
||||
is_expected.to have_body_text /#{new_user.email}/
|
||||
end
|
||||
|
||||
it 'contains the password text' do
|
||||
should have_body_text /Click here to set your password/
|
||||
is_expected.to have_body_text /Click here to set your password/
|
||||
end
|
||||
|
||||
it 'includes a link for user to set password' do
|
||||
params = "reset_password_token=#{token}"
|
||||
should have_body_text(
|
||||
is_expected.to have_body_text(
|
||||
%r{http://localhost(:\d+)?/users/password/edit\?#{params}}
|
||||
)
|
||||
end
|
||||
|
||||
it 'includes a link to the site' do
|
||||
should have_body_text /#{example_site_path}/
|
||||
is_expected.to have_body_text /#{example_site_path}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -95,23 +95,23 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'is sent to the new user' do
|
||||
should deliver_to new_user.email
|
||||
is_expected.to deliver_to new_user.email
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /^Account was created for you$/i
|
||||
is_expected.to have_subject /^Account was created for you$/i
|
||||
end
|
||||
|
||||
it 'contains the new user\'s login name' do
|
||||
should have_body_text /#{new_user.email}/
|
||||
is_expected.to have_body_text /#{new_user.email}/
|
||||
end
|
||||
|
||||
it 'should not contain the new user\'s password' do
|
||||
should_not have_body_text /password/
|
||||
is_expected.not_to have_body_text /password/
|
||||
end
|
||||
|
||||
it 'includes a link to the site' do
|
||||
should have_body_text /#{example_site_path}/
|
||||
is_expected.to have_body_text /#{example_site_path}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -123,19 +123,19 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'is sent to the new user' do
|
||||
should deliver_to key.user.email
|
||||
is_expected.to deliver_to key.user.email
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /^SSH key was added to your account$/i
|
||||
is_expected.to have_subject /^SSH key was added to your account$/i
|
||||
end
|
||||
|
||||
it 'contains the new ssh key title' do
|
||||
should have_body_text /#{key.title}/
|
||||
is_expected.to have_body_text /#{key.title}/
|
||||
end
|
||||
|
||||
it 'includes a link to ssh keys page' do
|
||||
should have_body_text /#{profile_keys_path}/
|
||||
is_expected.to have_body_text /#{profile_keys_path}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -145,19 +145,19 @@ describe Notify do
|
|||
subject { Notify.new_email_email(email.id) }
|
||||
|
||||
it 'is sent to the new user' do
|
||||
should deliver_to email.user.email
|
||||
is_expected.to deliver_to email.user.email
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /^Email was added to your account$/i
|
||||
is_expected.to have_subject /^Email was added to your account$/i
|
||||
end
|
||||
|
||||
it 'contains the new email address' do
|
||||
should have_body_text /#{email.email}/
|
||||
is_expected.to have_body_text /#{email.email}/
|
||||
end
|
||||
|
||||
it 'includes a link to emails page' do
|
||||
should have_body_text /#{profile_emails_path}/
|
||||
is_expected.to have_body_text /#{profile_emails_path}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -170,12 +170,12 @@ describe Notify do
|
|||
shared_examples 'an assignee email' do
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(current_user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(current_user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'is sent to the assignee' do
|
||||
should deliver_to assignee.email
|
||||
is_expected.to deliver_to assignee.email
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -190,11 +190,11 @@ describe Notify do
|
|||
it_behaves_like 'an email starting a new thread', 'issue'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
|
||||
is_expected.to have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains a link to the new issue' do
|
||||
should have_body_text /#{project_issue_path project, issue}/
|
||||
is_expected.to have_body_text /#{project_issue_path project, issue}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ describe Notify do
|
|||
subject { Notify.new_issue_email(issue_with_description.assignee_id, issue_with_description.id) }
|
||||
|
||||
it 'contains the description' do
|
||||
should have_body_text /#{issue_with_description.description}/
|
||||
is_expected.to have_body_text /#{issue_with_description.description}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -214,24 +214,24 @@ describe Notify do
|
|||
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(current_user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(current_user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{issue.title} \(##{issue.iid}\)/
|
||||
is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains the name of the previous assignee' do
|
||||
should have_body_text /#{previous_assignee.name}/
|
||||
is_expected.to have_body_text /#{previous_assignee.name}/
|
||||
end
|
||||
|
||||
it 'contains the name of the new assignee' do
|
||||
should have_body_text /#{assignee.name}/
|
||||
is_expected.to have_body_text /#{assignee.name}/
|
||||
end
|
||||
|
||||
it 'contains a link to the issue' do
|
||||
should have_body_text /#{project_issue_path project, issue}/
|
||||
is_expected.to have_body_text /#{project_issue_path project, issue}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -243,24 +243,24 @@ describe Notify do
|
|||
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(current_user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(current_user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{issue.title} \(##{issue.iid}\)/i
|
||||
is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/i
|
||||
end
|
||||
|
||||
it 'contains the new status' do
|
||||
should have_body_text /#{status}/i
|
||||
is_expected.to have_body_text /#{status}/i
|
||||
end
|
||||
|
||||
it 'contains the user name' do
|
||||
should have_body_text /#{current_user.name}/i
|
||||
is_expected.to have_body_text /#{current_user.name}/i
|
||||
end
|
||||
|
||||
it 'contains a link to the issue' do
|
||||
should have_body_text /#{project_issue_path project, issue}/
|
||||
is_expected.to have_body_text /#{project_issue_path project, issue}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -278,23 +278,23 @@ describe Notify do
|
|||
it_behaves_like 'an email starting a new thread', 'merge_request'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains a link to the new merge request' do
|
||||
should have_body_text /#{project_merge_request_path(project, merge_request)}/
|
||||
is_expected.to have_body_text /#{project_merge_request_path(project, merge_request)}/
|
||||
end
|
||||
|
||||
it 'contains the source branch for the merge request' do
|
||||
should have_body_text /#{merge_request.source_branch}/
|
||||
is_expected.to have_body_text /#{merge_request.source_branch}/
|
||||
end
|
||||
|
||||
it 'contains the target branch for the merge request' do
|
||||
should have_body_text /#{merge_request.target_branch}/
|
||||
is_expected.to have_body_text /#{merge_request.target_branch}/
|
||||
end
|
||||
|
||||
it 'has the correct message-id set' do
|
||||
should have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
|
||||
is_expected.to have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ describe Notify do
|
|||
subject { Notify.new_merge_request_email(merge_request_with_description.assignee_id, merge_request_with_description.id) }
|
||||
|
||||
it 'contains the description' do
|
||||
should have_body_text /#{merge_request_with_description.description}/
|
||||
is_expected.to have_body_text /#{merge_request_with_description.description}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -314,24 +314,24 @@ describe Notify do
|
|||
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(current_user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(current_user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains the name of the previous assignee' do
|
||||
should have_body_text /#{previous_assignee.name}/
|
||||
is_expected.to have_body_text /#{previous_assignee.name}/
|
||||
end
|
||||
|
||||
it 'contains the name of the new assignee' do
|
||||
should have_body_text /#{assignee.name}/
|
||||
is_expected.to have_body_text /#{assignee.name}/
|
||||
end
|
||||
|
||||
it 'contains a link to the merge request' do
|
||||
should have_body_text /#{project_merge_request_path project, merge_request}/
|
||||
is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -343,24 +343,24 @@ describe Notify do
|
|||
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(current_user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(current_user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i
|
||||
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i
|
||||
end
|
||||
|
||||
it 'contains the new status' do
|
||||
should have_body_text /#{status}/i
|
||||
is_expected.to have_body_text /#{status}/i
|
||||
end
|
||||
|
||||
it 'contains the user name' do
|
||||
should have_body_text /#{current_user.name}/i
|
||||
is_expected.to have_body_text /#{current_user.name}/i
|
||||
end
|
||||
|
||||
it 'contains a link to the merge request' do
|
||||
should have_body_text /#{project_merge_request_path project, merge_request}/
|
||||
is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -372,20 +372,20 @@ describe Notify do
|
|||
|
||||
it 'is sent as the merge author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(merge_author.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(merge_author.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains the new status' do
|
||||
should have_body_text /merged/i
|
||||
is_expected.to have_body_text /merged/i
|
||||
end
|
||||
|
||||
it 'contains a link to the merge request' do
|
||||
should have_body_text /#{project_merge_request_path project, merge_request}/
|
||||
is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -399,15 +399,15 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /Project was moved/
|
||||
is_expected.to have_subject /Project was moved/
|
||||
end
|
||||
|
||||
it 'contains name of project' do
|
||||
should have_body_text /#{project.name_with_namespace}/
|
||||
is_expected.to have_body_text /#{project.name_with_namespace}/
|
||||
end
|
||||
|
||||
it 'contains new user role' do
|
||||
should have_body_text /#{project.ssh_url_to_repo}/
|
||||
is_expected.to have_body_text /#{project.ssh_url_to_repo}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -422,13 +422,13 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /Access to project was granted/
|
||||
is_expected.to have_subject /Access to project was granted/
|
||||
end
|
||||
it 'contains name of project' do
|
||||
should have_body_text /#{project.name}/
|
||||
is_expected.to have_body_text /#{project.name}/
|
||||
end
|
||||
it 'contains new user role' do
|
||||
should have_body_text /#{project_member.human_access}/
|
||||
is_expected.to have_body_text /#{project_member.human_access}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -437,29 +437,29 @@ describe Notify do
|
|||
let(:note) { create(:note, project: project, author: note_author) }
|
||||
|
||||
before :each do
|
||||
Note.stub(:find).with(note.id).and_return(note)
|
||||
allow(Note).to receive(:find).with(note.id).and_return(note)
|
||||
end
|
||||
|
||||
shared_examples 'a note email' do
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(note_author.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(note_author.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'is sent to the given recipient' do
|
||||
should deliver_to recipient.notification_email
|
||||
is_expected.to deliver_to recipient.notification_email
|
||||
end
|
||||
|
||||
it 'contains the message from the note' do
|
||||
should have_body_text /#{note.note}/
|
||||
is_expected.to have_body_text /#{note.note}/
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on a commit' do
|
||||
let(:commit) { project.repository.commit }
|
||||
|
||||
before(:each) { note.stub(:noteable).and_return(commit) }
|
||||
before(:each) { allow(note).to receive(:noteable).and_return(commit) }
|
||||
|
||||
subject { Notify.note_commit_email(recipient.id, note.id) }
|
||||
|
||||
|
|
@ -467,18 +467,18 @@ describe Notify do
|
|||
it_behaves_like 'an answer to an existing thread', 'commits'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{commit.title} \(#{commit.short_id}\)/
|
||||
is_expected.to have_subject /#{commit.title} \(#{commit.short_id}\)/
|
||||
end
|
||||
|
||||
it 'contains a link to the commit' do
|
||||
should have_body_text commit.short_id
|
||||
is_expected.to have_body_text commit.short_id
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on a merge request' do
|
||||
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
|
||||
let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") }
|
||||
before(:each) { note.stub(:noteable).and_return(merge_request) }
|
||||
before(:each) { allow(note).to receive(:noteable).and_return(merge_request) }
|
||||
|
||||
subject { Notify.note_merge_request_email(recipient.id, note.id) }
|
||||
|
||||
|
|
@ -486,18 +486,18 @@ describe Notify do
|
|||
it_behaves_like 'an answer to an existing thread', 'merge_request'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains a link to the merge request note' do
|
||||
should have_body_text /#{note_on_merge_request_path}/
|
||||
is_expected.to have_body_text /#{note_on_merge_request_path}/
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on an issue' do
|
||||
let(:issue) { create(:issue, project: project) }
|
||||
let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
|
||||
before(:each) { note.stub(:noteable).and_return(issue) }
|
||||
before(:each) { allow(note).to receive(:noteable).and_return(issue) }
|
||||
|
||||
subject { Notify.note_issue_email(recipient.id, note.id) }
|
||||
|
||||
|
|
@ -505,11 +505,11 @@ describe Notify do
|
|||
it_behaves_like 'an answer to an existing thread', 'issue'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{issue.title} \(##{issue.iid}\)/
|
||||
is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/
|
||||
end
|
||||
|
||||
it 'contains a link to the issue note' do
|
||||
should have_body_text /#{note_on_issue_path}/
|
||||
is_expected.to have_body_text /#{note_on_issue_path}/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -525,15 +525,15 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /Access to group was granted/
|
||||
is_expected.to have_subject /Access to group was granted/
|
||||
end
|
||||
|
||||
it 'contains name of project' do
|
||||
should have_body_text /#{group.name}/
|
||||
is_expected.to have_body_text /#{group.name}/
|
||||
end
|
||||
|
||||
it 'contains new user role' do
|
||||
should have_body_text /#{membership.human_access}/
|
||||
is_expected.to have_body_text /#{membership.human_access}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -551,15 +551,15 @@ describe Notify do
|
|||
it_behaves_like 'an email sent from GitLab'
|
||||
|
||||
it 'is sent to the new user' do
|
||||
should deliver_to 'new-email@mail.com'
|
||||
is_expected.to deliver_to 'new-email@mail.com'
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject "Confirmation instructions"
|
||||
is_expected.to have_subject "Confirmation instructions"
|
||||
end
|
||||
|
||||
it 'includes a link to the site' do
|
||||
should have_body_text /#{example_site_path}/
|
||||
is_expected.to have_body_text /#{example_site_path}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -574,28 +574,28 @@ describe Notify do
|
|||
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'is sent to recipient' do
|
||||
should deliver_to 'devs@company.name'
|
||||
is_expected.to deliver_to 'devs@company.name'
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{commits.length} new commits pushed to repository/
|
||||
is_expected.to have_subject /#{commits.length} new commits pushed to repository/
|
||||
end
|
||||
|
||||
it 'includes commits list' do
|
||||
should have_body_text /Change some files/
|
||||
is_expected.to have_body_text /Change some files/
|
||||
end
|
||||
|
||||
it 'includes diffs' do
|
||||
should have_body_text /def archive_formats_regex/
|
||||
is_expected.to have_body_text /def archive_formats_regex/
|
||||
end
|
||||
|
||||
it 'contains a link to the diff' do
|
||||
should have_body_text /#{diff_path}/
|
||||
is_expected.to have_body_text /#{diff_path}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -610,28 +610,28 @@ describe Notify do
|
|||
|
||||
it 'is sent as the author' do
|
||||
sender = subject.header[:from].addrs[0]
|
||||
sender.display_name.should eq(user.name)
|
||||
sender.address.should eq(gitlab_sender)
|
||||
expect(sender.display_name).to eq(user.name)
|
||||
expect(sender.address).to eq(gitlab_sender)
|
||||
end
|
||||
|
||||
it 'is sent to recipient' do
|
||||
should deliver_to 'devs@company.name'
|
||||
is_expected.to deliver_to 'devs@company.name'
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /#{commits.first.title}/
|
||||
is_expected.to have_subject /#{commits.first.title}/
|
||||
end
|
||||
|
||||
it 'includes commits list' do
|
||||
should have_body_text /Change some files/
|
||||
is_expected.to have_body_text /Change some files/
|
||||
end
|
||||
|
||||
it 'includes diffs' do
|
||||
should have_body_text /def archive_formats_regex/
|
||||
is_expected.to have_body_text /def archive_formats_regex/
|
||||
end
|
||||
|
||||
it 'contains a link to the diff' do
|
||||
should have_body_text /#{diff_path}/
|
||||
is_expected.to have_body_text /#{diff_path}/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,5 +17,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ApplicationSetting, models: true do
|
||||
it { ApplicationSetting.create_from_defaults.should be_valid }
|
||||
it { expect(ApplicationSetting.create_from_defaults).to be_valid }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ require 'spec_helper'
|
|||
|
||||
describe AsanaService, models: true do
|
||||
describe 'Associations' do
|
||||
it { should belong_to :project }
|
||||
it { should have_one :service_hook }
|
||||
it { is_expected.to belong_to :project }
|
||||
it { is_expected.to have_one :service_hook }
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
|
|
@ -26,7 +26,7 @@ describe AsanaService, models: true do
|
|||
subject.active = true
|
||||
end
|
||||
|
||||
it { should validate_presence_of :api_key }
|
||||
it { is_expected.to validate_presence_of :api_key }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ describe AsanaService, models: true do
|
|||
end
|
||||
|
||||
it 'should call Asana service to created a story' do
|
||||
Asana::Task.should_receive(:find).with('123456').once
|
||||
expect(Asana::Task).to receive(:find).with('123456').once
|
||||
|
||||
@asana.check_commit('related to #123456', 'pushed')
|
||||
end
|
||||
|
||||
it 'should call Asana service to created a story and close a task' do
|
||||
Asana::Task.should_receive(:find).with('456789').twice
|
||||
expect(Asana::Task).to receive(:find).with('456789').twice
|
||||
|
||||
@asana.check_commit('fix #456789', 'pushed')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,22 +18,22 @@ require 'spec_helper'
|
|||
describe BroadcastMessage do
|
||||
subject { create(:broadcast_message) }
|
||||
|
||||
it { should be_valid }
|
||||
it { is_expected.to be_valid }
|
||||
|
||||
describe :current do
|
||||
it "should return last message if time match" do
|
||||
broadcast_message = create(:broadcast_message, starts_at: Time.now.yesterday, ends_at: Time.now.tomorrow)
|
||||
BroadcastMessage.current.should == broadcast_message
|
||||
expect(BroadcastMessage.current).to eq(broadcast_message)
|
||||
end
|
||||
|
||||
it "should return nil if time not come" do
|
||||
broadcast_message = create(:broadcast_message, starts_at: Time.now.tomorrow, ends_at: Time.now + 2.days)
|
||||
BroadcastMessage.current.should be_nil
|
||||
expect(BroadcastMessage.current).to be_nil
|
||||
end
|
||||
|
||||
it "should return nil if time has passed" do
|
||||
broadcast_message = create(:broadcast_message, starts_at: Time.now - 2.days, ends_at: Time.now.yesterday)
|
||||
BroadcastMessage.current.should be_nil
|
||||
expect(BroadcastMessage.current).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@ describe Commit do
|
|||
|
||||
describe '#title' do
|
||||
it "returns no_commit_message when safe_message is blank" do
|
||||
commit.stub(:safe_message).and_return('')
|
||||
commit.title.should == "--no commit message"
|
||||
allow(commit).to receive(:safe_message).and_return('')
|
||||
expect(commit.title).to eq("--no commit message")
|
||||
end
|
||||
|
||||
it "truncates a message without a newline at 80 characters" do
|
||||
message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.'
|
||||
|
||||
commit.stub(:safe_message).and_return(message)
|
||||
commit.title.should == "#{message[0..79]}…"
|
||||
allow(commit).to receive(:safe_message).and_return(message)
|
||||
expect(commit.title).to eq("#{message[0..79]}…")
|
||||
end
|
||||
|
||||
it "truncates a message with a newline before 80 characters at the newline" do
|
||||
message = commit.safe_message.split(" ").first
|
||||
|
||||
commit.stub(:safe_message).and_return(message + "\n" + message)
|
||||
commit.title.should == message
|
||||
allow(commit).to receive(:safe_message).and_return(message + "\n" + message)
|
||||
expect(commit.title).to eq(message)
|
||||
end
|
||||
|
||||
it "does not truncates a message with a newline after 80 but less 100 characters" do
|
||||
|
|
@ -30,25 +30,25 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis
|
|||
Vivamus egestas lacinia lacus, sed rutrum mauris.
|
||||
eos
|
||||
|
||||
commit.stub(:safe_message).and_return(message)
|
||||
commit.title.should == message.split("\n").first
|
||||
allow(commit).to receive(:safe_message).and_return(message)
|
||||
expect(commit.title).to eq(message.split("\n").first)
|
||||
end
|
||||
end
|
||||
|
||||
describe "delegation" do
|
||||
subject { commit }
|
||||
|
||||
it { should respond_to(:message) }
|
||||
it { should respond_to(:authored_date) }
|
||||
it { should respond_to(:committed_date) }
|
||||
it { should respond_to(:committer_email) }
|
||||
it { should respond_to(:author_email) }
|
||||
it { should respond_to(:parents) }
|
||||
it { should respond_to(:date) }
|
||||
it { should respond_to(:diffs) }
|
||||
it { should respond_to(:tree) }
|
||||
it { should respond_to(:id) }
|
||||
it { should respond_to(:to_patch) }
|
||||
it { is_expected.to respond_to(:message) }
|
||||
it { is_expected.to respond_to(:authored_date) }
|
||||
it { is_expected.to respond_to(:committed_date) }
|
||||
it { is_expected.to respond_to(:committer_email) }
|
||||
it { is_expected.to respond_to(:author_email) }
|
||||
it { is_expected.to respond_to(:parents) }
|
||||
it { is_expected.to respond_to(:date) }
|
||||
it { is_expected.to respond_to(:diffs) }
|
||||
it { is_expected.to respond_to(:tree) }
|
||||
it { is_expected.to respond_to(:id) }
|
||||
it { is_expected.to respond_to(:to_patch) }
|
||||
end
|
||||
|
||||
describe '#closes_issues' do
|
||||
|
|
@ -58,13 +58,13 @@ eos
|
|||
|
||||
it 'detects issues that this commit is marked as closing' do
|
||||
commit.stub(safe_message: "Fixes ##{issue.iid}")
|
||||
commit.closes_issues(project).should == [issue]
|
||||
expect(commit.closes_issues(project)).to eq([issue])
|
||||
end
|
||||
|
||||
it 'does not detect issues from other projects' do
|
||||
ext_ref = "#{other_project.path_with_namespace}##{other_issue.iid}"
|
||||
commit.stub(safe_message: "Fixes #{ext_ref}")
|
||||
commit.closes_issues(project).should be_empty
|
||||
expect(commit.closes_issues(project)).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,63 +4,63 @@ describe Issue, "Issuable" do
|
|||
let(:issue) { create(:issue) }
|
||||
|
||||
describe "Associations" do
|
||||
it { should belong_to(:project) }
|
||||
it { should belong_to(:author) }
|
||||
it { should belong_to(:assignee) }
|
||||
it { should have_many(:notes).dependent(:destroy) }
|
||||
it { is_expected.to belong_to(:project) }
|
||||
it { is_expected.to belong_to(:author) }
|
||||
it { is_expected.to belong_to(:assignee) }
|
||||
it { is_expected.to have_many(:notes).dependent(:destroy) }
|
||||
end
|
||||
|
||||
describe "Validation" do
|
||||
before { subject.stub(set_iid: false) }
|
||||
it { should validate_presence_of(:project) }
|
||||
it { should validate_presence_of(:iid) }
|
||||
it { should validate_presence_of(:author) }
|
||||
it { should validate_presence_of(:title) }
|
||||
it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) }
|
||||
it { is_expected.to validate_presence_of(:project) }
|
||||
it { is_expected.to validate_presence_of(:iid) }
|
||||
it { is_expected.to validate_presence_of(:author) }
|
||||
it { is_expected.to validate_presence_of(:title) }
|
||||
it { is_expected.to ensure_length_of(:title).is_at_least(0).is_at_most(255) }
|
||||
end
|
||||
|
||||
describe "Scope" do
|
||||
it { described_class.should respond_to(:opened) }
|
||||
it { described_class.should respond_to(:closed) }
|
||||
it { described_class.should respond_to(:assigned) }
|
||||
it { expect(described_class).to respond_to(:opened) }
|
||||
it { expect(described_class).to respond_to(:closed) }
|
||||
it { expect(described_class).to respond_to(:assigned) }
|
||||
end
|
||||
|
||||
describe ".search" do
|
||||
let!(:searchable_issue) { create(:issue, title: "Searchable issue") }
|
||||
|
||||
it "matches by title" do
|
||||
described_class.search('able').should == [searchable_issue]
|
||||
expect(described_class.search('able')).to eq([searchable_issue])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#today?" do
|
||||
it "returns true when created today" do
|
||||
# Avoid timezone differences and just return exactly what we want
|
||||
Date.stub(:today).and_return(issue.created_at.to_date)
|
||||
issue.today?.should be_true
|
||||
allow(Date).to receive(:today).and_return(issue.created_at.to_date)
|
||||
expect(issue.today?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false when not created today" do
|
||||
Date.stub(:today).and_return(Date.yesterday)
|
||||
issue.today?.should be_false
|
||||
allow(Date).to receive(:today).and_return(Date.yesterday)
|
||||
expect(issue.today?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
describe "#new?" do
|
||||
it "returns true when created today and record hasn't been updated" do
|
||||
issue.stub(:today?).and_return(true)
|
||||
issue.new?.should be_true
|
||||
allow(issue).to receive(:today?).and_return(true)
|
||||
expect(issue.new?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns false when not created today" do
|
||||
issue.stub(:today?).and_return(false)
|
||||
issue.new?.should be_false
|
||||
allow(issue).to receive(:today?).and_return(false)
|
||||
expect(issue.new?).to be_falsey
|
||||
end
|
||||
|
||||
it "returns false when record has been updated" do
|
||||
issue.stub(:today?).and_return(true)
|
||||
allow(issue).to receive(:today?).and_return(true)
|
||||
issue.touch
|
||||
issue.new?.should be_false
|
||||
expect(issue.new?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ describe Issue, "Mentionable" do
|
|||
|
||||
subject { issue.mentioned_users }
|
||||
|
||||
it { should include(user) }
|
||||
it { should_not include(user2) }
|
||||
it { is_expected.to include(user) }
|
||||
it { is_expected.not_to include(user2) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ describe DeployKey do
|
|||
let(:deploy_key) { create(:deploy_key, projects: [project]) }
|
||||
|
||||
describe "Associations" do
|
||||
it { should have_many(:deploy_keys_projects) }
|
||||
it { should have_many(:projects) }
|
||||
it { is_expected.to have_many(:deploy_keys_projects) }
|
||||
it { is_expected.to have_many(:projects) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ require 'spec_helper'
|
|||
|
||||
describe DeployKeysProject do
|
||||
describe "Associations" do
|
||||
it { should belong_to(:deploy_key) }
|
||||
it { should belong_to(:project) }
|
||||
it { is_expected.to belong_to(:deploy_key) }
|
||||
it { is_expected.to belong_to(:project) }
|
||||
end
|
||||
|
||||
describe "Validation" do
|
||||
it { should validate_presence_of(:project_id) }
|
||||
it { should validate_presence_of(:deploy_key_id) }
|
||||
it { is_expected.to validate_presence_of(:project_id) }
|
||||
it { is_expected.to validate_presence_of(:deploy_key_id) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ require 'spec_helper'
|
|||
|
||||
describe Event do
|
||||
describe "Associations" do
|
||||
it { should belong_to(:project) }
|
||||
it { should belong_to(:target) }
|
||||
it { is_expected.to belong_to(:project) }
|
||||
it { is_expected.to belong_to(:target) }
|
||||
end
|
||||
|
||||
describe "Respond to" do
|
||||
it { should respond_to(:author_name) }
|
||||
it { should respond_to(:author_email) }
|
||||
it { should respond_to(:issue_title) }
|
||||
it { should respond_to(:merge_request_title) }
|
||||
it { should respond_to(:commits) }
|
||||
it { is_expected.to respond_to(:author_name) }
|
||||
it { is_expected.to respond_to(:author_email) }
|
||||
it { is_expected.to respond_to(:issue_title) }
|
||||
it { is_expected.to respond_to(:merge_request_title) }
|
||||
it { is_expected.to respond_to(:commits) }
|
||||
end
|
||||
|
||||
describe "Push event" do
|
||||
|
|
@ -58,10 +58,10 @@ describe Event do
|
|||
)
|
||||
end
|
||||
|
||||
it { @event.push?.should be_true }
|
||||
it { @event.proper?.should be_true }
|
||||
it { @event.tag?.should be_false }
|
||||
it { @event.branch_name.should == "master" }
|
||||
it { @event.author.should == @user }
|
||||
it { expect(@event.push?).to be_truthy }
|
||||
it { expect(@event.proper?).to be_truthy }
|
||||
it { expect(@event.tag?).to be_falsey }
|
||||
it { expect(@event.branch_name).to eq("master") }
|
||||
it { expect(@event.author).to eq(@user) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ describe ForkedProjectLink, "add link on fork" do
|
|||
end
|
||||
|
||||
it "project_to should know it is forked" do
|
||||
@project_to.forked?.should be_true
|
||||
expect(@project_to.forked?).to be_truthy
|
||||
end
|
||||
|
||||
it "project should know who it is forked from" do
|
||||
@project_to.forked_from_project.should == project_from
|
||||
expect(@project_to.forked_from_project).to eq(project_from)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -43,15 +43,15 @@ describe :forked_from_project do
|
|||
|
||||
|
||||
it "project_to should know it is forked" do
|
||||
project_to.forked?.should be_true
|
||||
expect(project_to.forked?).to be_truthy
|
||||
end
|
||||
|
||||
it "project_from should not be forked" do
|
||||
project_from.forked?.should be_false
|
||||
expect(project_from.forked?).to be_falsey
|
||||
end
|
||||
|
||||
it "project_to.destroy should destroy fork_link" do
|
||||
forked_project_link.should_receive(:destroy)
|
||||
expect(forked_project_link).to receive(:destroy)
|
||||
project_to.destroy
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -19,29 +19,29 @@ describe Group do
|
|||
let!(:group) { create(:group) }
|
||||
|
||||
describe "Associations" do
|
||||
it { should have_many :projects }
|
||||
it { should have_many :group_members }
|
||||
it { is_expected.to have_many :projects }
|
||||
it { is_expected.to have_many :group_members }
|
||||
end
|
||||
|
||||
it { should validate_presence_of :name }
|
||||
it { should validate_uniqueness_of(:name) }
|
||||
it { should validate_presence_of :path }
|
||||
it { should validate_uniqueness_of(:path) }
|
||||
it { should_not validate_presence_of :owner }
|
||||
it { is_expected.to validate_presence_of :name }
|
||||
it { is_expected.to validate_uniqueness_of(:name) }
|
||||
it { is_expected.to validate_presence_of :path }
|
||||
it { is_expected.to validate_uniqueness_of(:path) }
|
||||
it { is_expected.not_to validate_presence_of :owner }
|
||||
|
||||
describe :users do
|
||||
it { group.users.should == group.owners }
|
||||
it { expect(group.users).to eq(group.owners) }
|
||||
end
|
||||
|
||||
describe :human_name do
|
||||
it { group.human_name.should == group.name }
|
||||
it { expect(group.human_name).to eq(group.name) }
|
||||
end
|
||||
|
||||
describe :add_users do
|
||||
let(:user) { create(:user) }
|
||||
before { group.add_user(user, GroupMember::MASTER) }
|
||||
|
||||
it { group.group_members.masters.map(&:user).should include(user) }
|
||||
it { expect(group.group_members.masters.map(&:user)).to include(user) }
|
||||
end
|
||||
|
||||
describe :add_users do
|
||||
|
|
@ -49,10 +49,10 @@ describe Group do
|
|||
before { group.add_users([user.id], GroupMember::GUEST) }
|
||||
|
||||
it "should update the group permission" do
|
||||
group.group_members.guests.map(&:user).should include(user)
|
||||
expect(group.group_members.guests.map(&:user)).to include(user)
|
||||
group.add_users([user.id], GroupMember::DEVELOPER)
|
||||
group.group_members.developers.map(&:user).should include(user)
|
||||
group.group_members.guests.map(&:user).should_not include(user)
|
||||
expect(group.group_members.developers.map(&:user)).to include(user)
|
||||
expect(group.group_members.guests.map(&:user)).not_to include(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -62,12 +62,12 @@ describe Group do
|
|||
|
||||
it "should be true if avatar is image" do
|
||||
group.update_attribute(:avatar, 'uploads/avatar.png')
|
||||
group.avatar_type.should be_true
|
||||
expect(group.avatar_type).to be_truthy
|
||||
end
|
||||
|
||||
it "should be false if avatar is html page" do
|
||||
group.update_attribute(:avatar, 'uploads/avatar.html')
|
||||
group.avatar_type.should == ["only images allowed"]
|
||||
expect(group.avatar_type).to eq(["only images allowed"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ require "spec_helper"
|
|||
|
||||
describe ServiceHook do
|
||||
describe "Associations" do
|
||||
it { should belong_to :service }
|
||||
it { is_expected.to belong_to :service }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,32 +26,32 @@ describe SystemHook do
|
|||
|
||||
it "project_create hook" do
|
||||
Projects::CreateService.new(create(:user), name: 'empty').execute
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_create/).once
|
||||
end
|
||||
|
||||
it "project_destroy hook" do
|
||||
user = create(:user)
|
||||
project = create(:empty_project, namespace: user.namespace)
|
||||
Projects::DestroyService.new(project, user, {}).execute
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
|
||||
end
|
||||
|
||||
it "user_create hook" do
|
||||
create(:user)
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_create/).once
|
||||
end
|
||||
|
||||
it "user_destroy hook" do
|
||||
user = create(:user)
|
||||
user.destroy
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
|
||||
end
|
||||
|
||||
it "project_create hook" do
|
||||
user = create(:user)
|
||||
project = create(:project)
|
||||
project.team << [user, :master]
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
|
||||
end
|
||||
|
||||
it "project_destroy hook" do
|
||||
|
|
@ -59,12 +59,12 @@ describe SystemHook do
|
|||
project = create(:project)
|
||||
project.team << [user, :master]
|
||||
project.project_members.destroy_all
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
|
||||
end
|
||||
|
||||
it 'group create hook' do
|
||||
create(:group)
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(
|
||||
body: /group_create/
|
||||
).once
|
||||
end
|
||||
|
|
@ -72,7 +72,7 @@ describe SystemHook do
|
|||
it 'group destroy hook' do
|
||||
group = create(:group)
|
||||
group.destroy
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(
|
||||
body: /group_destroy/
|
||||
).once
|
||||
end
|
||||
|
|
@ -81,7 +81,7 @@ describe SystemHook do
|
|||
group = create(:group)
|
||||
user = create(:user)
|
||||
group.add_user(user, Gitlab::Access::MASTER)
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(
|
||||
body: /user_add_to_group/
|
||||
).once
|
||||
end
|
||||
|
|
@ -91,7 +91,7 @@ describe SystemHook do
|
|||
user = create(:user)
|
||||
group.add_user(user, Gitlab::Access::MASTER)
|
||||
group.group_members.destroy_all
|
||||
WebMock.should have_requested(:post, @system_hook.url).with(
|
||||
expect(WebMock).to have_requested(:post, @system_hook.url).with(
|
||||
body: /user_remove_from_group/
|
||||
).once
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,25 +19,25 @@ require 'spec_helper'
|
|||
|
||||
describe ProjectHook do
|
||||
describe "Associations" do
|
||||
it { should belong_to :project }
|
||||
it { is_expected.to belong_to :project }
|
||||
end
|
||||
|
||||
describe "Mass assignment" do
|
||||
end
|
||||
|
||||
describe "Validations" do
|
||||
it { should validate_presence_of(:url) }
|
||||
it { is_expected.to validate_presence_of(:url) }
|
||||
|
||||
context "url format" do
|
||||
it { should allow_value("http://example.com").for(:url) }
|
||||
it { should allow_value("https://excample.com").for(:url) }
|
||||
it { should allow_value("http://test.com/api").for(:url) }
|
||||
it { should allow_value("http://test.com/api?key=abc").for(:url) }
|
||||
it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) }
|
||||
it { is_expected.to allow_value("http://example.com").for(:url) }
|
||||
it { is_expected.to allow_value("https://excample.com").for(:url) }
|
||||
it { is_expected.to allow_value("http://test.com/api").for(:url) }
|
||||
it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
|
||||
it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
|
||||
|
||||
it { should_not allow_value("example.com").for(:url) }
|
||||
it { should_not allow_value("ftp://example.com").for(:url) }
|
||||
it { should_not allow_value("herp-and-derp").for(:url) }
|
||||
it { is_expected.not_to allow_value("example.com").for(:url) }
|
||||
it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
|
||||
it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -53,22 +53,22 @@ describe ProjectHook do
|
|||
|
||||
it "POSTs to the web hook URL" do
|
||||
@project_hook.execute(@data)
|
||||
WebMock.should have_requested(:post, @project_hook.url).once
|
||||
expect(WebMock).to have_requested(:post, @project_hook.url).once
|
||||
end
|
||||
|
||||
it "POSTs the data as JSON" do
|
||||
json = @data.to_json
|
||||
|
||||
@project_hook.execute(@data)
|
||||
WebMock.should have_requested(:post, @project_hook.url).with(body: json).once
|
||||
expect(WebMock).to have_requested(:post, @project_hook.url).with(body: json).once
|
||||
end
|
||||
|
||||
it "catches exceptions" do
|
||||
WebHook.should_receive(:post).and_raise("Some HTTP Post error")
|
||||
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
|
||||
|
||||
lambda {
|
||||
expect {
|
||||
@project_hook.execute(@data)
|
||||
}.should raise_error
|
||||
}.to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ require 'spec_helper'
|
|||
|
||||
describe Issue do
|
||||
describe "Associations" do
|
||||
it { should belong_to(:milestone) }
|
||||
it { is_expected.to belong_to(:milestone) }
|
||||
end
|
||||
|
||||
describe "Mass assignment" do
|
||||
end
|
||||
|
||||
describe 'modules' do
|
||||
it { should include_module(Issuable) }
|
||||
it { is_expected.to include_module(Issuable) }
|
||||
end
|
||||
|
||||
subject { create(:issue) }
|
||||
|
|
@ -36,10 +36,10 @@ describe Issue do
|
|||
describe '#is_being_reassigned?' do
|
||||
it 'returns true if the issue assignee has changed' do
|
||||
subject.assignee = create(:user)
|
||||
subject.is_being_reassigned?.should be_true
|
||||
expect(subject.is_being_reassigned?).to be_truthy
|
||||
end
|
||||
it 'returns false if the issue assignee has not changed' do
|
||||
subject.is_being_reassigned?.should be_false
|
||||
expect(subject.is_being_reassigned?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ describe Issue do
|
|||
issue = create :issue, assignee: user
|
||||
end
|
||||
|
||||
Issue.open_for(user).count.should eq 2
|
||||
expect(Issue.open_for(user).count).to eq 2
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,67 +16,67 @@ require 'spec_helper'
|
|||
|
||||
describe Key do
|
||||
describe "Associations" do
|
||||
it { should belong_to(:user) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe "Mass assignment" do
|
||||
end
|
||||
|
||||
describe "Validation" do
|
||||
it { should validate_presence_of(:title) }
|
||||
it { should validate_presence_of(:key) }
|
||||
it { should ensure_length_of(:title).is_within(0..255) }
|
||||
it { should ensure_length_of(:key).is_within(0..5000) }
|
||||
it { is_expected.to validate_presence_of(:title) }
|
||||
it { is_expected.to validate_presence_of(:key) }
|
||||
it { is_expected.to ensure_length_of(:title).is_within(0..255) }
|
||||
it { is_expected.to ensure_length_of(:key).is_within(0..5000) }
|
||||
end
|
||||
|
||||
describe "Methods" do
|
||||
it { should respond_to :projects }
|
||||
it { is_expected.to respond_to :projects }
|
||||
end
|
||||
|
||||
context "validation of uniqueness" do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "accepts the key once" do
|
||||
build(:key, user: user).should be_valid
|
||||
expect(build(:key, user: user)).to be_valid
|
||||
end
|
||||
|
||||
it "does not accept the exact same key twice" do
|
||||
create(:key, user: user)
|
||||
build(:key, user: user).should_not be_valid
|
||||
expect(build(:key, user: user)).not_to be_valid
|
||||
end
|
||||
|
||||
it "does not accept a duplicate key with a different comment" do
|
||||
create(:key, user: user)
|
||||
duplicate = build(:key, user: user)
|
||||
duplicate.key << ' extra comment'
|
||||
duplicate.should_not be_valid
|
||||
expect(duplicate).not_to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "validate it is a fingerprintable key" do
|
||||
it "accepts the fingerprintable key" do
|
||||
build(:key).should be_valid
|
||||
expect(build(:key)).to be_valid
|
||||
end
|
||||
|
||||
it "rejects the unfingerprintable key (contains space in middle)" do
|
||||
build(:key_with_a_space_in_the_middle).should_not be_valid
|
||||
expect(build(:key_with_a_space_in_the_middle)).not_to be_valid
|
||||
end
|
||||
|
||||
it "rejects the unfingerprintable key (not a key)" do
|
||||
build(:invalid_key).should_not be_valid
|
||||
expect(build(:invalid_key)).not_to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context 'callbacks' do
|
||||
it 'should add new key to authorized_file' do
|
||||
@key = build(:personal_key, id: 7)
|
||||
GitlabShellWorker.should_receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
|
||||
expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
|
||||
@key.save
|
||||
end
|
||||
|
||||
it 'should remove key from authorized_file' do
|
||||
@key = create(:personal_key)
|
||||
GitlabShellWorker.should_receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
|
||||
expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
|
||||
@key.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ require 'spec_helper'
|
|||
|
||||
describe LabelLink do
|
||||
let(:label) { create(:label_link) }
|
||||
it { label.should be_valid }
|
||||
it { expect(label).to be_valid }
|
||||
|
||||
it { should belong_to(:label) }
|
||||
it { should belong_to(:target) }
|
||||
it { is_expected.to belong_to(:label) }
|
||||
it { is_expected.to belong_to(:target) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,30 +14,30 @@ require 'spec_helper'
|
|||
|
||||
describe Label do
|
||||
let(:label) { create(:label) }
|
||||
it { label.should be_valid }
|
||||
it { expect(label).to be_valid }
|
||||
|
||||
it { should belong_to(:project) }
|
||||
it { is_expected.to belong_to(:project) }
|
||||
|
||||
describe 'Validation' do
|
||||
it 'should validate color code' do
|
||||
build(:label, color: 'G-ITLAB').should_not be_valid
|
||||
build(:label, color: 'AABBCC').should_not be_valid
|
||||
build(:label, color: '#AABBCCEE').should_not be_valid
|
||||
build(:label, color: '#GGHHII').should_not be_valid
|
||||
build(:label, color: '#').should_not be_valid
|
||||
build(:label, color: '').should_not be_valid
|
||||
expect(build(:label, color: 'G-ITLAB')).not_to be_valid
|
||||
expect(build(:label, color: 'AABBCC')).not_to be_valid
|
||||
expect(build(:label, color: '#AABBCCEE')).not_to be_valid
|
||||
expect(build(:label, color: '#GGHHII')).not_to be_valid
|
||||
expect(build(:label, color: '#')).not_to be_valid
|
||||
expect(build(:label, color: '')).not_to be_valid
|
||||
|
||||
build(:label, color: '#AABBCC').should be_valid
|
||||
expect(build(:label, color: '#AABBCC')).to be_valid
|
||||
end
|
||||
|
||||
it 'should validate title' do
|
||||
build(:label, title: 'G,ITLAB').should_not be_valid
|
||||
build(:label, title: 'G?ITLAB').should_not be_valid
|
||||
build(:label, title: 'G&ITLAB').should_not be_valid
|
||||
build(:label, title: '').should_not be_valid
|
||||
expect(build(:label, title: 'G,ITLAB')).not_to be_valid
|
||||
expect(build(:label, title: 'G?ITLAB')).not_to be_valid
|
||||
expect(build(:label, title: 'G&ITLAB')).not_to be_valid
|
||||
expect(build(:label, title: '')).not_to be_valid
|
||||
|
||||
build(:label, title: 'GITLAB').should be_valid
|
||||
build(:label, title: 'gitlab').should be_valid
|
||||
expect(build(:label, title: 'GITLAB')).to be_valid
|
||||
expect(build(:label, title: 'gitlab')).to be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe GroupMember do
|
|||
it "should send email to user" do
|
||||
membership = build(:group_member)
|
||||
membership.stub(notification_service: double('NotificationService').as_null_object)
|
||||
membership.should_receive(:notification_service)
|
||||
expect(membership).to receive(:notification_service)
|
||||
membership.save
|
||||
end
|
||||
end
|
||||
|
|
@ -33,12 +33,12 @@ describe GroupMember do
|
|||
end
|
||||
|
||||
it "should send email to user" do
|
||||
@membership.should_receive(:notification_service)
|
||||
expect(@membership).to receive(:notification_service)
|
||||
@membership.update_attribute(:access_level, GroupMember::MASTER)
|
||||
end
|
||||
|
||||
it "does not send an email when the access level has not changed" do
|
||||
@membership.should_not_receive(:notification_service)
|
||||
expect(@membership).not_to receive(:notification_service)
|
||||
@membership.update_attribute(:access_level, GroupMember::OWNER)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue