Commit 0c4a70a3 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen

Updated rspec to rspec 3.x syntax

Signed-off-by: default avatarJeroen van Baarsen <jeroenvanbaarsen@gmail.com>
parent de1c450a
......@@ -4,4 +4,4 @@ begin
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec', 'rspec')
load Gem.bin_path('rspec-core', 'rspec')
......@@ -7,26 +7,26 @@ describe ApplicationController do
it 'should redirect if the user is over their password expiry' do
user.password_expires_at = Time.new(2002)
user.ldap_user?.should be_false
controller.stub(:current_user).and_return(user)
controller.should_receive(:redirect_to)
controller.should_receive(:new_profile_password_path)
expect(user.ldap_user?).to be_falsey
allow(controller).to receive(:current_user).and_return(user)
expect(controller).to receive(:redirect_to)
expect(controller).to receive(:new_profile_password_path)
controller.send(:check_password_expiration)
end
it 'should not redirect if the user is under their password expiry' do
user.password_expires_at = Time.now + 20010101
user.ldap_user?.should be_false
controller.stub(:current_user).and_return(user)
controller.should_not_receive(:redirect_to)
expect(user.ldap_user?).to be_falsey
allow(controller).to receive(:current_user).and_return(user)
expect(controller).not_to receive(:redirect_to)
controller.send(:check_password_expiration)
end
it 'should not redirect if the user is over their password expiry but they are an ldap user' do
user.password_expires_at = Time.new(2002)
user.stub(:ldap_user?).and_return(true)
controller.stub(:current_user).and_return(user)
controller.should_not_receive(:redirect_to)
allow(user).to receive(:ldap_user?).and_return(true)
allow(controller).to receive(:current_user).and_return(user)
expect(controller).not_to receive(:redirect_to)
controller.send(:check_password_expiration)
end
end
......
......@@ -9,8 +9,8 @@ describe Projects::BlobController do
project.team << [user, :master]
project.stub(:branches).and_return(['master', 'foo/bar/baz'])
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
controller.instance_variable_set(:@project, project)
end
......@@ -21,17 +21,17 @@ describe Projects::BlobController do
context "valid branch, valid file" do
let(:id) { 'master/README.md' }
it { should respond_with(:success) }
it { is_expected.to respond_with(:success) }
end
context "valid branch, invalid file" do
let(:id) { 'master/invalid-path.rb' }
it { should respond_with(:not_found) }
it { is_expected.to respond_with(:not_found) }
end
context "invalid branch, valid file" do
let(:id) { 'invalid-branch/README.md' }
it { should respond_with(:not_found) }
it { is_expected.to respond_with(:not_found) }
end
end
......@@ -45,7 +45,7 @@ describe Projects::BlobController do
context 'redirect to tree' do
let(:id) { 'markdown/doc' }
it { should redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") }
it { is_expected.to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") }
end
end
end
......@@ -9,8 +9,8 @@ describe Projects::BranchesController do
project.team << [user, :master]
project.stub(:branches).and_return(['master', 'foo/bar/baz'])
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
controller.instance_variable_set(:@project, project)
end
......@@ -27,25 +27,25 @@ describe Projects::BranchesController do
context "valid branch name, valid source" do
let(:branch) { "merge_branch" }
let(:ref) { "master" }
it { should redirect_to("/#{project.path_with_namespace}/tree/merge_branch") }
it { is_expected.to redirect_to("/#{project.path_with_namespace}/tree/merge_branch") }
end
context "invalid branch name, valid ref" do
let(:branch) { "<script>alert('merge');</script>" }
let(:ref) { "master" }
it { should redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") }
it { is_expected.to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") }
end
context "valid branch name, invalid ref" do
let(:branch) { "merge_branch" }
let(:ref) { "<script>alert('ref');</script>" }
it { should render_template("new") }
it { is_expected.to render_template("new") }
end
context "invalid branch name, invalid ref" do
let(:branch) { "<script>alert('merge');</script>" }
let(:ref) { "<script>alert('ref');</script>" }
it { should render_template("new") }
it { is_expected.to render_template("new") }
end
end
end
......@@ -19,7 +19,7 @@ describe Projects::CommitController do
end
it "should generate it" do
Commit.any_instance.should_receive(:"to_#{format}")
expect_any_instance_of(Commit).to receive(:"to_#{format}")
get :show, project_id: project.to_param, id: commit.id, format: format
end
......@@ -31,7 +31,7 @@ describe Projects::CommitController do
end
it "should not escape Html" do
Commit.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
allow_any_instance_of(Commit).to receive(:"to_#{format}").and_return('HTML entities &<>" ')
get :show, project_id: project.to_param, id: commit.id, format: format
......
......@@ -13,8 +13,8 @@ describe Projects::CommitsController do
context "as atom feed" do
it "should render as atom" do
get :show, project_id: project.to_param, id: "master", format: "atom"
response.should be_success
response.content_type.should == 'application/atom+xml'
expect(response).to be_success
expect(response.content_type).to eq('application/atom+xml')
end
end
end
......
......@@ -10,13 +10,13 @@ describe Import::GithubController do
describe "GET callback" do
it "updates access token" do
token = "asdasd12345"
Gitlab::GithubImport::Client.any_instance.stub(:get_token).and_return(token)
allow_any_instance_of(Gitlab::GithubImport::Client).to receive(:get_token).and_return(token)
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123", app_secret: "asd123", name: "github")
get :callback
user.reload.github_access_token.should == token
controller.should redirect_to(status_import_github_url)
expect(user.reload.github_access_token).to eq(token)
expect(controller).to redirect_to(status_import_github_url)
end
end
......@@ -55,7 +55,7 @@ describe Import::GithubController do
it "takes already existing namespace" do
namespace = create(:namespace, name: "john", owner: user)
Gitlab::GithubImport::ProjectCreator.should_receive(:new).with(@repo, namespace, user).
expect(Gitlab::GithubImport::ProjectCreator).to receive(:new).with(@repo, namespace, user).
and_return(double(execute: true))
controller.stub_chain(:client, :repo).and_return(@repo)
......
......@@ -15,8 +15,8 @@ describe Import::GitlabController do
get :callback
user.reload.gitlab_access_token.should == token
controller.should redirect_to(status_import_gitlab_url)
expect(user.reload.gitlab_access_token).to eq(token)
expect(controller).to redirect_to(status_import_gitlab_url)
end
end
......@@ -58,7 +58,7 @@ describe Import::GitlabController do
it "takes already existing namespace" do
namespace = create(:namespace, name: "john", owner: user)
Gitlab::GitlabImport::ProjectCreator.should_receive(:new).with(@repo, namespace, user).
expect(Gitlab::GitlabImport::ProjectCreator).to receive(:new).with(@repo, namespace, user).
and_return(double(execute: true))
controller.stub_chain(:client, :project).and_return(@repo)
......
......@@ -19,7 +19,7 @@ describe Projects::MergeRequestsController do
end
it "should generate it" do
MergeRequest.any_instance.should_receive(:"to_#{format}")
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
get :show, project_id: project.to_param, id: merge_request.iid, format: format
end
......@@ -31,7 +31,7 @@ describe Projects::MergeRequestsController do
end
it "should not escape Html" do
MergeRequest.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").and_return('HTML entities &<>" ')
get :show, project_id: project.to_param, id: merge_request.iid, format: format
......
......@@ -45,18 +45,18 @@ describe ProjectsController do
describe "POST #toggle_star" do
it "toggles star if user is signed in" do
sign_in(user)
expect(user.starred?(public_project)).to be_false
expect(user.starred?(public_project)).to be_falsey
post :toggle_star, id: public_project.to_param
expect(user.starred?(public_project)).to be_true
expect(user.starred?(public_project)).to be_truthy
post :toggle_star, id: public_project.to_param
expect(user.starred?(public_project)).to be_false
expect(user.starred?(public_project)).to be_falsey
end
it "does nothing if user is not signed in" do
post :toggle_star, id: public_project.to_param
expect(user.starred?(public_project)).to be_false
expect(user.starred?(public_project)).to be_falsey
post :toggle_star, id: public_project.to_param
expect(user.starred?(public_project)).to be_false
expect(user.starred?(public_project)).to be_falsey
end
end
end
......@@ -9,8 +9,8 @@ describe Projects::TreeController do
project.team << [user, :master]
project.stub(:branches).and_return(['master', 'foo/bar/baz'])
project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
controller.instance_variable_set(:@project, project)
end
......@@ -22,22 +22,22 @@ describe Projects::TreeController do
context "valid branch, no path" do
let(:id) { 'master' }
it { should respond_with(:success) }
it { is_expected.to respond_with(:success) }
end
context "valid branch, valid path" do
let(:id) { 'master/encoding/' }
it { should respond_with(:success) }
it { is_expected.to respond_with(:success) }
end
context "valid branch, invalid path" do
let(:id) { 'master/invalid-path/' }
it { should respond_with(:not_found) }
it { is_expected.to respond_with(:not_found) }
end
context "invalid branch, valid path" do
let(:id) { 'invalid-branch/encoding/' }
it { should respond_with(:not_found) }
it { is_expected.to respond_with(:not_found) }
end
end
......@@ -50,7 +50,7 @@ describe Projects::TreeController do
context 'redirect to blob' do
let(:id) { 'master/README.md' }
it { should redirect_to("/#{project.path_with_namespace}/blob/master/README.md") }
it { is_expected.to redirect_to("/#{project.path_with_namespace}/blob/master/README.md") }
end
end
end
......@@ -9,7 +9,7 @@ FactoryGirl.factories.map(&:name).each do |factory_name|
next if INVALID_FACTORIES.include?(factory_name)
describe "#{factory_name} factory" do
it 'should be valid' do
build(factory_name).should be_valid
expect(build(factory_name)).to be_valid
end
end
end
......@@ -15,12 +15,12 @@ describe "Admin::Hooks", feature: true do
within ".sidebar-wrapper" do
click_on "Hooks"
end
current_path.should == admin_hooks_path
expect(current_path).to eq(admin_hooks_path)
end
it "should have hooks list" do
visit admin_hooks_path
page.should have_content(@system_hook.url)
expect(page).to have_content(@system_hook.url)
end
end
......@@ -33,8 +33,8 @@ describe "Admin::Hooks", feature: true do
end
it "should open new hook popup" do
current_path.should == admin_hooks_path
page.should have_content(@url)
expect(current_path).to eq(admin_hooks_path)
expect(page).to have_content(@url)
end
end
......@@ -45,7 +45,7 @@ describe "Admin::Hooks", feature: true do
click_link "Test Hook"
end
it { current_path.should == admin_hooks_path }
it { expect(current_path).to eq(admin_hooks_path) }
end
end
......@@ -12,11 +12,11 @@ describe "Admin::Projects", feature: true do
end
it "should be ok" do
current_path.should == admin_projects_path
expect(current_path).to eq(admin_projects_path)
end
it "should have projects list" do
page.should have_content(@project.name)
expect(page).to have_content(@project.name)
end
end
......@@ -27,8 +27,8 @@ describe "Admin::Projects", feature: true do
end
it "should have project info" do
page.should have_content(@project.path)
page.should have_content(@project.name)
expect(page).to have_content(@project.path)
expect(page).to have_content(@project.name)
end
end
end
......@@ -9,12 +9,12 @@ describe "Admin::Users", feature: true do
end
it "should be ok" do
current_path.should == admin_users_path
expect(current_path).to eq(admin_users_path)
end
it "should have users list" do
page.should have_content(@user.email)
page.should have_content(@user.name)
expect(page).to have_content(@user.email)
expect(page).to have_content(@user.name)
end
end
......@@ -33,19 +33,19 @@ describe "Admin::Users", feature: true do
it "should apply defaults to user" do
click_button "Create user"
user = User.find_by(username: 'bang')
user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
expect(user.projects_limit).to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group)
end
it "should create user with valid data" do
click_button "Create user"
user = User.find_by(username: 'bang')
user.name.should == "Big Bang"
user.email.should == "bigbang@mail.com"
expect(user.name).to eq("Big Bang")
expect(user.email).to eq("bigbang@mail.com")
end
it "should call send mail" do
Notify.should_receive(:new_user_email)
expect(Notify).to receive(:new_user_email)
click_button "Create user"
end
......@@ -54,9 +54,9 @@ describe "Admin::Users", feature: true do
click_button "Create user"
user = User.find_by(username: 'bang')
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
email.text_part.body.should have_content(user.email)
email.text_part.body.should have_content('password')
expect(email.subject).to have_content("Account was created")
expect(email.text_part.body).to have_content(user.email)
expect(email.text_part.body).to have_content('password')
end
end
......@@ -67,8 +67,8 @@ describe "Admin::Users", feature: true do
end
it "should have user info" do
page.should have_content(@user.email)
page.should have_content(@user.name)
expect(page).to have_content(@user.email)
expect(page).to have_content(@user.name)
end
end
......@@ -80,8 +80,8 @@ describe "Admin::Users", feature: true do
end
it "should have user edit page" do
page.should have_content("Name")
page.should have_content("Password")
expect(page).to have_content("Name")
expect(page).to have_content("Password")
end
describe "Update user" do
......@@ -93,14 +93,14 @@ describe "Admin::Users", feature: true do
end
it "should show page with new data" do
page.should have_content("bigbang@mail.com")
page.should have_content("Big Bang")
expect(page).to have_content("bigbang@mail.com")
expect(page).to have_content("Big Bang")
end
it "should change user entry" do
@simple_user.reload
@simple_user.name.should == "Big Bang"
@simple_user.is_admin?.should be_true
expect(@simple_user.name).to eq("Big Bang")
expect(@simple_user.is_admin?).to be_truthy
end
end
end
......
......@@ -4,24 +4,24 @@ describe "Admin::Projects", feature: true do
describe "GET /admin/projects" do
subject { admin_projects_path }
it { should be_allowed_for :admin }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /admin/users" do
subject { admin_users_path }
it { should be_allowed_for :admin }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /admin/hooks" do
subject { admin_hooks_path }
it { should be_allowed_for :admin }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
end
......@@ -17,12 +17,12 @@ describe "Dashboard Issues Feed", feature: true do
it "should render atom feed via private token" do
visit issues_dashboard_path(:atom, private_token: user.private_token)
response_headers['Content-Type'].should have_content("application/atom+xml")
body.should have_selector("title", text: "#{user.name} issues")
body.should have_selector("author email", text: issue1.author_email)
body.should have_selector("entry summary", text: issue1.title)
body.should have_selector("author email", text: issue2.author_email)
body.should have_selector("entry summary", text: issue2.title)
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{user.name} issues")
expect(body).to have_selector("author email", text: issue1.author_email)
expect(body).to have_selector("entry summary", text: issue1.title)
expect(body).to have_selector("author email", text: issue2.author_email)
expect(body).to have_selector("entry summary", text: issue2.title)
end
end
end
......
......@@ -7,7 +7,7 @@ describe "Dashboard Feed", feature: true do
context "projects atom feed via private token" do
it "should render projects atom feed" do
visit dashboard_path(:atom, private_token: user.private_token)
body.should have_selector("feed title")
expect(body).to have_selector("feed title")
end
end
......@@ -24,11 +24,11 @@ describe "Dashboard Feed", feature: true do
end
it "should have issue opened event" do
body.should have_content("#{user.name} opened issue ##{issue.iid}")
expect(body).to have_content("#{user.name} opened issue ##{issue.iid}")
end
it "should have issue comment event" do
body.should have_content("#{user.name} commented on issue ##{issue.iid}")
expect(body).to have_content("#{user.name} commented on issue ##{issue.iid}")
end
end
end
......
......@@ -13,10 +13,10 @@ describe "Issues Feed", feature: true do
login_with user
visit project_issues_path(project, :atom)
response_headers['Content-Type'].should have_content("application/atom+xml")
body.should have_selector("title", text: "#{project.name} issues")
body.should have_selector("author email", text: issue.author_email)
body.should have_selector("entry summary", text: issue.title)
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{project.name} issues")
expect(body).to have_selector("author email", text: issue.author_email)
expect(body).to have_selector("entry summary", text: issue.title)
end
end
......@@ -24,10 +24,10 @@ describe "Issues Feed", feature: true do
it "should render atom feed" do
visit project_issues_path(project, :atom, private_token: user.private_token)
response_headers['Content-Type'].should have_content("application/atom+xml")
body.should have_selector("title", text: "#{project.name} issues")
body.should have_selector("author email", text: issue.author_email)
body.should have_selector("entry summary", text: issue.title)
expect(response_headers['Content-Type']).to have_content("application/atom+xml")
expect(body).to have_selector("title", text: "#{project.name} issues")
expect(body).to have_selector("author email", text: issue.author_email)
expect(body).to have_selector("entry summary", text: issue.title)
end
end
end
......
......@@ -7,7 +7,7 @@ describe "User Feed", feature: true do
context "user atom feed via private token" do
it "should render user atom feed" do
visit user_path(user, :atom, private_token: user.private_token)
body.should have_selector("feed title")
expect(body).to have_selector("feed title")
end
end
......
......@@ -25,25 +25,25 @@ describe "GitLab Flavored Markdown", feature: true do
it "should render title in commits#index" do
visit project_commits_path(project, 'master', limit: 1)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
it "should render title in commits#show" do
visit project_commit_path(project, commit)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
it "should render description in commits#show" do
visit project_commit_path(project, commit)
page.should have_link("@#{fred.username}")
expect(page).to have_link("@#{fred.username}")
end
it "should render title in repositories#branches" do
visit project_branches_path(project)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
end
......@@ -64,19 +64,19 @@ describe "GitLab Flavored Markdown", feature: true do
it "should render subject in issues#index" do
visit project_issues_path(project)
page.should have_link("##{@other_issue.iid}")
expect(page).to have_link("##{@other_issue.iid}")
end
it "should render subject in issues#show" do
visit project_issue_path(project, @issue)
page.should have_link("##{@other_issue.iid}")
expect(page).to have_link("##{@other_issue.iid}")
end
it "should render details in issues#show" do
visit project_issue_path(project, @issue)
page.should have_link("@#{fred.username}")
expect(page).to have_link("@#{fred.username}")
end
end
......@@ -89,13 +89,13 @@ describe "GitLab Flavored Markdown", feature: true do
it "should render title in merge_requests#index" do
visit project_merge_requests_path(project)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
it "should render title in merge_requests#show" do
visit project_merge_request_path(project, @merge_request)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
end
......@@ -111,19 +111,19 @@ describe "GitLab Flavored Markdown", feature: true do
it "should render title in milestones#index" do
visit project_milestones_path(project)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
it "should render title in milestones#show" do
visit project_milestone_path(project, @milestone)
page.should have_link("##{issue.iid}")
expect(page).to have_link("##{issue.iid}")
end
it "should render description in milestones#show" do
visit project_milestone_path(project, @milestone)
page.should have_link("@#{fred.username}")
expect(page).to have_link("@#{fred.username}")
end
end
end
......@@ -7,7 +7,7 @@ describe 'Help Pages', feature: true do
end
it 'replace the variable $your_email with the email of the user' do
visit help_page_path(category: 'ssh', file: 'README.md')
page.should have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
expect(page).to have_content("ssh-keygen -t rsa -C \"#{@user.email}\"")
end
end
end
......@@ -26,7 +26,7 @@ describe "Issues", feature: true do
end
it "should open new issue popup" do
page.should have_content("Issue ##{issue.iid}")
expect(page).to have_content("Issue ##{issue.iid}")
end
describe "fill in" do
......@@ -40,9 +40,9 @@ describe "Issues", feature: true do
it "should update issue fields" do
click_button "Save changes"
page.should have_content @user.name
page.should have_content "bug 345"
page.should have_content project.name
expect(page).to have_content @user.name
expect(page).to have_content "bug 345"
expect(page).to have_content project.name
end
end
......@@ -59,7 +59,7 @@ describe "Issues", feature: true do
it 'allows user to select unasigned', :js => true do
visit edit_project_issue_path(project, issue)
page.should have_content "Assign to #{@user.name}"
expect(page).to have_content "Assign to #{@user.name}"
first('#s2id_issue_assignee_id').click
sleep 2 # wait for ajax stuff to complete
......@@ -67,8 +67,8 @@ describe "Issues", feature: true do
click_button "Save changes"
page.should have_content 'Assignee: none'
issue.reload.assignee.should be_nil
expect(page).to have_content 'Assignee: none'
expect(issue.reload.assignee).to be_nil
end
end
......@@ -93,33 +93,33 @@ describe "Issues", feature: true do
it "should allow filtering by issues with no specified milestone" do
visit project_issues_path(project, milestone_id: '0')
page.should_not have_content 'foobar'
page.should have_content 'barbaz'
page.should have_content 'gitlab'
expect(page).not_to have_content 'foobar'
expect(page).to have_content 'barbaz'
expect(page).to have_content 'gitlab'
end
it "should allow filtering by a specified milestone" do
visit project_issues_path(project, milestone_id: issue.milestone.id)
page.should have_content 'foobar'
page.should_not have_content 'barbaz'
page.should_not have_content 'gitlab'
expect(page).to have_content 'foobar'
expect(page).not_to have_content 'barbaz'
expect(page).not_to have_content 'gitlab'
end
it "should allow filtering by issues with no specified assignee" do
visit project_issues_path(project, assignee_id: '0')
page.should have_content 'foobar'
page.should_not have_content 'barbaz'
page.should_not have_content 'gitlab'
expect(page).to have_content 'foobar'
expect(page).not_to have_content 'barbaz'
expect(page).not_to have_content 'gitlab'
end
it "should allow filtering by a specified assignee" do
visit project_issues_path(project, assignee_id: @user.id)
page.should_not have_content 'foobar'
page.should have_content 'barbaz'
page.should have_content 'gitlab'
expect(page).not_to have_content 'foobar'
expect(page).to have_content 'barbaz'
expect(page).to have_content 'gitlab'
end
end
......@@ -134,15 +134,15 @@ describe "Issues", feature: true do
it 'sorts by newest' do
visit project_issues_path(project, sort: sort_value_recently_created)
first_issue.should include("foo")
last_issue.should include("baz")
expect(first_issue).to include("foo")
expect(last_issue).to include("baz")
end
it 'sorts by oldest' do
visit project_issues_path(project, sort: sort_value_oldest_created)
first_issue.should include("baz")
last_issue.should include("foo")
expect(first_issue).to include("baz")
expect(last_issue).to include("foo")
end
it 'sorts by most recently updated' do
......@@ -150,7 +150,7 @@ describe "Issues", feature: true do
baz.save
visit project_issues_path(project, sort: sort_value_recently_updated)
first_issue.should include("baz")
expect(first_issue).to include("baz")
end
it 'sorts by least recently updated' do
......@@ -158,7 +158,7 @@ describe "Issues", feature: true do
baz.save
visit project_issues_path(project, sort: sort_value_oldest_updated)
first_issue.should include("baz")
expect(first_issue).to include("baz")
end
describe 'sorting by milestone' do
......@@ -172,13 +172,13 @@ describe "Issues", feature: true do
it 'sorts by recently due milestone' do
visit project_issues_path(project, sort: sort_value_milestone_soon)
first_issue.should include("foo")
expect(first_issue).to include("foo")
end
it 'sorts by least recently due milestone' do
visit project_issues_path(project, sort: sort_value_milestone_later)
first_issue.should include("bar")
expect(first_issue).to include("bar")
end
end
......@@ -195,9 +195,9 @@ describe "Issues", feature: true do
it 'sorts with a filter applied' do
visit project_issues_path(project, sort: sort_value_oldest_created, assignee_id: user2.id)
first_issue.should include("bar")
last_issue.should include("foo")
page.should_not have_content 'baz'
expect(first_issue).to include("bar")
expect(last_issue).to include("foo")
expect(page).not_to have_content 'baz'
end
end
end
......@@ -213,7 +213,7 @@ describe "Issues", feature: true do
find('.edit-issue.inline-update #issue_assignee_id').set project.team.members.first.id
click_button 'Update Issue'
page.should have_content "Assignee:"
expect(page).to have_content "Assignee:"
has_select?('issue_assignee_id', :selected => project.team.members.first.name)
end
end
......@@ -233,7 +233,7 @@ describe "Issues", feature: true do
login_with guest
visit project_issue_path(project, issue)
page.should have_content issue.assignee.name
expect(page).to have_content issue.assignee.name
end
end
end
......@@ -250,8 +250,8 @@ describe "Issues", feature: true do
find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id')
click_button 'Update Issue'
page.should have_content "Milestone changed to #{milestone.title}"
page.should have_content "Milestone: #{milestone.title}"
expect(page).to have_content "Milestone changed to #{milestone.title}"
expect(page).to have_content "Milestone: #{milestone.title}"
has_select?('issue_assignee_id', :selected => milestone.title)
end
end
......@@ -270,7 +270,7 @@ describe "Issues", feature: true do
login_with guest
visit project_issue_path(project, issue)
page.should have_content milestone.title
expect(page).to have_content milestone.title
end
end
......@@ -284,15 +284,15 @@ describe "Issues", feature: true do
it 'allows user to remove assignee', :js => true do
visit project_issue_path(project, issue)
page.should have_content "Assignee: #{user2.name}"
expect(page).to have_content "Assignee: #{user2.name}"
first('#s2id_issue_assignee_id').click
sleep 2 # wait for ajax stuff to complete
first('.user-result').click
page.should have_content 'Assignee: none'
expect(page).to have_content 'Assignee: none'
sleep 2 # wait for ajax stuff to complete
issue.reload.assignee.should be_nil
expect(issue.reload.assignee).to be_nil
end
end
end
......
......@@ -17,8 +17,8 @@ describe 'Comments' do
describe "the note form" do
it 'should be valid' do
should have_css(".js-main-target-form", visible: true, count: 1)
find(".js-main-target-form input[type=submit]").value.should == "Add Comment"
is_expected.to have_css(".js-main-target-form", visible: true, count: 1)
expect(find(".js-main-target-form input[type=submit]").value).to eq("Add Comment")
within('.js-main-target-form') do
expect(page).not_to have_link('Cancel')
end
......@@ -50,18 +50,18 @@ describe 'Comments' do
end
it 'should be added and form reset' do
should have_content("This is awsome!")
is_expected.to have_content("This is awsome!")
within('.js-main-target-form') do
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
expect(page).to have_css('.js-md-preview', visible: :hidden)
end
within(".js-main-target-form") { should have_css(".js-note-text", visible: true) }
within(".js-main-target-form") { is_expected.to have_css(".js-note-text", visible: true) }
end
end
describe "when editing a note", js: true do
it "should contain the hidden edit form" do
within("#note_#{note.id}") { should have_css(".note-edit-form", visible: false) }
within("#note_#{note.id}") { is_expected.to have_css(".note-edit-form", visible: false) }
end
describe "editing the note" do
......@@ -72,9 +72,9 @@ describe 'Comments' do
it "should show the note edit form and hide the note body" do
within("#note_#{note.id}") do
find(".current-note-edit-form", visible: true).should be_visible
find(".note-edit-form", visible: true).should be_visible
find(:css, ".note-text", visible: false).should_not be_visible
expect(find(".current-note-edit-form", visible: true)).to be_visible
expect(find(".note-edit-form", visible: true)).to be_visible
expect(find(:css, ".note-text", visible: false)).not_to be_visible
end
end
......@@ -94,8 +94,8 @@ describe 'Comments' do
end
within("#note_#{note.id}") do
should have_css(".note_edited_ago")
find(".note_edited_ago").text.should match(/less than a minute ago/)
is_expected.to have_css(".note_edited_ago")
expect(find(".note_edited_ago").text).to match(/less than a minute ago/)
end
end
end
......@@ -108,14 +108,14 @@ describe 'Comments' do
it "shows the delete link" do
within(".note-attachment") do
should have_css(".js-note-attachment-delete")
is_expected.to have_css(".js-note-attachment-delete")
end
end
it "removes the attachment div and resets the edit form" do
find(".js-note-attachment-delete").click
should_not have_css(".note-attachment")
find(".current-note-edit-form", visible: false).should_not be_visible
is_expected.not_to have_css(".note-attachment")
expect(find(".current-note-edit-form", visible: false)).not_to be_visible
end
end
end
......@@ -138,16 +138,16 @@ describe 'Comments' do
end
describe "the notes holder" do
it { should have_css(".js-temp-notes-holder") }
it { is_expected.to have_css(".js-temp-notes-holder") }
it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
it { within(".js-temp-notes-holder") { is_expected.to have_css(".new_note") } }
end
describe "the note form" do
it "shouldn't add a second form for same row" do
click_diff_line
should have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form", count: 1)
is_expected.to have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form", count: 1)
end
it "should be removed when canceled" do
......@@ -155,7 +155,7 @@ describe 'Comments' do
find(".js-close-discussion-note-form").trigger("click")
end
should have_no_css(".js-temp-notes-holder")
is_expected.to have_no_css(".js-temp-notes-holder")
end
end
end
......@@ -166,7 +166,7 @@ describe 'Comments' do
click_diff_line(line_code_2)
end
it { should have_css(".js-temp-notes-holder", count: 2) }
it { is_expected.to have_css(".js-temp-notes-holder", count: 2) }
describe "previewing them separately" do
before do
......@@ -191,10 +191,10 @@ describe 'Comments' do
end
it 'should be added as discussion' do
should have_content("Another comment on line 10")
should have_css(".notes_holder")
should have_css(".notes_holder .note", count: 1)
should have_button('Reply')
is_expected.to have_content("Another comment on line 10")
is_expected.to have_css(".notes_holder")
is_expected.to have_css(".notes_holder .note", count: 1)
is_expected.to have_button('Reply')
end
end
end
......
......@@ -13,11 +13,11 @@ describe "Profile account page", feature: true do
visit profile_account_path
end
it { page.should have_content("Remove account") }
it { expect(page).to have_content("Remove account") }
it "should delete the account" do
expect { click_link "Delete account" }.to change {User.count}.by(-1)
current_path.should == new_user_session_path
expect(current_path).to eq(new_user_session_path)
end
end
......@@ -28,8 +28,8 @@ describe "Profile account page", feature: true do
end
it "should not have option to remove account" do
page.should_not have_content("Remove account")
current_path.should == profile_account_path
expect(page).not_to have_content("Remove account")
expect(current_path).to eq(profile_account_path)
end
end
end
......@@ -14,7 +14,7 @@ describe "Search", feature: true do
end
it "should show project in search results" do
page.should have_content @project.name
expect(page).to have_content @project.name
end
end
......@@ -4,52 +4,52 @@ describe "Dashboard access", feature: true do
describe "GET /dashboard" do
subject { dashboard_path }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /dashboard/issues" do
subject { issues_dashboard_path }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /dashboard/merge_requests" do
subject { merge_requests_dashboard_path }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /dashboard/projects" do
subject { projects_dashboard_path }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /help" do
subject { help_path }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /projects/new" do
it { new_project_path.should be_allowed_for :admin }
it { new_project_path.should be_allowed_for :user }
it { new_project_path.should be_denied_for :visitor }
it { expect(new_project_path).to be_allowed_for :admin }
it { expect(new_project_path).to be_allowed_for :user }
it { expect(new_project_path).to be_denied_for :visitor }
end
describe "GET /groups/new" do
it { new_group_path.should be_allowed_for :admin }
it { new_group_path.should be_allowed_for :user }
it { new_group_path.should be_denied_for :visitor }
it { expect(new_group_path).to be_allowed_for :admin }
it { expect(new_group_path).to be_allowed_for :user }
it { expect(new_group_path).to be_denied_for :visitor }
end
end
......@@ -2,9 +2,9 @@ require 'spec_helper'
describe "Group access", feature: true do
describe "GET /projects/new" do
it { new_group_path.should be_allowed_for :admin }
it { new_group_path.should be_allowed_for :user }
it { new_group_path.should be_denied_for :visitor }
it { expect(new_group_path).to be_allowed_for :admin }
it { expect(new_group_path).to be_allowed_for :user }
it { expect(new_group_path).to be_denied_for :visitor }
end
describe "Group" do
......@@ -26,73 +26,73 @@ describe "Group access", feature: true do
describe "GET /groups/:path" do
subject { group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/merge_requests" do
subject { merge_requests_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/members" do
subject { members_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { should be_allowed_for owner }
it { should be_denied_for master }
it { should be_denied_for reporter }
it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_denied_for master }
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/projects" do
subject { projects_group_path(group) }
it { should be_allowed_for owner }
it { should be_denied_for master }
it { should be_denied_for reporter }
it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_denied_for master }
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
end
end
......@@ -22,61 +22,61 @@ describe "Group with internal project access", feature: true do
describe "GET /groups/:path" do
subject { group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/merge_requests" do
subject { merge_requests_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/members" do
subject { members_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { should be_allowed_for owner }
it { should be_denied_for master }
it { should be_denied_for reporter }
it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_denied_for master }
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
end
end
......@@ -23,61 +23,61 @@ describe "Group access", feature: true do
describe "GET /groups/:path" do
subject { group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/merge_requests" do
subject { merge_requests_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/members" do
subject { members_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { should be_allowed_for owner }
it { should be_denied_for master }
it { should be_denied_for reporter }
it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_denied_for master }
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
end
end
......@@ -22,61 +22,61 @@ describe "Group with public project access", feature: true do
describe "GET /groups/:path" do
subject { group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/merge_requests" do
subject { merge_requests_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/members" do
subject { members_group_path(group) }
it { should be_allowed_for owner }
it { should be_allowed_for master }
it { should be_allowed_for reporter }
it { should be_allowed_for :admin }
it { should be_allowed_for guest }
it { should be_allowed_for :user }
it { should be_allowed_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_allowed_for master }
it { is_expected.to be_allowed_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for guest }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_allowed_for :visitor }
end
describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { should be_allowed_for owner }
it { should be_denied_for master }
it { should be_denied_for reporter }
it { should be_allowed_for :admin }
it { should be_denied_for guest }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for owner }
it { is_expected.to be_denied_for master }
it { is_expected.to be_denied_for reporter }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_denied_for guest }
it { is_expected.to be_denied_for :user }
it { is_expected.to be_denied_for :visitor }
end
end
end
......@@ -7,70 +7,70 @@ describe "Users Security", feature: true do
end
describe "GET /login" do
it { new_user_session_path.should_not be_404_for :visitor }
it { expect(new_user_session_path).not_to be_404_for :visitor }
end
describe "GET /profile/keys" do
subject { profile_keys_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile" do
subject { profile_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/account" do
subject { profile_account_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/design" do
subject { design_profile_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/history" do
subject { history_profile_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/notifications" do
subject { profile_notifications_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
describe "GET /profile/groups" do
subject { profile_groups_path }
it { should be_allowed_for @u1 }
it { should be_allowed_for :admin }
it { should be_allowed_for :user }
it { should be_denied_for :visitor }
it { is_expected.to be_allowed_for @u1 }
it { is_expected.to be_allowed_for :admin }
it { is_expected.to be_allowed_for :user }
it { is_expected.to be_denied_for :visitor }
end
end
end
......@@ -27,40 +27,40 @@ describe IssuesFinder do
it 'should filter by all' do
params = { scope: "all", state: 'opened' }
issues = IssuesFinder.new.execute(user, params)
issues.size.should == 3
expect(issues.size).to eq(3)
end
it 'should filter by assignee id' do
params = { scope: "all", assignee_id: user.id, state: 'opened' }
issues = IssuesFinder.new.execute(user, params)
issues.size.should == 2
expect(issues.size).to eq(2)
end
it 'should filter by author id' do
params = { scope: "all", author_id: user2.id, state: 'opened' }
issues = IssuesFinder.new.execute(user, params)
issues.should == [issue3]
expect(issues).to eq([issue3])
end
it 'should filter by milestone id' do
params = { scope: "all", milestone_id: milestone.id, state: 'opened' }
issues = IssuesFinder.new.execute(user, params)
issues.should == [issue1]
expect(issues).to eq([issue1])
end
it 'should be empty for unauthorized user' do
params = { scope: "all", state: 'opened' }
issues = IssuesFinder.new.execute(nil, params)
issues.size.should be_zero
expect(issues.size).to be_zero
end
it 'should not include unauthorized issues' do
params = { scope: "all", state: 'opened' }
issues = IssuesFinder.new.execute(user2, params)
issues.size.should == 2
issues.should_not include(issue1)
issues.should include(issue2)
issues.should include(issue3)
expect(issues.size).to eq(2)
expect(issues).not_to include(issue1)
expect(issues).to include(issue2)
expect(issues).to include(issue3)
end
end
......@@ -68,13 +68,13 @@ describe IssuesFinder do
it 'should filter by assignee' do
params = { scope: "assigned-to-me", state: 'opened' }
issues = IssuesFinder.new.execute(user, params)
issues.size.should == 2
expect(issues.size).to eq(2)
end
it 'should filter by project' do
params = { scope: "assigned-to-me", state: 'opened', project_id: project1.id }
issues = IssuesFinder.new.execute(user, params)
issues.size.should == 1
expect(issues.size).to eq(1)
end
end
end
......
......@@ -21,13 +21,13 @@ describe MergeRequestsFinder do
it 'should filter by scope' do
params = { scope: 'authored', state: 'opened' }
merge_requests = MergeRequestsFinder.new.execute(user, params)
merge_requests.size.should == 2
expect(merge_requests.size).to eq(2)
end
it 'should filter by project' do
params = { project_id: project1.id, scope: 'authored', state: 'opened' }
merge_requests = MergeRequestsFinder.new.execute(user, params)
merge_requests.size.should == 1
expect(merge_requests.size).to eq(1)
end
end
end
......@@ -21,7 +21,7 @@ describe NotesFinder do
it 'should find all notes' do
notes = NotesFinder.new.execute(project, user, params)
notes.size.should eq(2)
expect(notes.size).to eq(2)
end
it 'should raise an exception for an invalid target_type' do
......@@ -32,7 +32,7 @@ describe NotesFinder do
it 'filters out old notes' do
note2.update_attribute(:updated_at, 2.hours.ago)
notes = NotesFinder.new.execute(project, user, params)
notes.should eq([note1])
expect(notes).to eq([note1])
end
end
end
......@@ -12,19 +12,19 @@ describe ProjectsFinder do
context 'non authenticated' do
subject { ProjectsFinder.new.execute(nil, group: group) }
it { should include(project1) }
it { should_not include(project2) }
it { should_not include(project3) }
it { should_not include(project4) }
it { is_expected.to include(project1) }
it { is_expected.not_to include(project2) }
it { is_expected.not_to include(project3) }
it { is_expected.not_to include(project4) }
end
context 'authenticated' do
subject { ProjectsFinder.new.execute(user, group: group) }
it { should include(project1) }
it { should include(project2) }
it { should_not include(project3) }
it { should_not include(project4) }
it { is_expected.to include(project1) }
it { is_expected.to include(project2) }
it { is_expected.not_to include(project3) }
it { is_expected.not_to include(project4) }
end
context 'authenticated, project member' do
......@@ -32,10 +32,10 @@ describe ProjectsFinder do
subject { ProjectsFinder.new.execute(user, group: group) }
it { should include(project1) }
it { should include(project2) }
it { should include(project3) }
it { should_not include(project4) }
it { is_expected.to include(project1) }
it { is_expected.to include(project2) }
it { is_expected.to include(project3) }
it { is_expected.not_to include(project4) }
end
context 'authenticated, group member' do
......@@ -43,9 +43,9 @@ describe ProjectsFinder do
subject { ProjectsFinder.new.execute(user, group: group) }
it { should include(project1) }
it { should include(project2) }
it { should include(project3) }
it { should include(project4) }
it { is_expected.to include(project1) }
it { is_expected.to include(project2) }
it { is_expected.to include(project3) }
it { is_expected.to include(project4) }
end
end
......@@ -18,14 +18,14 @@ describe SnippetsFinder do
it "returns all private and internal snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :all)
snippets.should include(@snippet2, @snippet3)
snippets.should_not include(@snippet1)
expect(snippets).to include(@snippet2, @snippet3)
expect(snippets).not_to include(@snippet1)
end
it "returns all public snippets" do
snippets = SnippetsFinder.new.execute(nil, filter: :all)
snippets.should include(@snippet3)
snippets.should_not include(@snippet1, @snippet2)
expect(snippets).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2)
end
end
......@@ -38,37 +38,37 @@ describe SnippetsFinder do
it "returns all public and internal snippets" do
snippets = SnippetsFinder.new.execute(user1, filter: :by_user, user: user)
snippets.should include(@snippet2, @snippet3)
snippets.should_not include(@snippet1)
expect(snippets).to include(@snippet2, @snippet3)
expect(snippets).not_to include(@snippet1)
end
it "returns internal snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_internal")
snippets.should include(@snippet2)
snippets.should_not include(@snippet1, @snippet3)
expect(snippets).to include(@snippet2)
expect(snippets).not_to include(@snippet1, @snippet3)
end
it "returns private snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_private")
snippets.should include(@snippet1)
snippets.should_not include(@snippet2, @snippet3)
expect(snippets).to include(@snippet1)
expect(snippets).not_to include(@snippet2, @snippet3)
end
it "returns public snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user, scope: "are_public")
snippets.should include(@snippet3)
snippets.should_not include(@snippet1, @snippet2)
expect(snippets).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2)
end
it "returns all snippets" do
snippets = SnippetsFinder.new.execute(user, filter: :by_user, user: user)
snippets.should include(@snippet1, @snippet2, @snippet3)
expect(snippets).to include(@snippet1, @snippet2, @snippet3)
end
it "returns only public snippets if unauthenticated user" do
snippets = SnippetsFinder.new.execute(nil, filter: :by_user, user: user)
snippets.should include(@snippet3)
snippets.should_not include(@snippet2, @snippet1)
expect(snippets).to include(@snippet3)
expect(snippets).not_to include(@snippet2, @snippet1)
end
end
......@@ -82,20 +82,20 @@ describe SnippetsFinder do
it "returns public snippets for unauthorized user" do
snippets = SnippetsFinder.new.execute(nil, filter: :by_project, project: project1)
snippets.should include(@snippet3)
snippets.should_not include(@snippet1, @snippet2)
expect(snippets).to include(@snippet3)
expect(snippets).not_to include(@snippet1, @snippet2)
end
it "returns public and internal snippets for none project members" do
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1)
snippets.should include(@snippet2, @snippet3)
snippets.should_not include(@snippet1)
expect(snippets).to include(@snippet2, @snippet3)
expect(snippets).not_to include(@snippet1)
end
it "returns all snippets for project members" do
project1.team << [user, :developer]
snippets = SnippetsFinder.new.execute(user, filter: :by_project, project: project1)
snippets.should include(@snippet1, @snippet2, @snippet3)
expect(snippets).to include(@snippet1, @snippet2, @snippet3)
end
end
end
......@@ -3,20 +3,20 @@ require 'spec_helper'
describe ApplicationHelper do
describe 'current_controller?' do
before do
controller.stub(:controller_name).and_return('foo')
allow(controller).to receive(:controller_name).and_return('foo')
end
it 'returns true when controller matches argument' do
current_controller?(:foo).should be_true
expect(current_controller?(:foo)).to be_truthy
end
it 'returns false when controller does not match argument' do
current_controller?(:bar).should_not be_true
expect(current_controller?(:bar)).not_to be_truthy
end
it 'should take any number of arguments' do
current_controller?(:baz, :bar).should_not be_true
current_controller?(:baz, :bar, :foo).should be_true
expect(current_controller?(:baz, :bar)).not_to be_truthy
expect(current_controller?(:baz, :bar, :foo)).to be_truthy
end
end
......@@ -26,16 +26,16 @@ describe ApplicationHelper do
end
it 'returns true when action matches argument' do
current_action?(:foo).should be_true
expect(current_action?(:foo)).to be_truthy
end
it 'returns false when action does not match argument' do
current_action?(:bar).should_not be_true
expect(current_action?(:bar)).not_to be_truthy
end
it 'should take any number of arguments' do
current_action?(:baz, :bar).should_not be_true
current_action?(:baz, :bar, :foo).should be_true
expect(current_action?(:baz, :bar)).not_to be_truthy
expect(current_action?(:baz, :bar, :foo)).to be_truthy
end
end
......@@ -46,13 +46,13 @@ describe ApplicationHelper do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
expect(group_icon(group.path).to_s).to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end
it 'should give default avatar_icon when no avatar is present' do
group = create(:group)
group.save!
group_icon(group.path).should match('group_avatar.png')
expect(group_icon(group.path)).to match('group_avatar.png')
end
end
......@@ -63,17 +63,18 @@ describe ApplicationHelper do
project = create(:project)
project.avatar = File.open(avatar_file_path)
project.save!
project_icon(project.to_param).to_s.should ==
expect(project_icon(project.to_param).to_s).to eq(
"<img alt=\"Gitlab logo\" src=\"/uploads/project/avatar/#{ project.id }/gitlab_logo.png\" />"
)
end
it 'should give uploaded icon when present' do
project = create(:project)
project.save!
Project.any_instance.stub(:avatar_in_git).and_return(true)
allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true)
project_icon(project.to_param).to_s.should match(
expect(project_icon(project.to_param).to_s).to match(
image_tag(project_avatar_path(project)))
end
end
......@@ -85,7 +86,7 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
expect(avatar_icon(user.email).to_s).to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should return an url for the avatar with relative url' do
......@@ -95,13 +96,13 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
avatar_icon(user.email).to_s.should match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
expect(avatar_icon(user.email).to_s).to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should call gravatar_icon when no avatar is present' do
user = create(:user, email: 'test@example.com')
user.save!
avatar_icon(user.email).to_s.should == 'http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon'
expect(avatar_icon(user.email).to_s).to eq('http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon')
end
end
......@@ -110,42 +111,42 @@ describe ApplicationHelper do
it 'should return a generic avatar path when Gravatar is disabled' do
ApplicationSetting.any_instance.stub(gravatar_enabled?: false)
gravatar_icon(user_email).should match('no_avatar.png')
expect(gravatar_icon(user_email)).to match('no_avatar.png')
end
it 'should return a generic avatar path when email is blank' do
gravatar_icon('').should match('no_avatar.png')
expect(gravatar_icon('')).to match('no_avatar.png')
end
it 'should return default gravatar url' do
Gitlab.config.gitlab.stub(https: false)
gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
expect(gravatar_icon(user_email)).to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
end
it 'should use SSL when appropriate' do
Gitlab.config.gitlab.stub(https: true)
gravatar_icon(user_email).should match('https://secure.gravatar.com')
expect(gravatar_icon(user_email)).to match('https://secure.gravatar.com')
end
it 'should return custom gravatar path when gravatar_url is set' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
allow(Gitlab.config.gravatar).to receive(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
expect(gravatar_icon(user_email, 20)).to eq('http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118')
end
it 'should accept a custom size' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
gravatar_icon(user_email, 64).should match(/\?s=64/)
expect(gravatar_icon(user_email, 64)).to match(/\?s=64/)
end
it 'should use default size when size is wrong' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
gravatar_icon(user_email, nil).should match(/\?s=40/)
expect(gravatar_icon(user_email, nil)).to match(/\?s=40/)
end
it 'should be case insensitive' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + ' ')
expect(gravatar_icon(user_email)).to eq(gravatar_icon(user_email.upcase + ' '))
end
end
......@@ -163,28 +164,28 @@ describe ApplicationHelper do
end
it 'includes a list of branch names' do
options[0][0].should == 'Branches'
options[0][1].should include('master', 'feature')
expect(options[0][0]).to eq('Branches')
expect(options[0][1]).to include('master', 'feature')
end
it 'includes a list of tag names' do
options[1][0].should == 'Tags'
options[1][1].should include('v1.0.0','v1.1.0')
expect(options[1][0]).to eq('Tags')
expect(options[1][1]).to include('v1.0.0','v1.1.0')
end
it 'includes a specific commit ref if defined' do
# Must be an instance variable
@ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
options[2][0].should == 'Commit'
options[2][1].should == [@ref]
expect(options[2][0]).to eq('Commit')
expect(options[2][1]).to eq([@ref])
end
it 'sorts tags in a natural order' do
# Stub repository.tag_names to make sure we get some valid testing data
expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
options[1][1].should == ['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9']
expect(options[1][1]).to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
end
end
......@@ -192,7 +193,7 @@ describe ApplicationHelper do
context 'with current_user is nil' do
it 'should return a string' do
allow(self).to receive(:current_user).and_return(nil)
user_color_scheme_class.should be_kind_of(String)
expect(user_color_scheme_class).to be_kind_of(String)
end
end
......@@ -202,7 +203,7 @@ describe ApplicationHelper do
it 'should return a string' do
current_user = double(:color_scheme_id => color_scheme_id)
allow(self).to receive(:current_user).and_return(current_user)
user_color_scheme_class.should be_kind_of(String)
expect(user_color_scheme_class).to be_kind_of(String)
end
end
end
......@@ -213,17 +214,17 @@ describe ApplicationHelper do
let(:a_tag) { '<a href="#">Foo</a>' }
it 'allows the a tag' do
simple_sanitize(a_tag).should == a_tag
expect(simple_sanitize(a_tag)).to eq(a_tag)
end
it 'allows the span tag' do
input = '<span class="foo">Bar</span>'
simple_sanitize(input).should == input
expect(simple_sanitize(input)).to eq(input)
end
it 'disallows other tags' do
input = "<strike><b>#{a_tag}</b></strike>"
simple_sanitize(input).should == a_tag
expect(simple_sanitize(input)).to eq(a_tag)
end
end
......@@ -254,7 +255,7 @@ describe ApplicationHelper do
let(:content) { 'Noël' }
it 'should preserve encoding' do
content.encoding.name.should == 'UTF-8'
expect(content.encoding.name).to eq('UTF-8')
expect(render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
end
end
......
......@@ -6,7 +6,7 @@ describe BroadcastMessagesHelper do
context "default style" do
it "should have no style" do
broadcast_styling(broadcast_message).should match('')
expect(broadcast_styling(broadcast_message)).to match('')
end
end
......@@ -14,7 +14,7 @@ describe BroadcastMessagesHelper do
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
it "should have a customized style" do
broadcast_styling(broadcast_message).should match('background-color:#f2dede;color:#b94a48')
expect(broadcast_styling(broadcast_message)).to match('background-color:#f2dede;color:#b94a48')
end
end
end
......
......@@ -10,58 +10,58 @@ describe DiffHelper do
describe 'diff_hard_limit_enabled?' do
it 'should return true if param is provided' do
controller.stub(:params).and_return { { :force_show_diff => true } }
diff_hard_limit_enabled?.should be_true
allow(controller).to receive(:params) { { :force_show_diff => true } }
expect(diff_hard_limit_enabled?).to be_truthy
end
it 'should return false if param is not provided' do
diff_hard_limit_enabled?.should be_false
expect(diff_hard_limit_enabled?).to be_falsey
end
end
describe 'allowed_diff_size' do
it 'should return hard limit for a diff if force diff is true' do
controller.stub(:params).and_return { { :force_show_diff => true } }
allowed_diff_size.should eq(1000)
allow(controller).to receive(:params) { { :force_show_diff => true } }
expect(allowed_diff_size).to eq(1000)
end
it 'should return safe limit for a diff if force diff is false' do
allowed_diff_size.should eq(100)
expect(allowed_diff_size).to eq(100)
end
end
describe 'parallel_diff' do
it 'should return an array of arrays containing the parsed diff' do
parallel_diff(diff_file, 0).should match_array(parallel_diff_result_array)
expect(parallel_diff(diff_file, 0)).to match_array(parallel_diff_result_array)
end
end
describe 'generate_line_code' do
it 'should generate correct line code' do
generate_line_code(diff_file.file_path, diff_file.diff_lines.first).should == '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6'
expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
end
end
describe 'unfold_bottom_class' do
it 'should return empty string when bottom line shouldnt be unfolded' do
unfold_bottom_class(false).should == ''
expect(unfold_bottom_class(false)).to eq('')
end
it 'should return js class when bottom lines should be unfolded' do
unfold_bottom_class(true).should == 'js-unfold-bottom'
expect(unfold_bottom_class(true)).to eq('js-unfold-bottom')
end
end
describe 'diff_line_content' do
it 'should return non breaking space when line is empty' do
diff_line_content(nil).should eq(" &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.
......@@ -8,18 +8,18 @@ describe IssuesHelper do
describe "title_for_issue" do
it "should return issue title if used internal tracker" do
@project = project
title_for_issue(issue.iid).should eq issue.title
expect(title_for_issue(issue.iid)).to eq issue.title
end
it "should always return empty string if used external tracker" do
@project = ext_project
title_for_issue(rand(100)).should eq ""
expect(title_for_issue(rand(100))).to eq ""
end
it "should always return empty string if project nil" do
@project = nil
title_for_issue(rand(100)).should eq ""
expect(title_for_issue(rand(100))).to eq ""
end
end
......@@ -33,29 +33,29 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
url_for_project_issues.should match(int_expected)
expect(url_for_project_issues).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
url_for_project_issues.should match(ext_expected)
expect(url_for_project_issues).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
url_for_project_issues.should eq ""
expect(url_for_project_issues).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
Gitlab.config.stub(:issues_tracker).and_return(nil)
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return path to external tracker" do
url_for_project_issues.should match(ext_expected)
expect(url_for_project_issues).to match(ext_expected)
end
end
end
......@@ -71,34 +71,34 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
url_for_issue(issue.iid).should match(int_expected)
expect(url_for_issue(issue.iid)).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
url_for_issue(issue.iid).should match(ext_expected)
expect(url_for_issue(issue.iid)).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
url_for_issue(issue.iid).should eq ""
expect(url_for_issue(issue.iid)).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
Gitlab.config.stub(:issues_tracker).and_return(nil)
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return external path" do
url_for_issue(issue.iid).should match(ext_expected)
expect(url_for_issue(issue.iid)).to match(ext_expected)
end
end
end
describe :url_for_new_issue do
describe '#url_for_new_issue' do
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
let(:ext_expected) do
issues_url.gsub(':project_id', ext_project.id.to_s)
......@@ -108,29 +108,29 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
url_for_new_issue.should match(int_expected)
expect(url_for_new_issue).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
url_for_new_issue.should match(ext_expected)
expect(url_for_new_issue).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
url_for_new_issue.should eq ""
expect(url_for_new_issue).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
Gitlab.config.stub(:issues_tracker).and_return(nil)
allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return internal path" do
url_for_new_issue.should match(ext_expected)
expect(url_for_new_issue).to match(ext_expected)
end
end
end
......
......@@ -7,6 +7,6 @@ describe MergeRequestsHelper do
[build(:issue, iid: 1), build(:issue, iid: 2), build(:issue, iid: 3)]
end
it { should eq('#1, #2, and #3') }
it { is_expected.to eq('#1, #2, and #3') }
end
end
......@@ -11,7 +11,7 @@ describe NotificationsHelper do
before { notification.stub(disabled?: true) }
it "has a red icon" do
notification_icon(notification).should match('class="fa fa-volume-off ns-mute"')
expect(notification_icon(notification)).to match('class="fa fa-volume-off ns-mute"')
end
end
......@@ -19,7 +19,7 @@ describe NotificationsHelper do
before { notification.stub(participating?: true) }
it "has a blue icon" do
notification_icon(notification).should match('class="fa fa-volume-down ns-part"')
expect(notification_icon(notification)).to match('class="fa fa-volume-down ns-part"')
end
end
......@@ -27,12 +27,12 @@ describe NotificationsHelper do
before { notification.stub(watch?: true) }
it "has a green icon" do
notification_icon(notification).should match('class="fa fa-volume-up ns-watch"')
expect(notification_icon(notification)).to match('class="fa fa-volume-up ns-watch"')
end
end
it "has a blue icon" do
notification_icon(notification).should match('class="fa fa-circle-o ns-default"')
expect(notification_icon(notification)).to match('class="fa fa-circle-o ns-default"')
end
end
end
......@@ -4,17 +4,17 @@ describe OauthHelper do
describe "additional_providers" do
it 'returns all enabled providers' do
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :github] }
helper.additional_providers.should include(*[:twitter, :github])
expect(helper.additional_providers).to include(*[:twitter, :github])
end
it 'does not return ldap provider' do
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :ldapmain] }
helper.additional_providers.should include(:twitter)
expect(helper.additional_providers).to include(:twitter)
end
it 'returns empty array' do
allow(helper).to receive(:enabled_oauth_providers) { [] }
helper.additional_providers.should == []
expect(helper.additional_providers).to eq([])
end
end
end
\ 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
......
......@@ -9,17 +9,17 @@ describe Gitlab::GitAccess do
describe 'push to none protected branch' do
it "returns true if user is a master" do
project.team << [user, :master]
Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_true
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy
end
it "returns true if user is a developer" do
project.team << [user, :developer]
Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_true
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy
end
it "returns false if user is a reporter" do
project.team << [user, :reporter]
Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_false
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_falsey
end
end
......@@ -30,17 +30,17 @@ describe Gitlab::GitAccess do
it "returns true if user is a master" do
project.team << [user, :master]
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy
end
it "returns false if user is a developer" do
project.team << [user, :developer]
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey
end
it "returns false if user is a reporter" do
project.team << [user, :reporter]
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey
end
end
......@@ -51,17 +51,17 @@ describe Gitlab::GitAccess do
it "returns true if user is a master" do
project.team << [user, :master]
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy
end
it "returns true if user is a developer" do
project.team << [user, :developer]
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy
end
it "returns false if user is a reporter" do
project.team << [user, :reporter]
Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false
expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey
end
end
......@@ -74,7 +74,7 @@ describe Gitlab::GitAccess do
context 'pull code' do
subject { access.download_access_check(user, project) }
it { subject.allowed?.should be_true }
it { expect(subject.allowed?).to be_truthy }
end
end
......@@ -84,7 +84,7 @@ describe Gitlab::GitAccess do
context 'pull code' do
subject { access.download_access_check(user, project) }
it { subject.allowed?.should be_false }
it { expect(subject.allowed?).to be_falsey }
end
end
......@@ -97,7 +97,7 @@ describe Gitlab::GitAccess do
context 'pull code' do
subject { access.download_access_check(user, project) }
it { subject.allowed?.should be_false }
it { expect(subject.allowed?).to be_falsey }
end
end
......@@ -105,7 +105,7 @@ describe Gitlab::GitAccess do
context 'pull code' do
subject { access.download_access_check(user, project) }
it { subject.allowed?.should be_false }
it { expect(subject.allowed?).to be_falsey }
end
end
......@@ -117,13 +117,13 @@ describe Gitlab::GitAccess do
before { key.projects << project }
subject { access.download_access_check(key, project) }
it { subject.allowed?.should be_true }
it { expect(subject.allowed?).to be_truthy }
end
context 'denied' do
subject { access.download_access_check(key, project) }
it { subject.allowed?.should be_false }
it { expect(subject.allowed?).to be_falsey }
end
end
end
......@@ -207,7 +207,7 @@ describe Gitlab::GitAccess do
context action do
subject { access.push_access_check(user, project, changes[action]) }
it { subject.allowed?.should allowed ? be_true : be_false }
it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey }
end
end
end
......@@ -223,7 +223,7 @@ describe Gitlab::GitAccess do
context action do
subject { access.push_access_check(user, project, changes[action]) }
it { subject.allowed?.should allowed ? be_true : be_false }
it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey }
end
end
end
......
......@@ -13,7 +13,7 @@ describe Gitlab::GitAccessWiki do
subject { access.push_access_check(user, project, changes) }
it { subject.allowed?.should be_true }
it { expect(subject.allowed?).to be_truthy }
end
def changes
......
......@@ -13,13 +13,13 @@ describe Gitlab::Github::ProjectCreator do
let(:namespace){ create(:namespace) }
it 'creates project' do
Project.any_instance.stub(:add_import_job)
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::Github::ProjectCreator.new(repo, namespace, user)
project_creator.execute
project = Project.last
project.import_url.should == "https://asdffg@gitlab.com/asd/vim.git"
project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE
expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
......@@ -13,13 +13,13 @@ describe Gitlab::GitlabImport::ProjectCreator do
let(:namespace){ create(:namespace) }
it 'creates project' do
Project.any_instance.stub(:add_import_job)
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user)
project_creator.execute
project = Project.last
project.import_url.should == "https://oauth2:asdffg@gitlab.com/asd/vim.git"
project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE
expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
......@@ -5,24 +5,24 @@ describe Gitlab::MarkdownHelper do
%w(textile rdoc org creole wiki
mediawiki rst adoc asciidoc asc).each do |type|
it "returns true for #{type} files" do
Gitlab::MarkdownHelper.markup?("README.#{type}").should be_true
expect(Gitlab::MarkdownHelper.markup?("README.#{type}")).to be_truthy
end
end
it 'returns false when given a non-markup filename' do
Gitlab::MarkdownHelper.markup?('README.rb').should_not be_true
expect(Gitlab::MarkdownHelper.markup?('README.rb')).not_to be_truthy
end
end
describe '#gitlab_markdown?' do
%w(mdown md markdown).each do |type|
it "returns true for #{type} files" do
Gitlab::MarkdownHelper.gitlab_markdown?("README.#{type}").should be_true
expect(Gitlab::MarkdownHelper.gitlab_markdown?("README.#{type}")).to be_truthy
end
end
it 'returns false when given a non-markdown filename' do
Gitlab::MarkdownHelper.gitlab_markdown?('README.rb').should_not be_true
expect(Gitlab::MarkdownHelper.gitlab_markdown?('README.rb')).not_to be_truthy
end
end
end
......@@ -10,7 +10,7 @@ describe Gitlab::LDAP::Access do
context 'when the user cannot be found' do
before { Gitlab::LDAP::Person.stub(find_by_dn: nil) }
it { should be_false }
it { is_expected.to be_falsey }
end
context 'when the user is found' do
......@@ -19,13 +19,13 @@ describe Gitlab::LDAP::Access do
context 'and the user is diabled via active directory' do
before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: true) }
it { should be_false }
it { is_expected.to be_falsey }
end
context 'and has no disabled flag in active diretory' do
before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false) }
it { should be_true }
it { is_expected.to be_truthy }
end
context 'without ActiveDirectory enabled' do
......@@ -34,7 +34,7 @@ describe Gitlab::LDAP::Access do
Gitlab::LDAP::Config.any_instance.stub(active_directory: false)
end
it { should be_true }
it { is_expected.to be_truthy }
end
end
end
......
......@@ -12,20 +12,20 @@ describe Gitlab::LDAP::Adapter do
context "and the result is non-empty" do
before { ldap.stub(search: [:foo]) }
it { should be_true }
it { is_expected.to be_truthy }
end
context "and the result is empty" do
before { ldap.stub(search: []) }
it { should be_false }
it { is_expected.to be_falsey }
end
end
context "when the search encounters an error" do
before { ldap.stub(search: nil, get_operation_result: double(code: 1, message: 'some error')) }
it { should be_false }
it { is_expected.to be_falsey }
end
end
end
......@@ -19,7 +19,7 @@ describe Gitlab::LDAP::Authentication do
klass.any_instance.stub(adapter: double(:adapter,
bind_as: double(:ldap_user, dn: dn)
))
expect(klass.login(login, password)).to be_true
expect(klass.login(login, password)).to be_truthy
end
it "is false if the user does not exist" do
......@@ -27,27 +27,27 @@ describe Gitlab::LDAP::Authentication do
klass.any_instance.stub(adapter: double(:adapter,
bind_as: double(:ldap_user, dn: dn)
))
expect(klass.login(login, password)).to be_false
expect(klass.login(login, password)).to be_falsey
end
it "is false if authentication fails" do
user
# try only to fake the LDAP call
klass.any_instance.stub(adapter: double(:adapter, bind_as: nil))
expect(klass.login(login, password)).to be_false
expect(klass.login(login, password)).to be_falsey
end
it "fails if ldap is disabled" do
Gitlab::LDAP::Config.stub(enabled?: false)
expect(klass.login(login, password)).to be_false
expect(klass.login(login, password)).to be_falsey
end
it "fails if no login is supplied" do
expect(klass.login('', password)).to be_false
expect(klass.login('', password)).to be_falsey
end
it "fails if no password is supplied" do
expect(klass.login(login, '')).to be_false
expect(klass.login(login, '')).to be_falsey
end
end
end
\ No newline at end of file
......@@ -4,7 +4,7 @@ describe Gitlab::LDAP::Config do
let(:config) { Gitlab::LDAP::Config.new provider }
let(:provider) { 'ldapmain' }
describe :initalize do
describe '#initalize' do
it 'requires a provider' do
expect{ Gitlab::LDAP::Config.new }.to raise_error ArgumentError
end
......
......@@ -16,17 +16,17 @@ describe Gitlab::LDAP::User do
describe :changed? do
it "marks existing ldap user as changed" do
existing_user = create(:omniauth_user, extern_uid: 'my-uid', provider: 'ldapmain')
expect(gl_user.changed?).to be_true
expect(gl_user.changed?).to be_truthy
end
it "marks existing non-ldap user if the email matches as changed" do
existing_user = create(:user, email: 'john@example.com')
expect(gl_user.changed?).to be_true
expect(gl_user.changed?).to be_truthy
end
it "dont marks existing ldap user as changed" do
existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain')
expect(gl_user.changed?).to be_false
expect(gl_user.changed?).to be_falsey
end
end
......
......@@ -19,12 +19,12 @@ describe Gitlab::OAuth::User do
it "finds an existing user based on uid and provider (facebook)" do
auth = double(info: double(name: 'John'), uid: 'my-uid', provider: 'my-provider')
expect( oauth_user.persisted? ).to be_true
expect( oauth_user.persisted? ).to be_truthy
end
it "returns false if use is not found in database" do
auth_hash.stub(uid: 'non-existing')
expect( oauth_user.persisted? ).to be_false
expect( oauth_user.persisted? ).to be_falsey
end
end
......@@ -62,8 +62,8 @@ describe Gitlab::OAuth::User do
it do
oauth_user.save
gl_user.should be_valid
gl_user.should_not be_blocked
expect(gl_user).to be_valid
expect(gl_user).not_to be_blocked
end
end
......@@ -72,8 +72,8 @@ describe Gitlab::OAuth::User do
it do
oauth_user.save
gl_user.should be_valid
gl_user.should be_blocked
expect(gl_user).to be_valid
expect(gl_user).to be_blocked
end
end
end
......@@ -89,8 +89,8 @@ describe Gitlab::OAuth::User do
it do
oauth_user.save
gl_user.should be_valid
gl_user.should_not be_blocked
expect(gl_user).to be_valid
expect(gl_user).not_to be_blocked
end
end
......@@ -99,8 +99,8 @@ describe Gitlab::OAuth::User do
it do
oauth_user.save
gl_user.should be_valid
gl_user.should_not be_blocked
expect(gl_user).to be_valid
expect(gl_user).not_to be_blocked
end
end
end
......
......@@ -13,8 +13,8 @@ describe 'Gitlab::Popen', no_db: true do
@output, @status = @klass.new.popen(%W(ls), path)
end
it { @status.should be_zero }
it { @output.should include('cache') }
it { expect(@status).to be_zero }
it { expect(@output).to include('cache') }
end
context 'non-zero status' do
......@@ -22,8 +22,8 @@ describe 'Gitlab::Popen', no_db: true do
@output, @status = @klass.new.popen(%W(cat NOTHING), path)
end
it { @status.should == 1 }
it { @output.should include('No such file or directory') }
it { expect(@status).to eq(1) }
it { expect(@output).to include('No such file or directory') }
end
context 'unsafe string command' do
......@@ -37,8 +37,8 @@ describe 'Gitlab::Popen', no_db: true do
@output, @status = @klass.new.popen(%W(ls))
end
it { @status.should be_zero }
it { @output.should include('spec') }
it { expect(@status).to be_zero }
it { expect(@output).to include('spec') }
end
end
......
......@@ -8,12 +8,12 @@ describe 'Gitlab::PushDataBuilder' do
describe :build_sample do
let(:data) { Gitlab::PushDataBuilder.build_sample(project, user) }
it { data.should be_a(Hash) }
it { data[:before].should == '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' }
it { data[:after].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
it { data[:ref].should == 'refs/heads/master' }
it { data[:commits].size.should == 3 }
it { data[:total_commits_count].should == 3 }
it { expect(data).to be_a(Hash) }
it { expect(data[:before]).to eq('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
it { expect(data[:after]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { expect(data[:ref]).to eq('refs/heads/master') }
it { expect(data[:commits].size).to eq(3) }
it { expect(data[:total_commits_count]).to eq(3) }
end
describe :build do
......@@ -25,12 +25,12 @@ describe 'Gitlab::PushDataBuilder' do
'refs/tags/v1.1.0')
end
it { data.should be_a(Hash) }
it { data[:before].should == Gitlab::Git::BLANK_SHA }
it { data[:checkout_sha].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
it { data[:after].should == '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b' }
it { data[:ref].should == 'refs/tags/v1.1.0' }
it { data[:commits].should be_empty }
it { data[:total_commits_count].should be_zero }
it { expect(data).to be_a(Hash) }
it { expect(data[:before]).to eq(Gitlab::Git::BLANK_SHA) }
it { expect(data[:checkout_sha]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
it { expect(data[:after]).to eq('8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b') }
it { expect(data[:ref]).to eq('refs/tags/v1.1.0') }
it { expect(data[:commits]).to be_empty }
it { expect(data[:total_commits_count]).to be_zero }
end
end
This diff is collapsed.
......@@ -2,20 +2,20 @@ require 'spec_helper'
describe Gitlab::Regex do
describe 'path regex' do
it { 'gitlab-ce'.should match(Gitlab::Regex.path_regex) }
it { 'gitlab_git'.should match(Gitlab::Regex.path_regex) }
it { '_underscore.js'.should match(Gitlab::Regex.path_regex) }
it { '100px.com'.should match(Gitlab::Regex.path_regex) }
it { '?gitlab'.should_not match(Gitlab::Regex.path_regex) }
it { 'git lab'.should_not match(Gitlab::Regex.path_regex) }
it { 'gitlab.git'.should_not match(Gitlab::Regex.path_regex) }
it { expect('gitlab-ce').to match(Gitlab::Regex.path_regex) }
it { expect('gitlab_git').to match(Gitlab::Regex.path_regex) }
it { expect('_underscore.js').to match(Gitlab::Regex.path_regex) }
it { expect('100px.com').to match(Gitlab::Regex.path_regex) }
it { expect('?gitlab').not_to match(Gitlab::Regex.path_regex) }
it { expect('git lab').not_to match(Gitlab::Regex.path_regex) }
it { expect('gitlab.git').not_to match(Gitlab::Regex.path_regex) }
end
describe 'project name regex' do
it { 'gitlab-ce'.should match(Gitlab::Regex.project_name_regex) }
it { 'GitLab CE'.should match(Gitlab::Regex.project_name_regex) }
it { '100 lines'.should match(Gitlab::Regex.project_name_regex) }
it { 'gitlab.git'.should match(Gitlab::Regex.project_name_regex) }
it { '?gitlab'.should_not match(Gitlab::Regex.project_name_regex) }
it { expect('gitlab-ce').to match(Gitlab::Regex.project_name_regex) }
it { expect('GitLab CE').to match(Gitlab::Regex.project_name_regex) }
it { expect('100 lines').to match(Gitlab::Regex.project_name_regex) }
it { expect('gitlab.git').to match(Gitlab::Regex.project_name_regex) }
it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) }
end
end
This diff is collapsed.
......@@ -5,20 +5,20 @@ describe Gitlab::Upgrader do
let(:current_version) { Gitlab::VERSION }
describe 'current_version_raw' do
it { upgrader.current_version_raw.should == current_version }
it { expect(upgrader.current_version_raw).to eq(current_version) }
end
describe 'latest_version?' do
it 'should be true if newest version' do
upgrader.stub(latest_version_raw: current_version)
upgrader.latest_version?.should be_true
expect(upgrader.latest_version?).to be_truthy
end
end
describe 'latest_version_raw' do
it 'should be latest version for GitLab 5' do
upgrader.stub(current_version_raw: "5.3.0")
upgrader.latest_version_raw.should == "v5.4.2"
expect(upgrader.latest_version_raw).to eq("v5.4.2")
end
end
end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -17,5 +17,5 @@
require 'spec_helper'
describe ApplicationSetting, models: true do
it { ApplicationSetting.create_from_defaults.should be_valid }
it { expect(ApplicationSetting.create_from_defaults).to be_valid }
end
This diff is collapsed.
......@@ -18,22 +18,22 @@ require 'spec_helper'
describe BroadcastMessage do
subject { create(:broadcast_message) }
it { should be_valid }
it { is_expected.to be_valid }
describe :current do
it "should return last message if time match" do
broadcast_message = create(:broadcast_message, starts_at: Time.now.yesterday, ends_at: Time.now.tomorrow)
BroadcastMessage.current.should == broadcast_message
expect(BroadcastMessage.current).to eq(broadcast_message)
end
it "should return nil if time not come" do
broadcast_message = create(:broadcast_message, starts_at: Time.now.tomorrow, ends_at: Time.now + 2.days)
BroadcastMessage.current.should be_nil
expect(BroadcastMessage.current).to be_nil
end
it "should return nil if time has passed" do
broadcast_message = create(:broadcast_message, starts_at: Time.now - 2.days, ends_at: Time.now.yesterday)
BroadcastMessage.current.should be_nil
expect(BroadcastMessage.current).to be_nil
end
end
end
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