Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-02-12 21:17:35 +0300
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-02-12 21:17:35 +0300
commit0c4a70a306b871899bf87ce4673918abfee4d95f (patch)
treec7a702fb511209ffe0eceba245d1ffea71dce1aa /spec/controllers
parentde1c450abd6b367390a1295cac402344f500d41d (diff)
Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/application_controller_spec.rb20
-rw-r--r--spec/controllers/blob_controller_spec.rb12
-rw-r--r--spec/controllers/branches_controller_spec.rb12
-rw-r--r--spec/controllers/commit_controller_spec.rb4
-rw-r--r--spec/controllers/commits_controller_spec.rb4
-rw-r--r--spec/controllers/import/github_controller_spec.rb8
-rw-r--r--spec/controllers/import/gitlab_controller_spec.rb6
-rw-r--r--spec/controllers/merge_requests_controller_spec.rb4
-rw-r--r--spec/controllers/projects_controller_spec.rb10
-rw-r--r--spec/controllers/tree_controller_spec.rb14
10 files changed, 47 insertions, 47 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index cc32805f5ec..186239d3096 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -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
diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb
index 11d748ca77f..02f418053fa 100644
--- a/spec/controllers/blob_controller_spec.rb
+++ b/spec/controllers/blob_controller_spec.rb
@@ -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
diff --git a/spec/controllers/branches_controller_spec.rb b/spec/controllers/branches_controller_spec.rb
index 610d7a84e31..d31870058ca 100644
--- a/spec/controllers/branches_controller_spec.rb
+++ b/spec/controllers/branches_controller_spec.rb
@@ -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
diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb
index cd8b46d7672..507fd4e6ba7 100644
--- a/spec/controllers/commit_controller_spec.rb
+++ b/spec/controllers/commit_controller_spec.rb
@@ -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
diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb
index 0c19d755eb1..c3de01a84f2 100644
--- a/spec/controllers/commits_controller_spec.rb
+++ b/spec/controllers/commits_controller_spec.rb
@@ -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
diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb
index f80b3884d88..30bf54a908c 100644
--- a/spec/controllers/import/github_controller_spec.rb
+++ b/spec/controllers/import/github_controller_spec.rb
@@ -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)
diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb
index 36995091c69..322dec04a1e 100644
--- a/spec/controllers/import/gitlab_controller_spec.rb
+++ b/spec/controllers/import/gitlab_controller_spec.rb
@@ -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)
diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb
index 300527e4ff2..fde34e480bf 100644
--- a/spec/controllers/merge_requests_controller_spec.rb
+++ b/spec/controllers/merge_requests_controller_spec.rb
@@ -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
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 71bc49787cc..ef786ccd324 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -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
diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb
index 8147fb0e6fb..c228584c886 100644
--- a/spec/controllers/tree_controller_spec.rb
+++ b/spec/controllers/tree_controller_spec.rb
@@ -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