Commit 1343b2df authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #8785 from jvanbaarsen/rspec-upgrade

Rspec upgrade
parents f9880c11 68600044
......@@ -222,7 +222,7 @@ group :development, :test do
gem 'rubocop', '0.28.0', require: false
# gem 'rails-dev-tweaks'
gem 'spinach-rails'
gem "rspec-rails"
gem "rspec-rails", '2.99'
gem "capybara", '~> 2.2.1'
gem "pry-rails"
gem "awesome_print"
......
......@@ -459,21 +459,25 @@ GEM
mime-types (>= 1.16)
rinku (1.7.3)
rouge (1.7.4)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
rspec (2.99.0)
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rspec-collection_matchers (1.1.2)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rspec-rails (2.14.0)
rspec-mocks (2.99.3)
rspec-rails (2.99.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-collection_matchers
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
rubocop (0.28.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
......@@ -724,7 +728,7 @@ DEPENDENCIES
redcarpet (~> 3.1.2)
redis-rails
request_store
rspec-rails
rspec-rails (= 2.99)
rubocop (= 0.28.0)
rugments
sanitize (~> 2.0)
......
......@@ -4,4 +4,4 @@ begin
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec', 'rspec')
load Gem.bin_path('rspec-core', 'rspec')
......@@ -17,7 +17,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
end
step 'I should see project "Community" home page' do
Gitlab.config.gitlab.stub(:host).and_return("www.example.com")
Gitlab.config.gitlab.should_receive(:host).and_return("www.example.com")
within '.navbar-gitlab .title' do
page.should have_content 'Community'
end
......
......@@ -47,8 +47,8 @@ Spinach.hooks.after_scenario do
end
Spinach.hooks.before_run do
include RSpec::Mocks::ExampleMethods
TestEnv.init(mailer: false)
RSpec::Mocks::setup self
include FactoryGirl::Syntax::Methods
end
......@@ -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,10 @@ 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 'redirects' do
expect(subject).
to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc")
end
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,31 @@ 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 'redirects' do
expect(subject).
to redirect_to("/#{project.path_with_namespace}/tree/merge_branch")
end
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 'redirects' do
expect(subject).
to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');")
end
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,8 @@ 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,16 @@ 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)
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123", app_secret: "asd123", name: "github")
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 +58,8 @@ 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,8 @@ 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,8 @@ 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,11 @@ 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 'redirects' do
redirect_url = "/#{project.path_with_namespace}/blob/master/README.md"
expect(subject).
to redirect_to(redirect_url)
end
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,21 @@ 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 +56,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 +69,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 +82,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 +95,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,13 @@ 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,12 @@ 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
......
require 'spec_helper'
describe "Issues Feed", feature: true do
describe "GET /issues" do
describe 'Issues Feed', feature: true do
describe 'GET /issues' do
let!(:user) { create(:user) }
let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, project: project) }
before { project.team << [user, :developer] }
context "when authenticated" do
it "should render atom feed" do
context 'when authenticated' do
it 'should render atom feed' 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
context "when authenticated via private token" do
it "should render atom feed" do
visit project_issues_path(project, :atom, private_token: user.private_token)
context 'when authenticated via private token' 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
......
......@@ -4,17 +4,23 @@ describe "User Feed", feature: true do
describe "GET /" do
let!(:user) { create(:user) }
context "user atom feed via private token" 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
context 'feed content' do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project, author: user, description: '') }
let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) }
let(:issue) do
create(:issue, project: project,
author: user, description: '')
end
let(:note) do
create(:note, noteable: issue, author: user,
note: 'Bug confirmed', project: project)
end
before do
project.team << [user, :master]
......@@ -23,11 +29,11 @@ describe "User Feed", feature: true do
visit user_path(user, :atom, private_token: user.private_token)
end
it "should have issue opened event" do
it 'should have issue opened event' do
expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}")
end
it "should have issue comment event" do
it 'should have issue comment event' do
expect(body).
to have_content("#{safe_name} commented on issue ##{issue.iid}")
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
This diff is collapsed.
......@@ -3,10 +3,12 @@ require 'spec_helper'
describe 'Comments' do
include RepoHelpers
describe "On a merge request", js: true, feature: true do
describe 'On a merge request', js: true, feature: true do
let!(:merge_request) { create(:merge_request) }
let!(:project) { merge_request.source_project }
let!(:note) { create(:note_on_merge_request, :with_attachment, project: project) }
let!(:note) do
create(:note_on_merge_request, :with_attachment, project: project)
end
before do
login_as :admin
......@@ -15,19 +17,20 @@ describe 'Comments' do
subject { page }
describe "the note form" 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
end
describe "with text" do
describe 'with text' do
before do
within(".js-main-target-form") do
fill_in "note[note]", with: "This is awesome"
within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awesome'
end
end
......@@ -40,41 +43,45 @@ describe 'Comments' do
end
end
describe "when posting a note" do
describe 'when posting a note' do
before do
within(".js-main-target-form") do
fill_in "note[note]", with: "This is awsome!"
within('.js-main-target-form') do
fill_in 'note[note]', with: 'This is awsome!'
find('.js-md-preview-button').click
click_button "Add Comment"
click_button 'Add Comment'
end
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') do
is_expected.to have_css('.js-note-text', visible: true)
end
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) }
describe 'when editing a note', js: true do
it 'should contain the hidden edit form' do
within("#note_#{note.id}") do
is_expected.to have_css('.note-edit-form', visible: false)
end
end
describe "editing the note" do
describe 'editing the note' do
before do
find('.note').hover
find(".js-note-edit").click
end
it "should show the note edit form and hide the note body" 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
......@@ -87,41 +94,43 @@ describe 'Comments' do
#end
#end
it "appends the edited at time to the note" do
within(".current-note-edit-form") do
fill_in "note[note]", with: "Some new content"
find(".btn-save").click
it 'appends the edited at time to the note' do
within('.current-note-edit-form') do
fill_in 'note[note]', with: 'Some new content'
find('.btn-save').click
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
describe "deleting an attachment" do
describe 'deleting an attachment' do
before do
find('.note').hover
find(".js-note-edit").click
find('.js-note-edit').click
end
it "shows the delete link" do
within(".note-attachment") do
should have_css(".js-note-attachment-delete")
it 'shows the delete link' do
within('.note-attachment') do
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
it 'removes the attachment div and resets the edit form' do
find('.js-note-attachment-delete').click
is_expected.not_to have_css('.note-attachment')
expect(find('.current-note-edit-form', visible: false)).
not_to be_visible
end
end
end
end
describe "On a merge request diff", js: true, feature: true do
describe 'On a merge request diff', js: true, feature: true do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
......@@ -132,69 +141,75 @@ describe 'Comments' do
subject { page }
describe "when adding a note" do
describe 'when adding a note' do
before do
click_diff_line
end
describe "the notes holder" do
it { should have_css(".js-temp-notes-holder") }
describe 'the notes holder' do
it { is_expected.to have_css('.js-temp-notes-holder') }
it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
it 'has .new_note css class' do
within('.js-temp-notes-holder') do
expect(subject).to have_css('.new_note')
end
end
end
describe "the note form" do
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
it 'should be removed when canceled' do
within(".diff-file form[rel$='#{line_code}']") do
find(".js-close-discussion-note-form").trigger("click")
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
describe "with muliple note forms" do
describe 'with muliple note forms' do
before do
click_diff_line
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
describe 'previewing them separately' do
before do
# add two separate texts and trigger previews on both
within("tr[id='#{line_code}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "One comment on line 7"
fill_in 'note[note]', with: 'One comment on line 7'
find('.js-md-preview-button').click
end
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 10"
fill_in 'note[note]', with: 'Another comment on line 10'
find('.js-md-preview-button').click
end
end
end
describe "posting a note" do
describe 'posting a note' do
before do
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "Another comment on line 10"
click_button("Add Comment")
fill_in 'note[note]', with: 'Another comment on line 10'
click_button('Add Comment')
end
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
......
require 'spec_helper'
describe "Profile account page", feature: true do
describe 'Profile account page', feature: true do
let(:user) { create(:user) }
before do
login_as :user
end
describe "when signup is enabled" do
describe 'when signup is enabled' do
before do
ApplicationSetting.any_instance.stub(signup_enabled?: true)
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
it 'should delete the account' do
expect { click_link 'Delete account' }.to change { User.count }.by(-1)
expect(current_path).to eq(new_user_session_path)
end
end
describe "when signup is disabled" do
describe 'when signup is disabled' do
before do
ApplicationSetting.any_instance.stub(signup_enabled?: false)
visit profile_account_path
end
it "should not have option to remove account" do
page.should_not have_content("Remove account")
current_path.should == profile_account_path
it 'should not have option to remove account' do
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
......@@ -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,14 @@ 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 +64,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 +87,8 @@ 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 +98,14 @@ 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 +114,47 @@ 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')
url = 'http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118'
expect(gravatar_icon(user_email)).to match(url)
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}')
url = 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
expect(gravatar_icon(user_email, 20)).to eq(url)
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 +172,30 @@ 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'])
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 +203,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 +213,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 +224,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 +265,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,8 @@ 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,61 @@ 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(" &nbsp;")
expect(diff_line_content(nil)).to eq(' &nbsp;')
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
......
This diff is collapsed.
......@@ -5,25 +5,25 @@ describe IssuesHelper do
let(:issue) { create :issue, project: project }
let(:ext_project) { create :redmine_project }
describe :title_for_issue 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
describe :url_for_project_issues do
describe "url_for_project_issues" do
let(:project_url) { ext_project.external_issue_tracker.project_url }
let(:ext_expected) do
project_url.gsub(':project_id', ext_project.id.to_s)
......@@ -33,34 +33,34 @@ 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
describe :url_for_issue do
describe "url_for_issue" do
let(:issues_url) { ext_project.external_issue_tracker.issues_url}
let(:ext_expected) do
issues_url.gsub(':id', issue.iid.to_s)
......@@ -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
\ No newline at end of file
......@@ -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
......
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 &lt;&lt; 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 &lt;&lt; stderr.read') }
end
end
end
......
This diff is collapsed.
......@@ -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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment