Skip to content
Snippets Groups Projects
Commit 0c4a70a3 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen
Browse files

Updated rspec to rspec 3.x syntax

parent de1c450a
No related branches found
No related tags found
2 merge requests!8785Rspec upgrade,!8686add "Uplaod" and "Replace" functionality
Showing
with 104 additions and 104 deletions
Loading
Loading
@@ -4,4 +4,4 @@ begin
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec', 'rspec')
load Gem.bin_path('rspec-core', 'rspec')
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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)
 
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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)
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment