summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-12 16:47:52 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-02-12 16:47:52 -0800
commit529188e4788991961796b1b6131389072ee61efb (patch)
treec4c12a7b2cb287fbc4065c886e53740e1ec41ae5
parent2ff1b8e68d085a8b43507630b3986743d2a48145 (diff)
parent1343b2dfac288eb60d536cc3d1a94de1eb178b51 (diff)
downloadgitlab-ce-529188e4788991961796b1b6131389072ee61efb.tar.gz
Merge branch 'master' of github.com:gitlabhq/gitlabhq
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock28
-rwxr-xr-xbin/rspec2
-rw-r--r--features/steps/project/redirects.rb2
-rw-r--r--features/support/env.rb2
-rw-r--r--spec/controllers/application_controller_spec.rb20
-rw-r--r--spec/controllers/blob_controller_spec.rb15
-rw-r--r--spec/controllers/branches_controller_spec.rb18
-rw-r--r--spec/controllers/commit_controller_spec.rb5
-rw-r--r--spec/controllers/commits_controller_spec.rb4
-rw-r--r--spec/controllers/import/github_controller_spec.rb16
-rw-r--r--spec/controllers/import/gitlab_controller_spec.rb13
-rw-r--r--spec/controllers/merge_requests_controller_spec.rb5
-rw-r--r--spec/controllers/projects_controller_spec.rb10
-rw-r--r--spec/controllers/tree_controller_spec.rb18
-rw-r--r--spec/factories_spec.rb2
-rw-r--r--spec/features/admin/admin_hooks_spec.rb10
-rw-r--r--spec/features/admin/admin_projects_spec.rb8
-rw-r--r--spec/features/admin/admin_users_spec.rb40
-rw-r--r--spec/features/admin/security_spec.rb18
-rw-r--r--spec/features/atom/dashboard_issues_spec.rb13
-rw-r--r--spec/features/atom/dashboard_spec.rb7
-rw-r--r--spec/features/atom/issues_spec.rb33
-rw-r--r--spec/features/atom/users_spec.rb18
-rw-r--r--spec/features/gitlab_flavored_markdown_spec.rb24
-rw-r--r--spec/features/help_pages_spec.rb2
-rw-r--r--spec/features/issues_spec.rb145
-rw-r--r--spec/features/notes_on_merge_requests_spec.rb133
-rw-r--r--spec/features/profile_spec.rb20
-rw-r--r--spec/features/search_spec.rb2
-rw-r--r--spec/features/security/dashboard_access_spec.rb42
-rw-r--r--spec/features/security/group/group_access_spec.rb90
-rw-r--r--spec/features/security/group/internal_group_access_spec.rb70
-rw-r--r--spec/features/security/group/mixed_group_access_spec.rb70
-rw-r--r--spec/features/security/group/public_group_access_spec.rb70
-rw-r--r--spec/features/security/profile_access_spec.rb58
-rw-r--r--spec/features/security/project/internal_access_spec.rb213
-rw-r--r--spec/features/security/project/private_access_spec.rb189
-rw-r--r--spec/features/security/project/public_access_spec.rb213
-rw-r--r--spec/finders/issues_finder_spec.rb22
-rw-r--r--spec/finders/merge_requests_finder_spec.rb4
-rw-r--r--spec/finders/notes_finder_spec.rb4
-rw-r--r--spec/finders/projects_finder_spec.rb32
-rw-r--r--spec/finders/snippets_finder_spec.rb40
-rw-r--r--spec/helpers/application_helper_spec.rb91
-rw-r--r--spec/helpers/broadcast_messages_helper_spec.rb5
-rw-r--r--spec/helpers/diff_helper_spec.rb31
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb255
-rw-r--r--spec/helpers/issues_helper_spec.rb44
-rw-r--r--spec/helpers/merge_requests_helper.rb2
-rw-r--r--spec/helpers/notifications_helper_spec.rb8
-rw-r--r--spec/helpers/oauth_helper_spec.rb6
-rw-r--r--spec/helpers/projects_helper_spec.rb6
-rw-r--r--spec/helpers/search_helper_spec.rb14
-rw-r--r--spec/helpers/submodule_helper_spec.rb34
-rw-r--r--spec/helpers/tab_helper_spec.rb30
-rw-r--r--spec/helpers/tree_helper_spec.rb4
-rw-r--r--spec/lib/disable_email_interceptor_spec.rb2
-rw-r--r--spec/lib/extracts_path_spec.rb20
-rw-r--r--spec/lib/git_ref_validator_spec.rb32
-rw-r--r--spec/lib/gitlab/backend/shell_spec.rb12
-rw-r--r--spec/lib/gitlab/closing_issue_extractor_spec.rb68
-rw-r--r--spec/lib/gitlab/diff/file_spec.rb6
-rw-r--r--spec/lib/gitlab/diff/parser_spec.rb34
-rw-r--r--spec/lib/gitlab/git_access_spec.rb34
-rw-r--r--spec/lib/gitlab/git_access_wiki_spec.rb2
-rw-r--r--spec/lib/gitlab/github/project_creator.rb6
-rw-r--r--spec/lib/gitlab/gitlab_import/project_creator.rb6
-rw-r--r--spec/lib/gitlab/gitlab_markdown_helper_spec.rb8
-rw-r--r--spec/lib/gitlab/ldap/access_spec.rb8
-rw-r--r--spec/lib/gitlab/ldap/adapter_spec.rb6
-rw-r--r--spec/lib/gitlab/ldap/authentication_spec.rb12
-rw-r--r--spec/lib/gitlab/ldap/config_spec.rb2
-rw-r--r--spec/lib/gitlab/ldap/user_spec.rb6
-rw-r--r--spec/lib/gitlab/oauth/user_spec.rb20
-rw-r--r--spec/lib/gitlab/popen_spec.rb12
-rw-r--r--spec/lib/gitlab/push_data_builder_spec.rb26
-rw-r--r--spec/lib/gitlab/reference_extractor_spec.rb34
-rw-r--r--spec/lib/gitlab/regex_spec.rb24
-rw-r--r--spec/lib/gitlab/satellite/action_spec.rb44
-rw-r--r--spec/lib/gitlab/satellite/merge_action_spec.rb32
-rw-r--r--spec/lib/gitlab/upgrader_spec.rb6
-rw-r--r--spec/lib/gitlab/version_info_spec.rb52
-rw-r--r--spec/lib/votes_spec.rb68
-rw-r--r--spec/mailers/notify_spec.rb218
-rw-r--r--spec/models/application_setting_spec.rb2
-rw-r--r--spec/models/asana_service_spec.rb10
-rw-r--r--spec/models/broadcast_message_spec.rb8
-rw-r--r--spec/models/commit_spec.rb42
-rw-r--r--spec/models/concerns/issuable_spec.rb46
-rw-r--r--spec/models/concerns/mentionable_spec.rb4
-rw-r--r--spec/models/deploy_key_spec.rb4
-rw-r--r--spec/models/deploy_keys_project_spec.rb8
-rw-r--r--spec/models/event_spec.rb24
-rw-r--r--spec/models/forked_project_link_spec.rb10
-rw-r--r--spec/models/group_spec.rb30
-rw-r--r--spec/models/hooks/service_hook_spec.rb2
-rw-r--r--spec/models/hooks/system_hook_spec.rb20
-rw-r--r--spec/models/hooks/web_hook_spec.rb30
-rw-r--r--spec/models/issue_spec.rb10
-rw-r--r--spec/models/key_spec.rb28
-rw-r--r--spec/models/label_link_spec.rb6
-rw-r--r--spec/models/label_spec.rb30
-rw-r--r--spec/models/members/group_member_spec.rb6
-rw-r--r--spec/models/members/project_member_spec.rb26
-rw-r--r--spec/models/members_spec.rb12
-rw-r--r--spec/models/merge_request_spec.rb32
-rw-r--r--spec/models/milestone_spec.rb42
-rw-r--r--spec/models/namespace_spec.rb30
-rw-r--r--spec/models/note_spec.rb291
-rw-r--r--spec/models/project_security_spec.rb18
-rw-r--r--spec/models/project_services/assembla_service_spec.rb6
-rw-r--r--spec/models/project_services/buildbox_service_spec.rb18
-rw-r--r--spec/models/project_services/flowdock_service_spec.rb6
-rw-r--r--spec/models/project_services/gemnasium_service_spec.rb6
-rw-r--r--spec/models/project_services/gitlab_ci_service_spec.rb8
-rw-r--r--spec/models/project_services/jira_service_spec.rb12
-rw-r--r--spec/models/project_services/pushover_service_spec.rb12
-rw-r--r--spec/models/project_services/slack_message_spec.rb17
-rw-r--r--spec/models/project_services/slack_service_spec.rb8
-rw-r--r--spec/models/project_snippet_spec.rb4
-rw-r--r--spec/models/project_spec.rb130
-rw-r--r--spec/models/project_team_spec.rb44
-rw-r--r--spec/models/project_wiki_spec.rb80
-rw-r--r--spec/models/protected_branch_spec.rb6
-rw-r--r--spec/models/repository_spec.rb8
-rw-r--r--spec/models/service_spec.rb8
-rw-r--r--spec/models/snippet_spec.rb16
-rw-r--r--spec/models/user_spec.rb196
-rw-r--r--spec/models/wiki_page_spec.rb30
-rw-r--r--spec/requests/api/api_helpers_spec.rb78
-rw-r--r--spec/requests/api/branches_spec.rb80
-rw-r--r--spec/requests/api/commits_spec.rb70
-rw-r--r--spec/requests/api/doorkeeper_access_spec.rb6
-rw-r--r--spec/requests/api/files_spec.rb36
-rw-r--r--spec/requests/api/fork_spec.rb44
-rw-r--r--spec/requests/api/group_members_spec.rb44
-rw-r--r--spec/requests/api/groups_spec.rb62
-rw-r--r--spec/requests/api/internal_spec.rb62
-rw-r--r--spec/requests/api/issues_spec.rb213
-rw-r--r--spec/requests/api/labels_spec.rb84
-rw-r--r--spec/requests/api/merge_requests_spec.rb197
-rw-r--r--spec/requests/api/milestones_spec.rb52
-rw-r--r--spec/requests/api/namespaces_spec.rb8
-rw-r--r--spec/requests/api/notes_spec.rb78
-rw-r--r--spec/requests/api/project_hooks_spec.rb44
-rw-r--r--spec/requests/api/project_members_spec.rb68
-rw-r--r--spec/requests/api/projects_spec.rb310
-rw-r--r--spec/requests/api/repositories_spec.rb132
-rw-r--r--spec/requests/api/services_spec.rb18
-rw-r--r--spec/requests/api/session_spec.rb30
-rw-r--r--spec/requests/api/system_hooks_spec.rb20
-rw-r--r--spec/requests/api/users_spec.rb260
-rw-r--r--spec/routing/admin_routing_spec.rb40
-rw-r--r--spec/routing/notifications_routing_spec.rb4
-rw-r--r--spec/routing/project_routing_spec.rb176
-rw-r--r--spec/routing/routing_spec.rb88
-rw-r--r--spec/services/event_create_service_spec.rb18
-rw-r--r--spec/services/git_push_service_spec.rb96
-rw-r--r--spec/services/git_tag_push_service_spec.rb22
-rw-r--r--spec/services/issues/bulk_update_context_spec.rb28
-rw-r--r--spec/services/issues/close_service_spec.rb10
-rw-r--r--spec/services/issues/create_service_spec.rb4
-rw-r--r--spec/services/issues/update_service_spec.rb20
-rw-r--r--spec/services/merge_requests/close_service_spec.rb12
-rw-r--r--spec/services/merge_requests/create_service_spec.rb6
-rw-r--r--spec/services/merge_requests/merge_service_spec.rb12
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb40
-rw-r--r--spec/services/merge_requests/reopen_service_spec.rb12
-rw-r--r--spec/services/merge_requests/update_service_spec.rb22
-rw-r--r--spec/services/notes/create_service_spec.rb4
-rw-r--r--spec/services/notification_service_spec.rb64
-rw-r--r--spec/services/projects/create_service_spec.rb16
-rw-r--r--spec/services/projects/fork_service_spec.rb40
-rw-r--r--spec/services/projects/transfer_service_spec.rb16
-rw-r--r--spec/services/projects/update_service_spec.rb30
-rw-r--r--spec/services/search_service_spec.rb8
-rw-r--r--spec/services/system_hooks_service_spec.rb48
-rw-r--r--spec/services/test_hook_service_spec.rb2
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/support/db_cleaner.rb11
-rw-r--r--spec/support/mentionable_shared_examples.rb28
-rw-r--r--spec/support/taskable_shared_examples.rb4
-rw-r--r--spec/support/test_env.rb4
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb10
-rw-r--r--spec/tasks/gitlab/mail_google_schema_whitelisting.rb2
-rw-r--r--spec/workers/post_receive_spec.rb16
187 files changed, 3816 insertions, 3563 deletions
diff --git a/Gemfile b/Gemfile
index 4d6d6e7e143..c3d8299e944 100644
--- a/Gemfile
+++ b/Gemfile
@@ -222,7 +222,7 @@ group :development, :test do
gem 'rubocop', '0.28.0', require: false
# gem 'rails-dev-tweaks'
gem 'spinach-rails'
- gem "rspec-rails"
+ gem "rspec-rails", '2.99'
gem "capybara", '~> 2.2.1'
gem "pry-rails"
gem "awesome_print"
diff --git a/Gemfile.lock b/Gemfile.lock
index aef30046d33..3283da40f8d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -459,21 +459,25 @@ GEM
mime-types (>= 1.16)
rinku (1.7.3)
rouge (1.7.4)
- rspec (2.14.1)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
- rspec-core (2.14.7)
- rspec-expectations (2.14.4)
+ rspec (2.99.0)
+ rspec-core (~> 2.99.0)
+ rspec-expectations (~> 2.99.0)
+ rspec-mocks (~> 2.99.0)
+ rspec-collection_matchers (1.1.2)
+ rspec-expectations (>= 2.99.0.beta1)
+ rspec-core (2.99.2)
+ rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.14.4)
- rspec-rails (2.14.0)
+ rspec-mocks (2.99.3)
+ rspec-rails (2.99.0)
actionpack (>= 3.0)
+ activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
+ rspec-collection_matchers
+ rspec-core (~> 2.99.0)
+ rspec-expectations (~> 2.99.0)
+ rspec-mocks (~> 2.99.0)
rubocop (0.28.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
@@ -724,7 +728,7 @@ DEPENDENCIES
redcarpet (~> 3.1.2)
redis-rails
request_store
- rspec-rails
+ rspec-rails (= 2.99)
rubocop (= 0.28.0)
rugments
sanitize (~> 2.0)
diff --git a/bin/rspec b/bin/rspec
index 41e37089ac2..20060ebd79c 100755
--- a/bin/rspec
+++ b/bin/rspec
@@ -4,4 +4,4 @@ begin
rescue LoadError
end
require 'bundler/setup'
-load Gem.bin_path('rspec', 'rspec')
+load Gem.bin_path('rspec-core', 'rspec')
diff --git a/features/steps/project/redirects.rb b/features/steps/project/redirects.rb
index e54637120ce..e2badccbcf4 100644
--- a/features/steps/project/redirects.rb
+++ b/features/steps/project/redirects.rb
@@ -17,7 +17,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
end
step 'I should see project "Community" home page' do
- Gitlab.config.gitlab.stub(:host).and_return("www.example.com")
+ Gitlab.config.gitlab.should_receive(:host).and_return("www.example.com")
within '.navbar-gitlab .title' do
page.should have_content 'Community'
end
diff --git a/features/support/env.rb b/features/support/env.rb
index 67660777842..be17065ccfd 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -47,8 +47,8 @@ Spinach.hooks.after_scenario do
end
Spinach.hooks.before_run do
+ include RSpec::Mocks::ExampleMethods
TestEnv.init(mailer: false)
- RSpec::Mocks::setup self
include FactoryGirl::Syntax::Methods
end
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..ea52e4d212a 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,10 @@ describe Projects::BlobController do
context 'redirect to tree' do
let(:id) { 'markdown/doc' }
- it { should redirect_to("/#{project.path_with_namespace}/tree/markdown/doc") }
+ it 'redirects' do
+ expect(subject).
+ to redirect_to("/#{project.path_with_namespace}/tree/markdown/doc")
+ end
end
end
end
diff --git a/spec/controllers/branches_controller_spec.rb b/spec/controllers/branches_controller_spec.rb
index 610d7a84e31..0c39d016440 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,31 @@ describe Projects::BranchesController do
context "valid branch name, valid source" do
let(:branch) { "merge_branch" }
let(:ref) { "master" }
- it { should redirect_to("/#{project.path_with_namespace}/tree/merge_branch") }
+ it 'redirects' do
+ expect(subject).
+ to redirect_to("/#{project.path_with_namespace}/tree/merge_branch")
+ end
end
context "invalid branch name, valid ref" do
let(:branch) { "<script>alert('merge');</script>" }
let(:ref) { "master" }
- it { should redirect_to("/#{project.path_with_namespace}/tree/alert('merge');") }
+ it 'redirects' do
+ expect(subject).
+ to redirect_to("/#{project.path_with_namespace}/tree/alert('merge');")
+ end
end
context "valid branch name, invalid ref" do
let(:branch) { "merge_branch" }
let(:ref) { "<script>alert('ref');</script>" }
- it { should render_template("new") }
+ it { is_expected.to render_template('new') }
end
context "invalid branch name, invalid ref" do
let(:branch) { "<script>alert('merge');</script>" }
let(:ref) { "<script>alert('ref');</script>" }
- it { should render_template("new") }
+ it { is_expected.to render_template('new') }
end
end
end
diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb
index cd8b46d7672..f0e39e674fd 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,8 @@ describe Projects::CommitController do
end
it "should not escape Html" do
- Commit.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
+ allow_any_instance_of(Commit).to receive(:"to_#{format}").
+ and_return('HTML entities &<>" ')
get :show, project_id: project.to_param, id: commit.id, format: format
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..3b779855d3f 100644
--- a/spec/controllers/import/github_controller_spec.rb
+++ b/spec/controllers/import/github_controller_spec.rb
@@ -10,13 +10,16 @@ describe Import::GithubController do
describe "GET callback" do
it "updates access token" do
token = "asdasd12345"
- Gitlab::GithubImport::Client.any_instance.stub(:get_token).and_return(token)
- Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123", app_secret: "asd123", name: "github")
+ allow_any_instance_of(Gitlab::GithubImport::Client).
+ to receive(:get_token).and_return(token)
+ Gitlab.config.omniauth.providers << OpenStruct.new(app_id: 'asd123',
+ app_secret: 'asd123',
+ name: 'github')
get :callback
-
- user.reload.github_access_token.should == token
- controller.should redirect_to(status_import_github_url)
+
+ expect(user.reload.github_access_token).to eq(token)
+ expect(controller).to redirect_to(status_import_github_url)
end
end
@@ -55,7 +58,8 @@ describe Import::GithubController do
it "takes already existing namespace" do
namespace = create(:namespace, name: "john", owner: user)
- Gitlab::GithubImport::ProjectCreator.should_receive(:new).with(@repo, namespace, user).
+ expect(Gitlab::GithubImport::ProjectCreator).
+ to receive(:new).with(@repo, namespace, user).
and_return(double(execute: true))
controller.stub_chain(:client, :repo).and_return(@repo)
diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb
index 36995091c69..287aa315db5 100644
--- a/spec/controllers/import/gitlab_controller_spec.rb
+++ b/spec/controllers/import/gitlab_controller_spec.rb
@@ -14,9 +14,9 @@ describe Import::GitlabController do
Gitlab.config.omniauth.providers << OpenStruct.new(app_id: "asd123", app_secret: "asd123", name: "gitlab")
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
@@ -28,7 +28,7 @@ describe Import::GitlabController do
it "assigns variables" do
@project = create(:project, import_type: 'gitlab', creator_id: user.id)
controller.stub_chain(:client, :projects).and_return([@repo])
-
+
get :status
expect(assigns(:already_added_projects)).to eq([@project])
@@ -38,7 +38,7 @@ describe Import::GitlabController do
it "does not show already added project" do
@project = create(:project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim')
controller.stub_chain(:client, :projects).and_return([@repo])
-
+
get :status
expect(assigns(:already_added_projects)).to eq([@project])
@@ -58,7 +58,8 @@ describe Import::GitlabController do
it "takes already existing namespace" do
namespace = create(:namespace, name: "john", owner: user)
- Gitlab::GitlabImport::ProjectCreator.should_receive(:new).with(@repo, namespace, user).
+ expect(Gitlab::GitlabImport::ProjectCreator).
+ to receive(:new).with(@repo, namespace, user).
and_return(double(execute: true))
controller.stub_chain(:client, :project).and_return(@repo)
diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb
index 300527e4ff2..eedaf17941a 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,8 @@ describe Projects::MergeRequestsController do
end
it "should not escape Html" do
- MergeRequest.any_instance.stub(:"to_#{format}").and_return('HTML entities &<>" ')
+ allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").
+ and_return('HTML entities &<>" ')
get :show, project_id: project.to_param, id: merge_request.iid, format: format
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..805e0a8795b 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,11 @@ describe Projects::TreeController do
context 'redirect to blob' do
let(:id) { 'master/README.md' }
- it { should redirect_to("/#{project.path_with_namespace}/blob/master/README.md") }
+ it 'redirects' do
+ redirect_url = "/#{project.path_with_namespace}/blob/master/README.md"
+ expect(subject).
+ to redirect_to(redirect_url)
+ end
end
end
end
diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb
index 66bef0761c7..c8e218d4d03 100644
--- a/spec/factories_spec.rb
+++ b/spec/factories_spec.rb
@@ -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
diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb
index 37d6b416d22..25862614d28 100644
--- a/spec/features/admin/admin_hooks_spec.rb
+++ b/spec/features/admin/admin_hooks_spec.rb
@@ -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
diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb
index 3b3d027ab75..eae3d102334 100644
--- a/spec/features/admin/admin_projects_spec.rb
+++ b/spec/features/admin/admin_projects_spec.rb
@@ -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
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index 59c4ffb5624..f97b69713ce 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -9,12 +9,12 @@ describe "Admin::Users", feature: true do
end
it "should be ok" do
- current_path.should == admin_users_path
+ expect(current_path).to eq(admin_users_path)
end
it "should have users list" do
- page.should have_content(@user.email)
- page.should have_content(@user.name)
+ expect(page).to have_content(@user.email)
+ expect(page).to have_content(@user.name)
end
end
@@ -33,19 +33,21 @@ describe "Admin::Users", feature: true do
it "should apply defaults to user" do
click_button "Create user"
user = User.find_by(username: 'bang')
- user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
- user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
+ expect(user.projects_limit).
+ to eq(Gitlab.config.gitlab.default_projects_limit)
+ expect(user.can_create_group).
+ to eq(Gitlab.config.gitlab.default_can_create_group)
end
it "should create user with valid data" do
click_button "Create user"
user = User.find_by(username: 'bang')
- user.name.should == "Big Bang"
- user.email.should == "bigbang@mail.com"
+ expect(user.name).to eq('Big Bang')
+ expect(user.email).to eq('bigbang@mail.com')
end
it "should call send mail" do
- Notify.should_receive(:new_user_email)
+ expect(Notify).to receive(:new_user_email)
click_button "Create user"
end
@@ -54,9 +56,9 @@ describe "Admin::Users", feature: true do
click_button "Create user"
user = User.find_by(username: 'bang')
email = ActionMailer::Base.deliveries.last
- email.subject.should have_content("Account was created")
- email.text_part.body.should have_content(user.email)
- email.text_part.body.should have_content('password')
+ expect(email.subject).to have_content('Account was created')
+ expect(email.text_part.body).to have_content(user.email)
+ expect(email.text_part.body).to have_content('password')
end
end
@@ -67,8 +69,8 @@ describe "Admin::Users", feature: true do
end
it "should have user info" do
- page.should have_content(@user.email)
- page.should have_content(@user.name)
+ expect(page).to have_content(@user.email)
+ expect(page).to have_content(@user.name)
end
end
@@ -80,8 +82,8 @@ describe "Admin::Users", feature: true do
end
it "should have user edit page" do
- page.should have_content("Name")
- page.should have_content("Password")
+ expect(page).to have_content('Name')
+ expect(page).to have_content('Password')
end
describe "Update user" do
@@ -93,14 +95,14 @@ describe "Admin::Users", feature: true do
end
it "should show page with new data" do
- page.should have_content("bigbang@mail.com")
- page.should have_content("Big Bang")
+ expect(page).to have_content('bigbang@mail.com')
+ expect(page).to have_content('Big Bang')
end
it "should change user entry" do
@simple_user.reload
- @simple_user.name.should == "Big Bang"
- @simple_user.is_admin?.should be_true
+ expect(@simple_user.name).to eq('Big Bang')
+ expect(@simple_user.is_admin?).to be_truthy
end
end
end
diff --git a/spec/features/admin/security_spec.rb b/spec/features/admin/security_spec.rb
index 21b0d8b965e..2bcd3d8d010 100644
--- a/spec/features/admin/security_spec.rb
+++ b/spec/features/admin/security_spec.rb
@@ -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
diff --git a/spec/features/atom/dashboard_issues_spec.rb b/spec/features/atom/dashboard_issues_spec.rb
index 187f2ffcffd..b710cb3c72f 100644
--- a/spec/features/atom/dashboard_issues_spec.rb
+++ b/spec/features/atom/dashboard_issues_spec.rb
@@ -17,12 +17,13 @@ describe "Dashboard Issues Feed", feature: true do
it "should render atom feed via private token" do
visit issues_dashboard_path(:atom, private_token: user.private_token)
- response_headers['Content-Type'].should have_content("application/atom+xml")
- body.should have_selector("title", text: "#{user.name} issues")
- body.should have_selector("author email", text: issue1.author_email)
- body.should have_selector("entry summary", text: issue1.title)
- body.should have_selector("author email", text: issue2.author_email)
- body.should have_selector("entry summary", text: issue2.title)
+ expect(response_headers['Content-Type']).
+ to have_content('application/atom+xml')
+ expect(body).to have_selector('title', text: "#{user.name} issues")
+ expect(body).to have_selector('author email', text: issue1.author_email)
+ expect(body).to have_selector('entry summary', text: issue1.title)
+ expect(body).to have_selector('author email', text: issue2.author_email)
+ expect(body).to have_selector('entry summary', text: issue2.title)
end
end
end
diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb
index 52ade3e2d31..ad157d742ff 100644
--- a/spec/features/atom/dashboard_spec.rb
+++ b/spec/features/atom/dashboard_spec.rb
@@ -7,7 +7,7 @@ describe "Dashboard Feed", feature: true do
context "projects atom feed via private token" do
it "should render projects atom feed" do
visit dashboard_path(:atom, private_token: user.private_token)
- body.should have_selector("feed title")
+ expect(body).to have_selector('feed title')
end
end
@@ -24,11 +24,12 @@ describe "Dashboard Feed", feature: true do
end
it "should have issue opened event" do
- body.should have_content("#{user.name} opened issue ##{issue.iid}")
+ expect(body).to have_content("#{user.name} opened issue ##{issue.iid}")
end
it "should have issue comment event" do
- body.should have_content("#{user.name} commented on issue ##{issue.iid}")
+ expect(body).
+ to have_content("#{user.name} commented on issue ##{issue.iid}")
end
end
end
diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb
index 453dca69094..43163e4113e 100644
--- a/spec/features/atom/issues_spec.rb
+++ b/spec/features/atom/issues_spec.rb
@@ -1,33 +1,36 @@
require 'spec_helper'
-describe "Issues Feed", feature: true do
- describe "GET /issues" do
+describe 'Issues Feed', feature: true do
+ describe 'GET /issues' do
let!(:user) { create(:user) }
let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, project: project) }
before { project.team << [user, :developer] }
- context "when authenticated" do
- it "should render atom feed" do
+ context 'when authenticated' do
+ it 'should render atom feed' do
login_with user
visit project_issues_path(project, :atom)
- response_headers['Content-Type'].should have_content("application/atom+xml")
- body.should have_selector("title", text: "#{project.name} issues")
- body.should have_selector("author email", text: issue.author_email)
- body.should have_selector("entry summary", text: issue.title)
+ expect(response_headers['Content-Type']).
+ to have_content('application/atom+xml')
+ expect(body).to have_selector('title', text: "#{project.name} issues")
+ expect(body).to have_selector('author email', text: issue.author_email)
+ expect(body).to have_selector('entry summary', text: issue.title)
end
end
- context "when authenticated via private token" do
- it "should render atom feed" do
- visit project_issues_path(project, :atom, private_token: user.private_token)
+ context 'when authenticated via private token' do
+ it 'should render atom feed' do
+ visit project_issues_path(project, :atom,
+ private_token: user.private_token)
- response_headers['Content-Type'].should have_content("application/atom+xml")
- body.should have_selector("title", text: "#{project.name} issues")
- body.should have_selector("author email", text: issue.author_email)
- body.should have_selector("entry summary", text: issue.title)
+ expect(response_headers['Content-Type']).
+ to have_content('application/atom+xml')
+ expect(body).to have_selector('title', text: "#{project.name} issues")
+ expect(body).to have_selector('author email', text: issue.author_email)
+ expect(body).to have_selector('entry summary', text: issue.title)
end
end
end
diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb
index de4f94fff2f..c0316b073ad 100644
--- a/spec/features/atom/users_spec.rb
+++ b/spec/features/atom/users_spec.rb
@@ -4,17 +4,23 @@ describe "User Feed", feature: true do
describe "GET /" do
let!(:user) { create(:user) }
- context "user atom feed via private token" do
+ context 'user atom feed via private token' do
it "should render user atom feed" do
visit user_path(user, :atom, private_token: user.private_token)
- body.should have_selector("feed title")
+ expect(body).to have_selector('feed title')
end
end
context 'feed content' do
let(:project) { create(:project) }
- let(:issue) { create(:issue, project: project, author: user, description: '') }
- let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) }
+ let(:issue) do
+ create(:issue, project: project,
+ author: user, description: '')
+ end
+ let(:note) do
+ create(:note, noteable: issue, author: user,
+ note: 'Bug confirmed', project: project)
+ end
before do
project.team << [user, :master]
@@ -23,11 +29,11 @@ describe "User Feed", feature: true do
visit user_path(user, :atom, private_token: user.private_token)
end
- it "should have issue opened event" do
+ it 'should have issue opened event' do
expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}")
end
- it "should have issue comment event" do
+ it 'should have issue comment event' do
expect(body).
to have_content("#{safe_name} commented on issue ##{issue.iid}")
end
diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb
index 9f50d1c9738..73a9f78708a 100644
--- a/spec/features/gitlab_flavored_markdown_spec.rb
+++ b/spec/features/gitlab_flavored_markdown_spec.rb
@@ -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
diff --git a/spec/features/help_pages_spec.rb b/spec/features/help_pages_spec.rb
index 89129cfc7cd..41088ce8271 100644
--- a/spec/features/help_pages_spec.rb
+++ b/spec/features/help_pages_spec.rb
@@ -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
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index 29aeb6a400a..f54155439cb 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Issues", feature: true do
+describe 'Issues', feature: true do
include SortingHelper
let(:project) { create(:project) }
@@ -12,7 +12,7 @@ describe "Issues", feature: true do
project.team << [[@user, user2], :developer]
end
- describe "Edit issue" do
+ describe 'Edit issue' do
let!(:issue) do
create(:issue,
author: @user,
@@ -25,30 +25,34 @@ describe "Issues", feature: true do
click_link "Edit"
end
- it "should open new issue popup" do
- page.should have_content("Issue ##{issue.iid}")
+ it 'should open new issue popup' do
+ expect(page).to have_content("Issue ##{issue.iid}")
end
- describe "fill in" do
+ describe 'fill in' do
before do
- fill_in "issue_title", with: "bug 345"
- fill_in "issue_description", with: "bug description"
+ fill_in 'issue_title', with: 'bug 345'
+ fill_in 'issue_description', with: 'bug description'
end
- it { expect { click_button "Save changes" }.to_not change {Issue.count} }
+ it 'does not change issue count' do
+ expect {
+ click_button 'Save changes'
+ }.to_not change { Issue.count }
+ end
- it "should update issue fields" do
- click_button "Save changes"
+ 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
end
- describe "Editing issue assignee" do
+ describe 'Editing issue assignee' do
let!(:issue) do
create(:issue,
author: @user,
@@ -56,23 +60,23 @@ describe "Issues", feature: true do
project: project)
end
- it 'allows user to select unasigned', :js => 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
first('.user-result').click
- click_button "Save changes"
+ 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
- describe "Filter issue" do
+ describe 'Filter issue' do
before do
['foobar', 'barbaz', 'gitlab'].each do |title|
create(:issue,
@@ -90,43 +94,47 @@ describe "Issues", feature: true do
let(:issue) { @issue }
- it "should allow filtering by issues with no specified milestone" 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
+ 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
+ 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
+ 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
describe 'filter issue' do
titles = ['foo','bar','baz']
titles.each_with_index do |title, index|
- let!(title.to_sym) { create(:issue, title: title, project: project, created_at: Time.now - (index * 60)) }
+ let!(title.to_sym) do
+ create(:issue, title: title,
+ project: project,
+ created_at: Time.now - (index * 60))
+ end
end
let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
@@ -134,15 +142,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 +158,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 +166,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 +180,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
@@ -193,11 +201,13 @@ describe "Issues", feature: true do
end
it 'sorts with a filter applied' do
- visit project_issues_path(project, sort: sort_value_oldest_created, assignee_id: user2.id)
+ 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
@@ -210,11 +220,13 @@ describe "Issues", feature: true do
it 'with dropdown menu' do
visit project_issue_path(project, issue)
- find('.edit-issue.inline-update #issue_assignee_id').set project.team.members.first.id
+ find('.edit-issue.inline-update #issue_assignee_id').
+ set project.team.members.first.id
click_button 'Update Issue'
- page.should have_content "Assignee:"
- has_select?('issue_assignee_id', :selected => project.team.members.first.name)
+ expect(page).to have_content 'Assignee:'
+ has_select?('issue_assignee_id',
+ selected: project.team.members.first.name)
end
end
@@ -228,12 +240,12 @@ describe "Issues", feature: true do
issue.save
end
- it "shows assignee text", js: true do
+ it 'shows assignee text', js: true do
logout
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
@@ -247,12 +259,13 @@ describe "Issues", feature: true do
it 'with dropdown menu' do
visit project_issue_path(project, issue)
- find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id')
+ 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}"
- has_select?('issue_assignee_id', :selected => 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
@@ -265,12 +278,12 @@ describe "Issues", feature: true do
issue.save
end
- it "shows milestone text", js: true do
+ it 'shows milestone text', js: true do
logout
login_with guest
visit project_issue_path(project, issue)
- page.should have_content milestone.title
+ expect(page).to have_content milestone.title
end
end
@@ -282,26 +295,26 @@ describe "Issues", feature: true do
issue.save
end
- it 'allows user to remove assignee', :js => 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
def first_issue
- all("ul.issues-list li").first.text
+ all('ul.issues-list li').first.text
end
def last_issue
- all("ul.issues-list li").last.text
+ all('ul.issues-list li').last.text
end
end
diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb
index f66f5e7cb19..7790d0ecd73 100644
--- a/spec/features/notes_on_merge_requests_spec.rb
+++ b/spec/features/notes_on_merge_requests_spec.rb
@@ -3,10 +3,12 @@ require 'spec_helper'
describe 'Comments' do
include RepoHelpers
- describe "On a merge request", js: true, feature: true do
+ describe 'On a merge request', js: true, feature: true do
let!(:merge_request) { create(:merge_request) }
let!(:project) { merge_request.source_project }
- let!(:note) { create(:note_on_merge_request, :with_attachment, project: project) }
+ let!(:note) do
+ create(:note_on_merge_request, :with_attachment, project: project)
+ end
before do
login_as :admin
@@ -15,19 +17,20 @@ describe 'Comments' do
subject { page }
- describe "the note form" do
+ describe 'the note form' do
it 'should be valid' do
- should have_css(".js-main-target-form", visible: true, count: 1)
- find(".js-main-target-form input[type=submit]").value.should == "Add Comment"
+ is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
+ expect(find('.js-main-target-form input[type=submit]').value).
+ to eq('Add Comment')
within('.js-main-target-form') do
expect(page).not_to have_link('Cancel')
end
end
- describe "with text" do
+ describe 'with text' do
before do
- within(".js-main-target-form") do
- fill_in "note[note]", with: "This is awesome"
+ within('.js-main-target-form') do
+ fill_in 'note[note]', with: 'This is awesome'
end
end
@@ -40,41 +43,45 @@ describe 'Comments' do
end
end
- describe "when posting a note" do
+ describe 'when posting a note' do
before do
- within(".js-main-target-form") do
- fill_in "note[note]", with: "This is awsome!"
+ within('.js-main-target-form') do
+ fill_in 'note[note]', with: 'This is awsome!'
find('.js-md-preview-button').click
- click_button "Add Comment"
+ click_button 'Add Comment'
end
end
it 'should be added and form reset' do
- should have_content("This is awsome!")
+ is_expected.to have_content('This is awsome!')
within('.js-main-target-form') do
expect(page).to have_no_field('note[note]', with: 'This is awesome!')
expect(page).to have_css('.js-md-preview', visible: :hidden)
end
- within(".js-main-target-form") { should have_css(".js-note-text", visible: true) }
+ within('.js-main-target-form') do
+ is_expected.to have_css('.js-note-text', visible: true)
+ end
end
end
- describe "when editing a note", js: true do
- it "should contain the hidden edit form" do
- within("#note_#{note.id}") { should have_css(".note-edit-form", visible: false) }
+ describe 'when editing a note', js: true do
+ it 'should contain the hidden edit form' do
+ within("#note_#{note.id}") do
+ is_expected.to have_css('.note-edit-form', visible: false)
+ end
end
- describe "editing the note" do
+ describe 'editing the note' do
before do
find('.note').hover
find(".js-note-edit").click
end
- it "should show the note edit form and hide the note body" do
+ it 'should show the note edit form and hide the note body' do
within("#note_#{note.id}") do
- find(".current-note-edit-form", visible: true).should be_visible
- find(".note-edit-form", visible: true).should be_visible
- find(:css, ".note-text", visible: false).should_not be_visible
+ expect(find('.current-note-edit-form', visible: true)).to be_visible
+ expect(find('.note-edit-form', visible: true)).to be_visible
+ expect(find(:css, '.note-text', visible: false)).not_to be_visible
end
end
@@ -87,41 +94,43 @@ describe 'Comments' do
#end
#end
- it "appends the edited at time to the note" do
- within(".current-note-edit-form") do
- fill_in "note[note]", with: "Some new content"
- find(".btn-save").click
+ it 'appends the edited at time to the note' do
+ within('.current-note-edit-form') do
+ fill_in 'note[note]', with: 'Some new content'
+ find('.btn-save').click
end
within("#note_#{note.id}") do
- should have_css(".note_edited_ago")
- find(".note_edited_ago").text.should match(/less than a minute ago/)
+ is_expected.to have_css('.note_edited_ago')
+ expect(find('.note_edited_ago').text).
+ to match(/less than a minute ago/)
end
end
end
- describe "deleting an attachment" do
+ describe 'deleting an attachment' do
before do
find('.note').hover
- find(".js-note-edit").click
+ find('.js-note-edit').click
end
- it "shows the delete link" do
- within(".note-attachment") do
- should have_css(".js-note-attachment-delete")
+ it 'shows the delete link' do
+ within('.note-attachment') do
+ is_expected.to have_css('.js-note-attachment-delete')
end
end
- it "removes the attachment div and resets the edit form" do
- find(".js-note-attachment-delete").click
- should_not have_css(".note-attachment")
- find(".current-note-edit-form", visible: false).should_not be_visible
+ it 'removes the attachment div and resets the edit form' do
+ find('.js-note-attachment-delete').click
+ is_expected.not_to have_css('.note-attachment')
+ expect(find('.current-note-edit-form', visible: false)).
+ not_to be_visible
end
end
end
end
- describe "On a merge request diff", js: true, feature: true do
+ describe 'On a merge request diff', js: true, feature: true do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
@@ -132,69 +141,75 @@ describe 'Comments' do
subject { page }
- describe "when adding a note" do
+ describe 'when adding a note' do
before do
click_diff_line
end
- describe "the notes holder" do
- it { should have_css(".js-temp-notes-holder") }
+ describe 'the notes holder' do
+ it { is_expected.to have_css('.js-temp-notes-holder') }
- it { within(".js-temp-notes-holder") { should have_css(".new_note") } }
+ it 'has .new_note css class' do
+ within('.js-temp-notes-holder') do
+ expect(subject).to have_css('.new_note')
+ end
+ end
end
- describe "the note form" do
+ describe 'the note form' do
it "shouldn't add a second form for same row" do
click_diff_line
- should have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form", count: 1)
+ is_expected.
+ to have_css("tr[id='#{line_code}'] + .js-temp-notes-holder form",
+ count: 1)
end
- it "should be removed when canceled" do
+ it 'should be removed when canceled' do
within(".diff-file form[rel$='#{line_code}']") do
- find(".js-close-discussion-note-form").trigger("click")
+ find('.js-close-discussion-note-form').trigger('click')
end
- should have_no_css(".js-temp-notes-holder")
+ is_expected.to have_no_css('.js-temp-notes-holder')
end
end
end
- describe "with muliple note forms" do
+ describe 'with muliple note forms' do
before do
click_diff_line
click_diff_line(line_code_2)
end
- it { should have_css(".js-temp-notes-holder", count: 2) }
+ it { is_expected.to have_css('.js-temp-notes-holder', count: 2) }
- describe "previewing them separately" do
+ describe 'previewing them separately' do
before do
# add two separate texts and trigger previews on both
within("tr[id='#{line_code}'] + .js-temp-notes-holder") do
- fill_in "note[note]", with: "One comment on line 7"
+ fill_in 'note[note]', with: 'One comment on line 7'
find('.js-md-preview-button').click
end
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
- fill_in "note[note]", with: "Another comment on line 10"
+ fill_in 'note[note]', with: 'Another comment on line 10'
find('.js-md-preview-button').click
end
end
end
- describe "posting a note" do
+ describe 'posting a note' do
before do
within("tr[id='#{line_code_2}'] + .js-temp-notes-holder") do
- fill_in "note[note]", with: "Another comment on line 10"
- click_button("Add Comment")
+ fill_in 'note[note]', with: 'Another comment on line 10'
+ click_button('Add Comment')
end
end
it 'should be added as discussion' do
- should have_content("Another comment on line 10")
- should have_css(".notes_holder")
- should have_css(".notes_holder .note", count: 1)
- should have_button('Reply')
+ is_expected.to have_content('Another comment on line 10')
+ is_expected.to have_css('.notes_holder')
+ is_expected.to have_css('.notes_holder .note', count: 1)
+ is_expected.to have_button('Reply')
end
end
end
diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb
index 4a76e89fd34..3d36a3c02d0 100644
--- a/spec/features/profile_spec.rb
+++ b/spec/features/profile_spec.rb
@@ -1,35 +1,35 @@
require 'spec_helper'
-describe "Profile account page", feature: true do
+describe 'Profile account page', feature: true do
let(:user) { create(:user) }
before do
login_as :user
end
- describe "when signup is enabled" do
+ describe 'when signup is enabled' do
before do
ApplicationSetting.any_instance.stub(signup_enabled?: true)
visit profile_account_path
end
- it { page.should have_content("Remove account") }
+ it { expect(page).to have_content('Remove account') }
- it "should delete the account" do
- expect { click_link "Delete account" }.to change {User.count}.by(-1)
- current_path.should == new_user_session_path
+ it 'should delete the account' do
+ expect { click_link 'Delete account' }.to change { User.count }.by(-1)
+ expect(current_path).to eq(new_user_session_path)
end
end
- describe "when signup is disabled" do
+ describe 'when signup is disabled' do
before do
ApplicationSetting.any_instance.stub(signup_enabled?: false)
visit profile_account_path
end
- it "should not have option to remove account" do
- page.should_not have_content("Remove account")
- current_path.should == profile_account_path
+ it 'should not have option to remove account' do
+ expect(page).not_to have_content('Remove account')
+ expect(current_path).to eq(profile_account_path)
end
end
end
diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb
index cce9f06cb69..73987739a7a 100644
--- a/spec/features/search_spec.rb
+++ b/spec/features/search_spec.rb
@@ -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
diff --git a/spec/features/security/dashboard_access_spec.rb b/spec/features/security/dashboard_access_spec.rb
index 1cca82cef64..d1f00a3dd82 100644
--- a/spec/features/security/dashboard_access_spec.rb
+++ b/spec/features/security/dashboard_access_spec.rb
@@ -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
diff --git a/spec/features/security/group/group_access_spec.rb b/spec/features/security/group/group_access_spec.rb
index 44de499e6d2..e0c5cbf4d3d 100644
--- a/spec/features/security/group/group_access_spec.rb
+++ b/spec/features/security/group/group_access_spec.rb
@@ -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
diff --git a/spec/features/security/group/internal_group_access_spec.rb b/spec/features/security/group/internal_group_access_spec.rb
index da5c6eb4e91..5279a1bc13a 100644
--- a/spec/features/security/group/internal_group_access_spec.rb
+++ b/spec/features/security/group/internal_group_access_spec.rb
@@ -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
diff --git a/spec/features/security/group/mixed_group_access_spec.rb b/spec/features/security/group/mixed_group_access_spec.rb
index c9889d99590..efd14858b98 100644
--- a/spec/features/security/group/mixed_group_access_spec.rb
+++ b/spec/features/security/group/mixed_group_access_spec.rb
@@ -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
diff --git a/spec/features/security/group/public_group_access_spec.rb b/spec/features/security/group/public_group_access_spec.rb
index 2e76ab154ff..c7e3d0a8a40 100644
--- a/spec/features/security/group/public_group_access_spec.rb
+++ b/spec/features/security/group/public_group_access_spec.rb
@@ -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
diff --git a/spec/features/security/profile_access_spec.rb b/spec/features/security/profile_access_spec.rb
index 4efc0ffdcd3..5f254c42e58 100644
--- a/spec/features/security/profile_access_spec.rb
+++ b/spec/features/security/profile_access_spec.rb
@@ -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
diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb
index 598d554a946..81f94e33569 100644
--- a/spec/features/security/project/internal_access_spec.rb
+++ b/spec/features/security/project/internal_access_spec.rb
@@ -18,73 +18,76 @@ describe "Internal Project Access", feature: true do
describe "Project should be internal" do
subject { project }
- its(:internal?) { should be_true }
+ describe '#internal?' do
+ subject { super().internal? }
+ it { is_expected.to be_truthy }
+ end
end
describe "GET /:project_path" do
subject { project_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/tree/master" do
subject { project_tree_path(project, project.repository.root_ref) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/commits/master" do
subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/commit/:sha" do
subject { project_commit_path(project, project.repository.commit) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/compare" do
subject { project_compare_index_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/team" do
subject { project_team_index_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/blob" do
@@ -94,89 +97,89 @@ describe "Internal Project Access", feature: true do
@blob_path = project_blob_path(project, File.join(commit.id, path))
end
- it { @blob_path.should be_allowed_for master }
- it { @blob_path.should be_allowed_for reporter }
- it { @blob_path.should be_allowed_for :admin }
- it { @blob_path.should be_allowed_for guest }
- it { @blob_path.should be_allowed_for :user }
- it { @blob_path.should be_denied_for :visitor }
+ it { expect(@blob_path).to be_allowed_for master }
+ it { expect(@blob_path).to be_allowed_for reporter }
+ it { expect(@blob_path).to be_allowed_for :admin }
+ it { expect(@blob_path).to be_allowed_for guest }
+ it { expect(@blob_path).to be_allowed_for :user }
+ it { expect(@blob_path).to be_denied_for :visitor }
end
describe "GET /:project_path/edit" do
subject { edit_project_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/deploy_keys" do
subject { project_deploy_keys_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/issues" do
subject { project_issues_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/snippets" do
subject { project_snippets_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/merge_requests" do
subject { project_merge_requests_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/merge_requests/new" do
subject { new_project_merge_request_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/branches" do
@@ -184,15 +187,15 @@ describe "Internal Project Access", feature: true do
before do
# Speed increase
- Project.any_instance.stub(:branches).and_return([])
+ allow_any_instance_of(Project).to receive(:branches).and_return([])
end
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/tags" do
@@ -200,25 +203,25 @@ describe "Internal Project Access", feature: true do
before do
# Speed increase
- Project.any_instance.stub(:tags).and_return([])
+ allow_any_instance_of(Project).to receive(:tags).and_return([])
end
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/hooks" do
subject { project_hooks_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
end
diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb
index b1d4c79e05b..fd21e722611 100644
--- a/spec/features/security/project/private_access_spec.rb
+++ b/spec/features/security/project/private_access_spec.rb
@@ -18,73 +18,76 @@ describe "Private Project Access", feature: true do
describe "Project should be private" do
subject { project }
- its(:private?) { should be_true }
+ describe '#private?' do
+ subject { super().private? }
+ it { is_expected.to be_truthy }
+ end
end
describe "GET /:project_path" do
subject { project_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/tree/master" do
subject { project_tree_path(project, project.repository.root_ref) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/commits/master" do
subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/commit/:sha" do
subject { project_commit_path(project, project.repository.commit) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/compare" do
subject { project_compare_index_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/team" do
subject { project_team_index_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/blob" do
@@ -94,67 +97,67 @@ describe "Private Project Access", feature: true do
@blob_path = project_blob_path(project, File.join(commit.id, path))
end
- it { @blob_path.should be_allowed_for master }
- it { @blob_path.should be_allowed_for reporter }
- it { @blob_path.should be_allowed_for :admin }
- it { @blob_path.should be_denied_for guest }
- it { @blob_path.should be_denied_for :user }
- it { @blob_path.should be_denied_for :visitor }
+ it { expect(@blob_path).to be_allowed_for master }
+ it { expect(@blob_path).to be_allowed_for reporter }
+ it { expect(@blob_path).to be_allowed_for :admin }
+ it { expect(@blob_path).to be_denied_for guest }
+ it { expect(@blob_path).to be_denied_for :user }
+ it { expect(@blob_path).to be_denied_for :visitor }
end
describe "GET /:project_path/edit" do
subject { edit_project_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/deploy_keys" do
subject { project_deploy_keys_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/issues" do
subject { project_issues_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/snippets" do
subject { project_snippets_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/merge_requests" do
subject { project_merge_requests_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/branches" do
@@ -162,15 +165,15 @@ describe "Private Project Access", feature: true do
before do
# Speed increase
- Project.any_instance.stub(:branches).and_return([])
+ allow_any_instance_of(Project).to receive(:branches).and_return([])
end
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/tags" do
@@ -178,25 +181,25 @@ describe "Private Project Access", feature: true do
before do
# Speed increase
- Project.any_instance.stub(:tags).and_return([])
+ allow_any_instance_of(Project).to receive(:tags).and_return([])
end
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/hooks" do
subject { project_hooks_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
end
diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb
index a4c8a2be25a..ddc1c3be7df 100644
--- a/spec/features/security/project/public_access_spec.rb
+++ b/spec/features/security/project/public_access_spec.rb
@@ -23,73 +23,76 @@ describe "Public Project Access", feature: true do
describe "Project should be public" do
subject { project }
- its(:public?) { should be_true }
+ describe '#public?' do
+ subject { super().public? }
+ it { is_expected.to be_truthy }
+ end
end
describe "GET /:project_path" do
subject { project_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/tree/master" do
subject { project_tree_path(project, project.repository.root_ref) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/commits/master" do
subject { project_commits_path(project, project.repository.root_ref, limit: 1) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/commit/:sha" do
subject { project_commit_path(project, project.repository.commit) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/compare" do
subject { project_compare_index_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/team" do
subject { project_team_index_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/blob" do
@@ -99,89 +102,89 @@ describe "Public Project Access", feature: true do
@blob_path = project_blob_path(project, File.join(commit.id, path))
end
- it { @blob_path.should be_allowed_for master }
- it { @blob_path.should be_allowed_for reporter }
- it { @blob_path.should be_allowed_for :admin }
- it { @blob_path.should be_allowed_for guest }
- it { @blob_path.should be_allowed_for :user }
- it { @blob_path.should be_allowed_for :visitor }
+ it { expect(@blob_path).to be_allowed_for master }
+ it { expect(@blob_path).to be_allowed_for reporter }
+ it { expect(@blob_path).to be_allowed_for :admin }
+ it { expect(@blob_path).to be_allowed_for guest }
+ it { expect(@blob_path).to be_allowed_for :user }
+ it { expect(@blob_path).to be_allowed_for :visitor }
end
describe "GET /:project_path/edit" do
subject { edit_project_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/deploy_keys" do
subject { project_deploy_keys_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/issues" do
subject { project_issues_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/snippets" do
subject { project_snippets_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/snippets/new" do
subject { new_project_snippet_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/merge_requests" do
subject { project_merge_requests_path(project) }
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/merge_requests/new" do
subject { new_project_merge_request_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
describe "GET /:project_path/branches" do
@@ -189,15 +192,15 @@ describe "Public Project Access", feature: true do
before do
# Speed increase
- Project.any_instance.stub(:branches).and_return([])
+ allow_any_instance_of(Project).to receive(:branches).and_return([])
end
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/tags" do
@@ -205,25 +208,25 @@ describe "Public Project Access", feature: true do
before do
# Speed increase
- Project.any_instance.stub(:tags).and_return([])
+ allow_any_instance_of(Project).to receive(:tags).and_return([])
end
- it { should be_allowed_for master }
- it { should be_allowed_for reporter }
- it { should be_allowed_for :admin }
- it { should be_allowed_for guest }
- it { should be_allowed_for :user }
- it { should be_allowed_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_allowed_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_allowed_for guest }
+ it { is_expected.to be_allowed_for :user }
+ it { is_expected.to be_allowed_for :visitor }
end
describe "GET /:project_path/hooks" do
subject { project_hooks_path(project) }
- it { should be_allowed_for master }
- it { should be_denied_for reporter }
- it { should be_allowed_for :admin }
- it { should be_denied_for guest }
- it { should be_denied_for :user }
- it { should be_denied_for :visitor }
+ it { is_expected.to be_allowed_for master }
+ it { is_expected.to be_denied_for reporter }
+ it { is_expected.to be_allowed_for :admin }
+ it { is_expected.to be_denied_for guest }
+ it { is_expected.to be_denied_for :user }
+ it { is_expected.to be_denied_for :visitor }
end
end
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index 06e247aea61..479fa950387 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -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
diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb
index 94b4d4c4ff4..8536377a7f0 100644
--- a/spec/finders/merge_requests_finder_spec.rb
+++ b/spec/finders/merge_requests_finder_spec.rb
@@ -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
diff --git a/spec/finders/notes_finder_spec.rb b/spec/finders/notes_finder_spec.rb
index 4f8a5f909df..c83824b900d 100644
--- a/spec/finders/notes_finder_spec.rb
+++ b/spec/finders/notes_finder_spec.rb
@@ -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
diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb
index 6e3ae4d615b..2ab71b05968 100644
--- a/spec/finders/projects_finder_spec.rb
+++ b/spec/finders/projects_finder_spec.rb
@@ -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
diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb
index c645cbc964c..1b4ffc2d717 100644
--- a/spec/finders/snippets_finder_spec.rb
+++ b/spec/finders/snippets_finder_spec.rb
@@ -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
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index a46883b3c99..61d6c906ad0 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -3,20 +3,20 @@ require 'spec_helper'
describe ApplicationHelper do
describe 'current_controller?' do
before do
- controller.stub(:controller_name).and_return('foo')
+ allow(controller).to receive(:controller_name).and_return('foo')
end
it 'returns true when controller matches argument' do
- current_controller?(:foo).should be_true
+ expect(current_controller?(:foo)).to be_truthy
end
it 'returns false when controller does not match argument' do
- current_controller?(:bar).should_not be_true
+ expect(current_controller?(:bar)).not_to be_truthy
end
it 'should take any number of arguments' do
- current_controller?(:baz, :bar).should_not be_true
- current_controller?(:baz, :bar, :foo).should be_true
+ expect(current_controller?(:baz, :bar)).not_to be_truthy
+ expect(current_controller?(:baz, :bar, :foo)).to be_truthy
end
end
@@ -26,16 +26,16 @@ describe ApplicationHelper do
end
it 'returns true when action matches argument' do
- current_action?(:foo).should be_true
+ expect(current_action?(:foo)).to be_truthy
end
it 'returns false when action does not match argument' do
- current_action?(:bar).should_not be_true
+ expect(current_action?(:bar)).not_to be_truthy
end
it 'should take any number of arguments' do
- current_action?(:baz, :bar).should_not be_true
- current_action?(:baz, :bar, :foo).should be_true
+ expect(current_action?(:baz, :bar)).not_to be_truthy
+ expect(current_action?(:baz, :bar, :foo)).to be_truthy
end
end
@@ -46,13 +46,14 @@ describe ApplicationHelper do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
- group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
+ expect(group_icon(group.path).to_s).
+ to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end
it 'should give default avatar_icon when no avatar is present' do
group = create(:group)
group.save!
- group_icon(group.path).should match('group_avatar.png')
+ expect(group_icon(group.path)).to match('group_avatar.png')
end
end
@@ -63,17 +64,18 @@ describe ApplicationHelper do
project = create(:project)
project.avatar = File.open(avatar_file_path)
project.save!
- project_icon(project.to_param).to_s.should ==
+ expect(project_icon(project.to_param).to_s).to eq(
"<img alt=\"Gitlab logo\" src=\"/uploads/project/avatar/#{ project.id }/gitlab_logo.png\" />"
+ )
end
it 'should give uploaded icon when present' do
project = create(:project)
project.save!
- Project.any_instance.stub(:avatar_in_git).and_return(true)
+ allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true)
- project_icon(project.to_param).to_s.should match(
+ expect(project_icon(project.to_param).to_s).to match(
image_tag(project_avatar_path(project)))
end
end
@@ -85,7 +87,8 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
+ expect(avatar_icon(user.email).to_s).
+ to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should return an url for the avatar with relative url' do
@@ -95,13 +98,14 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- avatar_icon(user.email).to_s.should match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
+ expect(avatar_icon(user.email).to_s).
+ to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should call gravatar_icon when no avatar is present' do
user = create(:user, email: 'test@example.com')
user.save!
- avatar_icon(user.email).to_s.should == 'http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon'
+ expect(avatar_icon(user.email).to_s).to eq('http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon')
end
end
@@ -110,42 +114,47 @@ describe ApplicationHelper do
it 'should return a generic avatar path when Gravatar is disabled' do
ApplicationSetting.any_instance.stub(gravatar_enabled?: false)
- gravatar_icon(user_email).should match('no_avatar.png')
+ expect(gravatar_icon(user_email)).to match('no_avatar.png')
end
it 'should return a generic avatar path when email is blank' do
- gravatar_icon('').should match('no_avatar.png')
+ expect(gravatar_icon('')).to match('no_avatar.png')
end
it 'should return default gravatar url' do
Gitlab.config.gitlab.stub(https: false)
- gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
+ url = 'http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118'
+ expect(gravatar_icon(user_email)).to match(url)
end
it 'should use SSL when appropriate' do
Gitlab.config.gitlab.stub(https: true)
- gravatar_icon(user_email).should match('https://secure.gravatar.com')
+ expect(gravatar_icon(user_email)).to match('https://secure.gravatar.com')
end
it 'should return custom gravatar path when gravatar_url is set' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
- gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
+ allow(Gitlab.config.gravatar).
+ to receive(:plain_url).
+ and_return('http://example.local/?s=%{size}&hash=%{hash}')
+ url = 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
+ expect(gravatar_icon(user_email, 20)).to eq(url)
end
it 'should accept a custom size' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- gravatar_icon(user_email, 64).should match(/\?s=64/)
+ expect(gravatar_icon(user_email, 64)).to match(/\?s=64/)
end
it 'should use default size when size is wrong' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- gravatar_icon(user_email, nil).should match(/\?s=40/)
+ expect(gravatar_icon(user_email, nil)).to match(/\?s=40/)
end
it 'should be case insensitive' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + ' ')
+ expect(gravatar_icon(user_email)).
+ to eq(gravatar_icon(user_email.upcase + ' '))
end
end
@@ -163,28 +172,30 @@ describe ApplicationHelper do
end
it 'includes a list of branch names' do
- options[0][0].should == 'Branches'
- options[0][1].should include('master', 'feature')
+ expect(options[0][0]).to eq('Branches')
+ expect(options[0][1]).to include('master', 'feature')
end
it 'includes a list of tag names' do
- options[1][0].should == 'Tags'
- options[1][1].should include('v1.0.0','v1.1.0')
+ expect(options[1][0]).to eq('Tags')
+ expect(options[1][1]).to include('v1.0.0', 'v1.1.0')
end
it 'includes a specific commit ref if defined' do
# Must be an instance variable
@ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
- options[2][0].should == 'Commit'
- options[2][1].should == [@ref]
+ expect(options[2][0]).to eq('Commit')
+ expect(options[2][1]).to eq([@ref])
end
it 'sorts tags in a natural order' do
# Stub repository.tag_names to make sure we get some valid testing data
- expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
+ expect(@project.repository).to receive(:tag_names).
+ and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
- options[1][1].should == ['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9']
+ expect(options[1][1]).
+ to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
end
end
@@ -192,7 +203,7 @@ describe ApplicationHelper do
context 'with current_user is nil' do
it 'should return a string' do
allow(self).to receive(:current_user).and_return(nil)
- user_color_scheme_class.should be_kind_of(String)
+ expect(user_color_scheme_class).to be_kind_of(String)
end
end
@@ -202,7 +213,7 @@ describe ApplicationHelper do
it 'should return a string' do
current_user = double(:color_scheme_id => color_scheme_id)
allow(self).to receive(:current_user).and_return(current_user)
- user_color_scheme_class.should be_kind_of(String)
+ expect(user_color_scheme_class).to be_kind_of(String)
end
end
end
@@ -213,17 +224,17 @@ describe ApplicationHelper do
let(:a_tag) { '<a href="#">Foo</a>' }
it 'allows the a tag' do
- simple_sanitize(a_tag).should == a_tag
+ expect(simple_sanitize(a_tag)).to eq(a_tag)
end
it 'allows the span tag' do
input = '<span class="foo">Bar</span>'
- simple_sanitize(input).should == input
+ expect(simple_sanitize(input)).to eq(input)
end
it 'disallows other tags' do
input = "<strike><b>#{a_tag}</b></strike>"
- simple_sanitize(input).should == a_tag
+ expect(simple_sanitize(input)).to eq(a_tag)
end
end
@@ -254,7 +265,7 @@ describe ApplicationHelper do
let(:content) { 'Noël' }
it 'should preserve encoding' do
- content.encoding.name.should == 'UTF-8'
+ expect(content.encoding.name).to eq('UTF-8')
expect(render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
end
end
diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb
index 1338ce4873d..f6df12662bb 100644
--- a/spec/helpers/broadcast_messages_helper_spec.rb
+++ b/spec/helpers/broadcast_messages_helper_spec.rb
@@ -6,7 +6,7 @@ describe BroadcastMessagesHelper do
context "default style" do
it "should have no style" do
- broadcast_styling(broadcast_message).should match('')
+ expect(broadcast_styling(broadcast_message)).to match('')
end
end
@@ -14,7 +14,8 @@ describe BroadcastMessagesHelper do
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
it "should have a customized style" do
- broadcast_styling(broadcast_message).should match('background-color:#f2dede;color:#b94a48')
+ expect(broadcast_styling(broadcast_message)).
+ to match('background-color:#f2dede;color:#b94a48')
end
end
end
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index b07742a6ee2..5bd09793b11 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -10,58 +10,61 @@ describe DiffHelper do
describe 'diff_hard_limit_enabled?' do
it 'should return true if param is provided' do
- controller.stub(:params).and_return { { :force_show_diff => true } }
- diff_hard_limit_enabled?.should be_true
+ allow(controller).to receive(:params) { { force_show_diff: true } }
+ expect(diff_hard_limit_enabled?).to be_truthy
end
it 'should return false if param is not provided' do
- diff_hard_limit_enabled?.should be_false
+ expect(diff_hard_limit_enabled?).to be_falsey
end
end
describe 'allowed_diff_size' do
it 'should return hard limit for a diff if force diff is true' do
- controller.stub(:params).and_return { { :force_show_diff => true } }
- allowed_diff_size.should eq(1000)
+ allow(controller).to receive(:params) { { force_show_diff: true } }
+ expect(allowed_diff_size).to eq(1000)
end
it 'should return safe limit for a diff if force diff is false' do
- allowed_diff_size.should eq(100)
+ expect(allowed_diff_size).to eq(100)
end
end
describe 'parallel_diff' do
it 'should return an array of arrays containing the parsed diff' do
- parallel_diff(diff_file, 0).should match_array(parallel_diff_result_array)
+ expect(parallel_diff(diff_file, 0)).
+ to match_array(parallel_diff_result_array)
end
end
describe 'generate_line_code' do
it 'should generate correct line code' do
- generate_line_code(diff_file.file_path, diff_file.diff_lines.first).should == '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6'
+ expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).
+ to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
end
end
describe 'unfold_bottom_class' do
it 'should return empty string when bottom line shouldnt be unfolded' do
- unfold_bottom_class(false).should == ''
+ expect(unfold_bottom_class(false)).to eq('')
end
it 'should return js class when bottom lines should be unfolded' do
- unfold_bottom_class(true).should == 'js-unfold-bottom'
+ expect(unfold_bottom_class(true)).to eq('js-unfold-bottom')
end
end
describe 'diff_line_content' do
it 'should return non breaking space when line is empty' do
- diff_line_content(nil).should eq(" &nbsp;")
+ expect(diff_line_content(nil)).to eq(' &nbsp;')
end
it 'should return the line itself' do
- diff_line_content(diff_file.diff_lines.first.text).should eq("@@ -6,12 +6,18 @@ module Popen")
- diff_line_content(diff_file.diff_lines.first.type).should eq("match")
- diff_line_content(diff_file.diff_lines.first.new_pos).should eq(6)
+ expect(diff_line_content(diff_file.diff_lines.first.text)).
+ to eq('@@ -6,12 +6,18 @@ module Popen')
+ expect(diff_line_content(diff_file.diff_lines.first.type)).to eq('match')
+ expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6)
end
end
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index d633287b2a9..317a559f83c 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -1,4 +1,4 @@
-require "spec_helper"
+require 'spec_helper'
describe GitlabMarkdownHelper do
include ApplicationHelper
@@ -30,26 +30,27 @@ describe GitlabMarkdownHelper do
it "should return unaltered text if project is nil" do
actual = "Testing references: ##{issue.iid}"
- gfm(actual).should_not == actual
+ expect(gfm(actual)).not_to eq(actual)
@project = nil
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it "should not alter non-references" do
actual = expected = "_Please_ *stop* 'helping' and all the other b*$#%' you do."
- gfm(actual).should == expected
+ expect(gfm(actual)).to eq(expected)
end
it "should not touch HTML entities" do
- @project.issues.stub(:where).with(id: '39').and_return([issue])
+ allow(@project.issues).to receive(:where).
+ with(id: '39').and_return([issue])
actual = 'We&#39;ll accept good pull requests.'
- gfm(actual).should == "We'll accept good pull requests."
+ expect(gfm(actual)).to eq("We'll accept good pull requests.")
end
it "should forward HTML options to links" do
- gfm("Fixed in #{commit.id}", @project, class: 'foo').
- should have_selector('a.gfm.foo')
+ expect(gfm("Fixed in #{commit.id}", @project, class: 'foo')).
+ to have_selector('a.gfm.foo')
end
describe "referencing a commit" do
@@ -57,38 +58,38 @@ describe GitlabMarkdownHelper do
it "should link using a full id" do
actual = "Reverts #{commit.id}"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link using a short id" do
actual = "Backported from #{commit.short_id}"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
actual = "Reverted (see #{commit.id})"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should keep whitespace intact" do
actual = "Changes #{commit.id} dramatically"
expected = /Changes <a.+>#{commit.id}<\/a> dramatically/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
actual = expected = "What happened in #{commit.id.reverse}"
- gfm(actual).should == expected
+ expect(gfm(actual)).to eq(expected)
end
it "should include a title attribute" do
actual = "Reverts #{commit.id}"
- gfm(actual).should match(/title="#{commit.link_title}"/)
+ expect(gfm(actual)).to match(/title="#{commit.link_title}"/)
end
it "should include standard gfm classes" do
actual = "Reverts #{commit.id}"
- gfm(actual).should match(/class="\s?gfm gfm-commit\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-commit\s?"/)
end
end
@@ -101,37 +102,37 @@ describe GitlabMarkdownHelper do
end
it "should link using a simple name" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link using a name with dots" do
user.update_attributes(name: "alphA.Beta")
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link using name with underscores" do
user.update_attributes(name: "ping_pong_king")
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
actual = "Mail the admin (@#{user.username})"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should keep whitespace intact" do
actual = "Yes, @#{user.username} is right."
expected = /Yes, <a.+>@#{user.username}<\/a> is right/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
actual = expected = "@#{user.username.reverse} you are right."
- gfm(actual).should == expected
+ expect(gfm(actual)).to eq(expected)
end
it "should include standard gfm classes" do
- gfm(actual).should match(/class="\s?gfm gfm-team_member\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-team_member\s?"/)
end
end
@@ -148,37 +149,38 @@ describe GitlabMarkdownHelper do
let(:expected) { polymorphic_path([project, object]) }
it "should link using a valid id" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
- gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+ expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).
+ to match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it "should include a title attribute" do
title = "#{object.class.to_s.titlecase}: #{object.title}"
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it "should include standard gfm classes" do
css = object.class.to_s.underscore
- gfm(actual).should match(/class="\s?gfm gfm-#{css}\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-#{css}\s?"/)
end
end
@@ -204,27 +206,26 @@ describe GitlabMarkdownHelper do
end
it 'should link using a valid id' do
- gfm(actual).should match(
+ expect(gfm(actual)).to match(
/#{expected}.*#{Regexp.escape(full_reference)}/
)
end
it 'should link with adjacent text' do
# Wrap the reference in parenthesis
- gfm(actual.gsub(full_reference, "(#{full_reference})")).should(
+ expect(gfm(actual.gsub(full_reference, "(#{full_reference})"))).to(
match(expected)
)
# Append some text to the end of the reference
- gfm(actual.gsub(full_reference, "#{full_reference}, right?")).should(
- match(expected)
- )
+ expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).
+ to(match(expected))
end
it 'should keep whitespace intact' do
actual = "Referenced #{full_reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it 'should not link with an invalid id' do
@@ -234,7 +235,7 @@ describe GitlabMarkdownHelper do
else
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
end
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it 'should include a title attribute' do
@@ -243,12 +244,12 @@ describe GitlabMarkdownHelper do
else
title = "#{object.class.to_s.titlecase}: #{object.title}"
end
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it 'should include standard gfm classes' do
css = object.class.to_s.underscore
- gfm(actual).should match(/class="\s?gfm gfm-#{css}\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-#{css}\s?"/)
end
end
@@ -307,36 +308,37 @@ describe GitlabMarkdownHelper do
end
it "should link using a valid id" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
- gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+ expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).
+ to match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
invalid_reference = actual.gsub(/(\d+)$/, "r45")
- gfm(invalid_reference).should == invalid_reference
+ expect(gfm(invalid_reference)).to eq(invalid_reference)
end
it "should include a title attribute" do
title = "Issue in JIRA tracker"
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it "should include standard gfm classes" do
- gfm(actual).should match(/class="\s?gfm gfm-issue\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-issue\s?"/)
end
end
@@ -354,37 +356,37 @@ describe GitlabMarkdownHelper do
let(:expected) { project_snippet_path(project, object) }
it "should link using a valid id" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
- gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+ expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it "should include a title attribute" do
title = "Snippet: #{object.title}"
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it "should include standard gfm classes" do
css = object.class.to_s.underscore
- gfm(actual).should match(/class="\s?gfm gfm-snippet\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-snippet\s?"/)
end
end
@@ -394,63 +396,63 @@ describe GitlabMarkdownHelper do
it "should link to the merge request" do
expected = project_merge_request_path(project, merge_request)
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link to the commit" do
expected = project_commit_path(project, commit)
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link to the issue" do
expected = project_issue_path(project, issue)
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
end
describe "emoji" do
it "matches at the start of a string" do
- gfm(":+1:").should match(/<img/)
+ expect(gfm(":+1:")).to match(/<img/)
end
it "matches at the end of a string" do
- gfm("This gets a :-1:").should match(/<img/)
+ expect(gfm("This gets a :-1:")).to match(/<img/)
end
it "matches with adjacent text" do
- gfm("+1 (:+1:)").should match(/<img/)
+ expect(gfm("+1 (:+1:)")).to match(/<img/)
end
it "has a title attribute" do
- gfm(":-1:").should match(/title=":-1:"/)
+ expect(gfm(":-1:")).to match(/title=":-1:"/)
end
it "has an alt attribute" do
- gfm(":-1:").should match(/alt=":-1:"/)
+ expect(gfm(":-1:")).to match(/alt=":-1:"/)
end
it "has an emoji class" do
- gfm(":+1:").should match('class="emoji"')
+ expect(gfm(":+1:")).to match('class="emoji"')
end
it "sets height and width" do
actual = gfm(":+1:")
- actual.should match(/width="20"/)
- actual.should match(/height="20"/)
+ expect(actual).to match(/width="20"/)
+ expect(actual).to match(/height="20"/)
end
it "keeps whitespace intact" do
- gfm('This deserves a :+1: big time.').
- should match(/deserves a <img.+> big time/)
+ expect(gfm('This deserves a :+1: big time.')).
+ to match(/deserves a <img.+> big time/)
end
it "ignores invalid emoji" do
- gfm(":invalid-emoji:").should_not match(/<img/)
+ expect(gfm(":invalid-emoji:")).not_to match(/<img/)
end
it "should work independent of reference links (i.e. without @project being set)" do
@project = nil
- gfm(":+1:").should match(/<img/)
+ expect(gfm(":+1:")).to match(/<img/)
end
end
end
@@ -467,34 +469,37 @@ describe GitlabMarkdownHelper do
groups = actual.split("</a>")
# Leading commit link
- groups[0].should match(/href="#{commit_path}"/)
- groups[0].should match(/This should finally fix $/)
+ expect(groups[0]).to match(/href="#{commit_path}"/)
+ expect(groups[0]).to match(/This should finally fix $/)
# First issue link
- groups[1].should match(/href="#{project_issue_url(project, issues[0])}"/)
- groups[1].should match(/##{issues[0].iid}$/)
+ expect(groups[1]).
+ to match(/href="#{project_issue_url(project, issues[0])}"/)
+ expect(groups[1]).to match(/##{issues[0].iid}$/)
# Internal commit link
- groups[2].should match(/href="#{commit_path}"/)
- groups[2].should match(/ and /)
+ expect(groups[2]).to match(/href="#{commit_path}"/)
+ expect(groups[2]).to match(/ and /)
# Second issue link
- groups[3].should match(/href="#{project_issue_url(project, issues[1])}"/)
- groups[3].should match(/##{issues[1].iid}$/)
+ expect(groups[3]).
+ to match(/href="#{project_issue_url(project, issues[1])}"/)
+ expect(groups[3]).to match(/##{issues[1].iid}$/)
# Trailing commit link
- groups[4].should match(/href="#{commit_path}"/)
- groups[4].should match(/ for real$/)
+ expect(groups[4]).to match(/href="#{commit_path}"/)
+ expect(groups[4]).to match(/ for real$/)
end
it "should forward HTML options" do
actual = link_to_gfm("Fixed in #{commit.id}", commit_path, class: 'foo')
- actual.should have_selector 'a.gfm.gfm-commit.foo'
+ expect(actual).to have_selector 'a.gfm.gfm-commit.foo'
end
it "escapes HTML passed in as the body" do
actual = "This is a <h1>test</h1> - see ##{issues[0].iid}"
- link_to_gfm(actual, commit_path).should match('&lt;h1&gt;test&lt;/h1&gt;')
+ expect(link_to_gfm(actual, commit_path)).
+ to match('&lt;h1&gt;test&lt;/h1&gt;')
end
end
@@ -502,25 +507,29 @@ describe GitlabMarkdownHelper do
it "should handle references in paragraphs" do
actual = "\n\nLorem ipsum dolor sit amet. #{commit.id} Nam pulvinar sapien eget.\n"
expected = project_commit_path(project, commit)
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle references in headers" do
actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}"
- markdown(actual, {no_header_anchors:true}).should match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
- markdown(actual, {no_header_anchors:true}).should match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
+ expect(markdown(actual, no_header_anchors: true)).
+ to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
+ expect(markdown(actual, no_header_anchors: true)).
+ to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
end
it "should add ids and links to headers" do
# Test every rule except nested tags.
text = '..Ab_c-d. e..'
id = 'ab_c-d-e'
- markdown("# #{text}").should match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
- markdown("# #{text}", {no_header_anchors:true}).should == "<h1>#{text}</h1>"
+ expect(markdown("# #{text}")).
+ to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
+ expect(markdown("# #{text}", {no_header_anchors:true})).
+ to eq("<h1>#{text}</h1>")
id = 'link-text'
- markdown("# [link text](url) ![img alt](url)").should match(
+ expect(markdown("# [link text](url) ![img alt](url)")).to match(
%r{<h1 id="#{id}"><a href="[^"]*url">link text</a> <img[^>]*><a href="[^"]*##{id}"></a></h1>}
)
end
@@ -530,32 +539,37 @@ describe GitlabMarkdownHelper do
actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}"
- markdown(actual).should match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
- markdown(actual).should match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
+ expect(markdown(actual)).
+ to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
+ expect(markdown(actual)).
+ to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
end
it "should not link the apostrophe to issue 39" do
project.team << [user, :master]
- project.issues.stub(:where).with(iid: '39').and_return([issue])
+ allow(project.issues).
+ to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, it is @#{member.user.username}'s task."
expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should not link the apostrophe to issue 39 in code blocks" do
project.team << [user, :master]
- project.issues.stub(:where).with(iid: '39').and_return([issue])
+ allow(project.issues).
+ to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, `it is @#{member.user.username}'s task.`"
expected = /Yes, <code>it is @gfm\'s task.<\/code>/
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle references in <em>" do
actual = "Apply _!#{merge_request.iid}_ ASAP"
- markdown(actual).should match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
+ expect(markdown(actual)).
+ to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
end
it "should handle tables" do
@@ -564,91 +578,94 @@ describe GitlabMarkdownHelper do
| cell 1 | cell 2 |
| cell 3 | cell 4 |}
- markdown(actual).should match(/\A<table/)
+ expect(markdown(actual)).to match(/\A<table/)
end
it "should leave code blocks untouched" do
- helper.stub(:user_color_scheme_class).and_return(:white)
+ allow(helper).to receive(:user_color_scheme_class).and_return(:white)
target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
- helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html
- helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html
+ expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).
+ to eq(target_html)
+ expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).
+ to eq(target_html)
end
it "should leave inline code untouched" do
- markdown("\nDon't use `$#{snippet.id}` here.\n").should ==
+ expect(markdown("\nDon't use `$#{snippet.id}` here.\n")).to eq(
"<p>Don't use <code>$#{snippet.id}</code> here.</p>\n"
+ )
end
it "should leave ref-like autolinks untouched" do
- markdown("look at http://example.tld/#!#{merge_request.iid}").should == "<p>look at <a href=\"http://example.tld/#!#{merge_request.iid}\">http://example.tld/#!#{merge_request.iid}</a></p>\n"
+ expect(markdown("look at http://example.tld/#!#{merge_request.iid}")).to eq("<p>look at <a href=\"http://example.tld/#!#{merge_request.iid}\">http://example.tld/#!#{merge_request.iid}</a></p>\n")
end
it "should leave ref-like href of 'manual' links untouched" do
- markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})").should == "<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a class=\"gfm gfm-merge_request \" href=\"#{project_merge_request_url(project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n"
+ expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a class=\"gfm gfm-merge_request \" href=\"#{project_merge_request_url(project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n")
end
it "should leave ref-like src of images untouched" do
- markdown("screen shot: ![some image](http://example.tld/#!#{merge_request.iid})").should == "<p>screen shot: <img src=\"http://example.tld/#!#{merge_request.iid}\" alt=\"some image\"></p>\n"
+ expect(markdown("screen shot: ![some image](http://example.tld/#!#{merge_request.iid})")).to eq("<p>screen shot: <img src=\"http://example.tld/#!#{merge_request.iid}\" alt=\"some image\"></p>\n")
end
it "should generate absolute urls for refs" do
- markdown("##{issue.iid}").should include(project_issue_url(project, issue))
+ expect(markdown("##{issue.iid}")).to include(project_issue_url(project, issue))
end
it "should generate absolute urls for emoji" do
- markdown(':smile:').should(
+ expect(markdown(':smile:')).to(
include(%(src="#{Gitlab.config.gitlab.url}/assets/emoji/smile.png))
)
end
it "should generate absolute urls for emoji if relative url is present" do
- Gitlab.config.gitlab.stub(:url).and_return('http://localhost/gitlab/root')
- markdown(":smile:").should include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
+ allow(Gitlab.config.gitlab).to receive(:url).and_return('http://localhost/gitlab/root')
+ expect(markdown(":smile:")).to include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
end
it "should generate absolute urls for emoji if asset_host is present" do
- Gitlab::Application.config.stub(:asset_host).and_return("https://cdn.example.com")
+ allow(Gitlab::Application.config).to receive(:asset_host).and_return("https://cdn.example.com")
ActionView::Base.any_instance.stub_chain(:config, :asset_host).and_return("https://cdn.example.com")
- markdown(":smile:").should include("src=\"https://cdn.example.com/assets/emoji/smile.png")
+ expect(markdown(":smile:")).to include("src=\"https://cdn.example.com/assets/emoji/smile.png")
end
it "should handle relative urls for a file in master" do
actual = "[GitLab API doc](doc/api/README.md)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle relative urls for a directory in master" do
actual = "[GitLab API doc](doc/api)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle absolute urls" do
actual = "[GitLab](https://www.gitlab.com)\n"
expected = "<p><a href=\"https://www.gitlab.com\">GitLab</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle relative urls in reference links for a file in master" do
actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle relative urls in reference links for a directory in master" do
actual = "[GitLab API doc directory][GitLab readmes]\n [GitLab readmes]: doc/api/\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc directory</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should not handle malformed relative urls in reference links for a file in master" do
actual = "[GitLab readme]: doc/api/README.md\n"
expected = ""
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
end
@@ -661,29 +678,29 @@ describe GitlabMarkdownHelper do
it "should not touch relative urls" do
actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n"
expected = "<p><a href=\"doc/api/README.md\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
end
describe "#render_wiki_content" do
before do
@wiki = double('WikiPage')
- @wiki.stub(:content).and_return('wiki content')
+ allow(@wiki).to receive(:content).and_return('wiki content')
end
it "should use GitLab Flavored Markdown for markdown files" do
- @wiki.stub(:format).and_return(:markdown)
+ allow(@wiki).to receive(:format).and_return(:markdown)
- helper.should_receive(:markdown).with('wiki content')
+ expect(helper).to receive(:markdown).with('wiki content')
helper.render_wiki_content(@wiki)
end
it "should use the Gollum renderer for all other file types" do
- @wiki.stub(:format).and_return(:rdoc)
+ allow(@wiki).to receive(:format).and_return(:rdoc)
formatted_content_stub = double('formatted_content')
- formatted_content_stub.should_receive(:html_safe)
- @wiki.stub(:formatted_content).and_return(formatted_content_stub)
+ expect(formatted_content_stub).to receive(:html_safe)
+ allow(@wiki).to receive(:formatted_content).and_return(formatted_content_stub)
helper.render_wiki_content(@wiki)
end
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index c82729a52e2..7a8fd25e02d 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -5,25 +5,25 @@ describe IssuesHelper do
let(:issue) { create :issue, project: project }
let(:ext_project) { create :redmine_project }
- describe :title_for_issue do
+ describe "title_for_issue" do
it "should return issue title if used internal tracker" do
@project = project
- title_for_issue(issue.iid).should eq issue.title
+ expect(title_for_issue(issue.iid)).to eq issue.title
end
it "should always return empty string if used external tracker" do
@project = ext_project
- title_for_issue(rand(100)).should eq ""
+ expect(title_for_issue(rand(100))).to eq ""
end
it "should always return empty string if project nil" do
@project = nil
- title_for_issue(rand(100)).should eq ""
+ expect(title_for_issue(rand(100))).to eq ""
end
end
- describe :url_for_project_issues do
+ describe "url_for_project_issues" do
let(:project_url) { ext_project.external_issue_tracker.project_url }
let(:ext_expected) do
project_url.gsub(':project_id', ext_project.id.to_s)
@@ -33,34 +33,34 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
- url_for_project_issues.should match(int_expected)
+ expect(url_for_project_issues).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
- url_for_project_issues.should match(ext_expected)
+ expect(url_for_project_issues).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
- url_for_project_issues.should eq ""
+ expect(url_for_project_issues).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
- Gitlab.config.stub(:issues_tracker).and_return(nil)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return path to external tracker" do
- url_for_project_issues.should match(ext_expected)
+ expect(url_for_project_issues).to match(ext_expected)
end
end
end
- describe :url_for_issue do
+ describe "url_for_issue" do
let(:issues_url) { ext_project.external_issue_tracker.issues_url}
let(:ext_expected) do
issues_url.gsub(':id', issue.iid.to_s)
@@ -71,34 +71,34 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
- url_for_issue(issue.iid).should match(int_expected)
+ expect(url_for_issue(issue.iid)).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
- url_for_issue(issue.iid).should match(ext_expected)
+ expect(url_for_issue(issue.iid)).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
- url_for_issue(issue.iid).should eq ""
+ expect(url_for_issue(issue.iid)).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
- Gitlab.config.stub(:issues_tracker).and_return(nil)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return external path" do
- url_for_issue(issue.iid).should match(ext_expected)
+ expect(url_for_issue(issue.iid)).to match(ext_expected)
end
end
end
- describe :url_for_new_issue do
+ describe '#url_for_new_issue' do
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
let(:ext_expected) do
issues_url.gsub(':project_id', ext_project.id.to_s)
@@ -108,29 +108,29 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
- url_for_new_issue.should match(int_expected)
+ expect(url_for_new_issue).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
- url_for_new_issue.should match(ext_expected)
+ expect(url_for_new_issue).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
- url_for_new_issue.should eq ""
+ expect(url_for_new_issue).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
- Gitlab.config.stub(:issues_tracker).and_return(nil)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return internal path" do
- url_for_new_issue.should match(ext_expected)
+ expect(url_for_new_issue).to match(ext_expected)
end
end
end
diff --git a/spec/helpers/merge_requests_helper.rb b/spec/helpers/merge_requests_helper.rb
index 5a317c4886b..5262d644048 100644
--- a/spec/helpers/merge_requests_helper.rb
+++ b/spec/helpers/merge_requests_helper.rb
@@ -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
diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb
index dcc3318e4f9..482cb33e94f 100644
--- a/spec/helpers/notifications_helper_spec.rb
+++ b/spec/helpers/notifications_helper_spec.rb
@@ -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
diff --git a/spec/helpers/oauth_helper_spec.rb b/spec/helpers/oauth_helper_spec.rb
index 453699136e9..088c342fa13 100644
--- a/spec/helpers/oauth_helper_spec.rb
+++ b/spec/helpers/oauth_helper_spec.rb
@@ -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
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 281d4862199..0f78725e3d9 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -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
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index 733f2754727..b327f4f911a 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -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
diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb
index 41c9f038c26..3d80dc9d0a4 100644
--- a/spec/helpers/submodule_helper_spec.rb
+++ b/spec/helpers/submodule_helper_spec.rb
@@ -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
diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb
index fa8a3f554f7..fc0ceecfbe7 100644
--- a/spec/helpers/tab_helper_spec.rb
+++ b/spec/helpers/tab_helper_spec.rb
@@ -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
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index 8aa50c4c778..8271e00f41b 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -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
diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb
index 8bf6ee2ed50..06d5450688b 100644
--- a/spec/lib/disable_email_interceptor_spec.rb
+++ b/spec/lib/disable_email_interceptor_spec.rb
@@ -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)
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb
index 7b3818ea5c8..ac602eac154 100644
--- a/spec/lib/extracts_path_spec.rb
+++ b/spec/lib/extracts_path_spec.rb
@@ -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
diff --git a/spec/lib/git_ref_validator_spec.rb b/spec/lib/git_ref_validator_spec.rb
index b2469c18395..4633b6f3934 100644
--- a/spec/lib/git_ref_validator_spec.rb
+++ b/spec/lib/git_ref_validator_spec.rb
@@ -1,20 +1,20 @@
require 'spec_helper'
describe Gitlab::GitRefValidator do
- it { Gitlab::GitRefValidator.validate('feature/new').should be_true }
- it { Gitlab::GitRefValidator.validate('implement_@all').should be_true }
- it { Gitlab::GitRefValidator.validate('my_new_feature').should be_true }
- it { Gitlab::GitRefValidator.validate('#1').should be_true }
- it { Gitlab::GitRefValidator.validate('feature/~new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/^new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/:new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/?new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/*new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/[new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/new/').should be_false }
- it { Gitlab::GitRefValidator.validate('feature/new.').should be_false }
- it { Gitlab::GitRefValidator.validate('feature\@{').should be_false }
- it { Gitlab::GitRefValidator.validate('feature\new').should be_false }
- it { Gitlab::GitRefValidator.validate('feature//new').should be_false }
- it { Gitlab::GitRefValidator.validate('feature new').should be_false }
+ it { expect(Gitlab::GitRefValidator.validate('feature/new')).to be_truthy }
+ it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy }
+ it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy }
+ it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy }
+ it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/?new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/*new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/[new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/new/')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature/new.')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature\@{')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey }
+ it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey }
end
diff --git a/spec/lib/gitlab/backend/shell_spec.rb b/spec/lib/gitlab/backend/shell_spec.rb
index f00ec0fa401..27279465c1a 100644
--- a/spec/lib/gitlab/backend/shell_spec.rb
+++ b/spec/lib/gitlab/backend/shell_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb
index 0a1f3fa351d..c96ee78e5fd 100644
--- a/spec/lib/gitlab/closing_issue_extractor_spec.rb
+++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb
index cf0b5c282c1..40eb45e37ca 100644
--- a/spec/lib/gitlab/diff/file_spec.rb
+++ b/spec/lib/gitlab/diff/file_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/diff/parser_spec.rb b/spec/lib/gitlab/diff/parser_spec.rb
index 35b78260acd..918f6d0ead4 100644
--- a/spec/lib/gitlab/diff/parser_spec.rb
+++ b/spec/lib/gitlab/diff/parser_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index fbcaa405f8d..666398eedd4 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb
index 4ff45c0c616..c31c6764091 100644
--- a/spec/lib/gitlab/git_access_wiki_spec.rb
+++ b/spec/lib/gitlab/git_access_wiki_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/github/project_creator.rb b/spec/lib/gitlab/github/project_creator.rb
index 0bade5619a5..3686ddbf170 100644
--- a/spec/lib/gitlab/github/project_creator.rb
+++ b/spec/lib/gitlab/github/project_creator.rb
@@ -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
diff --git a/spec/lib/gitlab/gitlab_import/project_creator.rb b/spec/lib/gitlab/gitlab_import/project_creator.rb
index 51f3534ed60..e5d917830b0 100644
--- a/spec/lib/gitlab/gitlab_import/project_creator.rb
+++ b/spec/lib/gitlab/gitlab_import/project_creator.rb
@@ -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
diff --git a/spec/lib/gitlab/gitlab_markdown_helper_spec.rb b/spec/lib/gitlab/gitlab_markdown_helper_spec.rb
index 540618a5603..ab613193f41 100644
--- a/spec/lib/gitlab/gitlab_markdown_helper_spec.rb
+++ b/spec/lib/gitlab/gitlab_markdown_helper_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/ldap/access_spec.rb b/spec/lib/gitlab/ldap/access_spec.rb
index 4573b8696c4..a2b05249147 100644
--- a/spec/lib/gitlab/ldap/access_spec.rb
+++ b/spec/lib/gitlab/ldap/access_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb
index 19347e47378..b609e4b38f2 100644
--- a/spec/lib/gitlab/ldap/adapter_spec.rb
+++ b/spec/lib/gitlab/ldap/adapter_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/ldap/authentication_spec.rb b/spec/lib/gitlab/ldap/authentication_spec.rb
index 11fdf108756..8afc2b21f46 100644
--- a/spec/lib/gitlab/ldap/authentication_spec.rb
+++ b/spec/lib/gitlab/ldap/authentication_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/ldap/config_spec.rb b/spec/lib/gitlab/ldap/config_spec.rb
index 3ebb8aae243..2df2beca7a6 100644
--- a/spec/lib/gitlab/ldap/config_spec.rb
+++ b/spec/lib/gitlab/ldap/config_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb
index 63ffc21ba3b..4f93545feb6 100644
--- a/spec/lib/gitlab/ldap/user_spec.rb
+++ b/spec/lib/gitlab/ldap/user_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/oauth/user_spec.rb b/spec/lib/gitlab/oauth/user_spec.rb
index 2680794a747..44cdd1e4fab 100644
--- a/spec/lib/gitlab/oauth/user_spec.rb
+++ b/spec/lib/gitlab/oauth/user_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb
index 76d506eb3c0..cd9d0456b25 100644
--- a/spec/lib/gitlab/popen_spec.rb
+++ b/spec/lib/gitlab/popen_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/push_data_builder_spec.rb b/spec/lib/gitlab/push_data_builder_spec.rb
index 691fd133637..da25d45f1ff 100644
--- a/spec/lib/gitlab/push_data_builder_spec.rb
+++ b/spec/lib/gitlab/push_data_builder_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb
index 5f45df4e8c3..0847c31258c 100644
--- a/spec/lib/gitlab/reference_extractor_spec.rb
+++ b/spec/lib/gitlab/reference_extractor_spec.rb
@@ -3,51 +3,51 @@ require 'spec_helper'
describe Gitlab::ReferenceExtractor do
it 'extracts username references' do
subject.analyze('this contains a @user reference', nil)
- subject.users.should == [{ project: nil, id: 'user' }]
+ expect(subject.users).to eq([{ project: nil, id: 'user' }])
end
it 'extracts issue references' do
subject.analyze('this one talks about issue #1234', nil)
- subject.issues.should == [{ project: nil, id: '1234' }]
+ expect(subject.issues).to eq([{ project: nil, id: '1234' }])
end
it 'extracts JIRA issue references' do
subject.analyze('this one talks about issue JIRA-1234', nil)
- subject.issues.should == [{ project: nil, id: 'JIRA-1234' }]
+ expect(subject.issues).to eq([{ project: nil, id: 'JIRA-1234' }])
end
it 'extracts merge request references' do
subject.analyze("and here's !43, a merge request", nil)
- subject.merge_requests.should == [{ project: nil, id: '43' }]
+ expect(subject.merge_requests).to eq([{ project: nil, id: '43' }])
end
it 'extracts snippet ids' do
subject.analyze('snippets like $12 get extracted as well', nil)
- subject.snippets.should == [{ project: nil, id: '12' }]
+ expect(subject.snippets).to eq([{ project: nil, id: '12' }])
end
it 'extracts commit shas' do
subject.analyze('commit shas 98cf0ae3 are pulled out as Strings', nil)
- subject.commits.should == [{ project: nil, id: '98cf0ae3' }]
+ expect(subject.commits).to eq([{ project: nil, id: '98cf0ae3' }])
end
it 'extracts multiple references and preserves their order' do
subject.analyze('@me and @you both care about this', nil)
- subject.users.should == [
+ expect(subject.users).to eq([
{ project: nil, id: 'me' },
{ project: nil, id: 'you' }
- ]
+ ])
end
it 'leaves the original note unmodified' do
text = 'issue #123 is just the worst, @user'
subject.analyze(text, nil)
- text.should == 'issue #123 is just the worst, @user'
+ expect(text).to eq('issue #123 is just the worst, @user')
end
it 'handles all possible kinds of references' do
accessors = Gitlab::Markdown::TYPES.map { |t| "#{t}s".to_sym }
- subject.should respond_to(*accessors)
+ expect(subject).to respond_to(*accessors)
end
context 'with a project' do
@@ -62,7 +62,7 @@ describe Gitlab::ReferenceExtractor do
project.team << [@u_bar, :guest]
subject.analyze('@foo, @baduser, @bar, and @offteam', project)
- subject.users_for(project).should == [@u_foo, @u_bar]
+ expect(subject.users_for(project)).to eq([@u_foo, @u_bar])
end
it 'accesses valid issue objects' do
@@ -70,7 +70,7 @@ describe Gitlab::ReferenceExtractor do
@i1 = create(:issue, project: project)
subject.analyze("##{@i0.iid}, ##{@i1.iid}, and #999.", project)
- subject.issues_for(project).should == [@i0, @i1]
+ expect(subject.issues_for(project)).to eq([@i0, @i1])
end
it 'accesses valid merge requests' do
@@ -78,7 +78,7 @@ describe Gitlab::ReferenceExtractor do
@m1 = create(:merge_request, source_project: project, target_project: project, source_branch: 'bbb')
subject.analyze("!999, !#{@m1.iid}, and !#{@m0.iid}.", project)
- subject.merge_requests_for(project).should == [@m1, @m0]
+ expect(subject.merge_requests_for(project)).to eq([@m1, @m0])
end
it 'accesses valid snippets' do
@@ -87,7 +87,7 @@ describe Gitlab::ReferenceExtractor do
@s2 = create(:project_snippet)
subject.analyze("$#{@s0.id}, $999, $#{@s2.id}, $#{@s1.id}", project)
- subject.snippets_for(project).should == [@s0, @s1]
+ expect(subject.snippets_for(project)).to eq([@s0, @s1])
end
it 'accesses valid commits' do
@@ -96,9 +96,9 @@ describe Gitlab::ReferenceExtractor do
subject.analyze("this references commits #{commit.sha[0..6]} and 012345",
project)
extracted = subject.commits_for(project)
- extracted.should have(1).item
- extracted[0].sha.should == commit.sha
- extracted[0].message.should == commit.message
+ expect(extracted.size).to eq(1)
+ expect(extracted[0].sha).to eq(commit.sha)
+ expect(extracted[0].message).to eq(commit.message)
end
end
end
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index a3aae7771bd..1db9f15b790 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/satellite/action_spec.rb b/spec/lib/gitlab/satellite/action_spec.rb
index 3eb1258d67e..28e3d64ee2b 100644
--- a/spec/lib/gitlab/satellite/action_spec.rb
+++ b/spec/lib/gitlab/satellite/action_spec.rb
@@ -6,7 +6,7 @@ describe 'Gitlab::Satellite::Action' do
describe '#prepare_satellite!' do
it 'should be able to fetch timeout from conf' do
- Gitlab::Satellite::Action::DEFAULT_OPTIONS[:git_timeout].should == 30.seconds
+ expect(Gitlab::Satellite::Action::DEFAULT_OPTIONS[:git_timeout]).to eq(30.seconds)
end
it 'create a repository with a parking branch and one remote: origin' do
@@ -15,22 +15,22 @@ describe 'Gitlab::Satellite::Action' do
#now lets dirty it up
starting_remote_count = repo.git.list_remotes.size
- starting_remote_count.should >= 1
+ expect(starting_remote_count).to be >= 1
#kind of hookey way to add a second remote
origin_uri = repo.git.remote({v: true}).split(" ")[1]
begin
repo.git.remote({raise: true}, 'add', 'another-remote', origin_uri)
repo.git.branch({raise: true}, 'a-new-branch')
- repo.heads.size.should > (starting_remote_count)
- repo.git.remote().split(" ").size.should > (starting_remote_count)
+ expect(repo.heads.size).to be > (starting_remote_count)
+ expect(repo.git.remote().split(" ").size).to be > (starting_remote_count)
rescue
end
repo.git.config({}, "user.name", "#{user.name} -- foo")
repo.git.config({}, "user.email", "#{user.email} -- foo")
- repo.config['user.name'].should =="#{user.name} -- foo"
- repo.config['user.email'].should =="#{user.email} -- foo"
+ expect(repo.config['user.name']).to eq("#{user.name} -- foo")
+ expect(repo.config['user.email']).to eq("#{user.email} -- foo")
#These must happen in the context of the satellite directory...
@@ -42,13 +42,13 @@ describe 'Gitlab::Satellite::Action' do
#verify it's clean
heads = repo.heads.map(&:name)
- heads.size.should == 1
- heads.include?(Gitlab::Satellite::Satellite::PARKING_BRANCH).should == true
+ expect(heads.size).to eq(1)
+ expect(heads.include?(Gitlab::Satellite::Satellite::PARKING_BRANCH)).to eq(true)
remotes = repo.git.remote().split(' ')
- remotes.size.should == 1
- remotes.include?('origin').should == true
- repo.config['user.name'].should ==user.name
- repo.config['user.email'].should ==user.email
+ expect(remotes.size).to eq(1)
+ expect(remotes.include?('origin')).to eq(true)
+ expect(repo.config['user.name']).to eq(user.name)
+ expect(repo.config['user.email']).to eq(user.email)
end
end
@@ -61,16 +61,16 @@ describe 'Gitlab::Satellite::Action' do
#set assumptions
FileUtils.rm_f(project.satellite.lock_file)
- File.exists?(project.satellite.lock_file).should be_false
+ expect(File.exists?(project.satellite.lock_file)).to be_falsey
satellite_action = Gitlab::Satellite::Action.new(user, project)
satellite_action.send(:in_locked_and_timed_satellite) do |sat_repo|
- repo.should == sat_repo
- (File.exists? project.satellite.lock_file).should be_true
+ expect(repo).to eq(sat_repo)
+ expect(File.exists? project.satellite.lock_file).to be_truthy
called = true
end
- called.should be_true
+ expect(called).to be_truthy
end
@@ -80,19 +80,19 @@ describe 'Gitlab::Satellite::Action' do
# Set base assumptions
if File.exists? project.satellite.lock_file
- FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_false
+ expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_falsey
end
satellite_action = Gitlab::Satellite::Action.new(user, project)
satellite_action.send(:in_locked_and_timed_satellite) do |sat_repo|
called = true
- repo.should == sat_repo
- (File.exists? project.satellite.lock_file).should be_true
- FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_true
+ expect(repo).to eq(sat_repo)
+ expect(File.exists? project.satellite.lock_file).to be_truthy
+ expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_truthy
end
- called.should be_true
- FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_false
+ expect(called).to be_truthy
+ expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_falsey
end
diff --git a/spec/lib/gitlab/satellite/merge_action_spec.rb b/spec/lib/gitlab/satellite/merge_action_spec.rb
index 479a73a1081..915e3ff0e51 100644
--- a/spec/lib/gitlab/satellite/merge_action_spec.rb
+++ b/spec/lib/gitlab/satellite/merge_action_spec.rb
@@ -13,9 +13,9 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#commits_between' do
def verify_commits(commits, first_commit_sha, last_commit_sha)
- commits.each { |commit| commit.class.should == Gitlab::Git::Commit }
- commits.first.id.should == first_commit_sha
- commits.last.id.should == last_commit_sha
+ commits.each { |commit| expect(commit.class).to eq(Gitlab::Git::Commit) }
+ expect(commits.first.id).to eq(first_commit_sha)
+ expect(commits.last.id).to eq(last_commit_sha)
end
context 'on fork' do
@@ -35,7 +35,7 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#format_patch' do
def verify_content(patch)
sample_compare.commits.each do |commit|
- patch.include?(commit).should be_true
+ expect(patch.include?(commit)).to be_truthy
end
end
@@ -57,11 +57,11 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#diffs_between_satellite tested against diff_in_satellite' do
def is_a_matching_diff(diff, diffs)
diff_count = diff.scan('diff --git').size
- diff_count.should >= 1
- diffs.size.should == diff_count
+ expect(diff_count).to be >= 1
+ expect(diffs.size).to eq(diff_count)
diffs.each do |a_diff|
- a_diff.class.should == Gitlab::Git::Diff
- (diff.include? a_diff.diff).should be_true
+ expect(a_diff.class).to eq(Gitlab::Git::Diff)
+ expect(diff.include? a_diff.diff).to be_truthy
end
end
@@ -82,23 +82,23 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#can_be_merged?' do
context 'on fork' do
- it { Gitlab::Satellite::MergeAction.new(
+ it { expect(Gitlab::Satellite::MergeAction.new(
merge_request_fork.author,
- merge_request_fork).can_be_merged?.should be_true }
+ merge_request_fork).can_be_merged?).to be_truthy }
- it { Gitlab::Satellite::MergeAction.new(
+ it { expect(Gitlab::Satellite::MergeAction.new(
merge_request_fork_with_conflict.author,
- merge_request_fork_with_conflict).can_be_merged?.should be_false }
+ merge_request_fork_with_conflict).can_be_merged?).to be_falsey }
end
context 'between branches' do
- it { Gitlab::Satellite::MergeAction.new(
+ it { expect(Gitlab::Satellite::MergeAction.new(
merge_request.author,
- merge_request).can_be_merged?.should be_true }
+ merge_request).can_be_merged?).to be_truthy }
- it { Gitlab::Satellite::MergeAction.new(
+ it { expect(Gitlab::Satellite::MergeAction.new(
merge_request_with_conflict.author,
- merge_request_with_conflict).can_be_merged?.should be_false }
+ merge_request_with_conflict).can_be_merged?).to be_falsey }
end
end
end
diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb
index 2b254d6b3a6..ce3ea6c260a 100644
--- a/spec/lib/gitlab/upgrader_spec.rb
+++ b/spec/lib/gitlab/upgrader_spec.rb
@@ -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
diff --git a/spec/lib/gitlab/version_info_spec.rb b/spec/lib/gitlab/version_info_spec.rb
index 94dccf7a4e5..5afeb1c1ec3 100644
--- a/spec/lib/gitlab/version_info_spec.rb
+++ b/spec/lib/gitlab/version_info_spec.rb
@@ -12,58 +12,58 @@ describe 'Gitlab::VersionInfo', no_db: true do
end
context '>' do
- it { @v2_0_0.should > @v1_1_0 }
- it { @v1_1_0.should > @v1_0_1 }
- it { @v1_0_1.should > @v1_0_0 }
- it { @v1_0_0.should > @v0_1_0 }
- it { @v0_1_0.should > @v0_0_1 }
+ it { expect(@v2_0_0).to be > @v1_1_0 }
+ it { expect(@v1_1_0).to be > @v1_0_1 }
+ it { expect(@v1_0_1).to be > @v1_0_0 }
+ it { expect(@v1_0_0).to be > @v0_1_0 }
+ it { expect(@v0_1_0).to be > @v0_0_1 }
end
context '>=' do
- it { @v2_0_0.should >= Gitlab::VersionInfo.new(2, 0, 0) }
- it { @v2_0_0.should >= @v1_1_0 }
+ it { expect(@v2_0_0).to be >= Gitlab::VersionInfo.new(2, 0, 0) }
+ it { expect(@v2_0_0).to be >= @v1_1_0 }
end
context '<' do
- it { @v0_0_1.should < @v0_1_0 }
- it { @v0_1_0.should < @v1_0_0 }
- it { @v1_0_0.should < @v1_0_1 }
- it { @v1_0_1.should < @v1_1_0 }
- it { @v1_1_0.should < @v2_0_0 }
+ it { expect(@v0_0_1).to be < @v0_1_0 }
+ it { expect(@v0_1_0).to be < @v1_0_0 }
+ it { expect(@v1_0_0).to be < @v1_0_1 }
+ it { expect(@v1_0_1).to be < @v1_1_0 }
+ it { expect(@v1_1_0).to be < @v2_0_0 }
end
context '<=' do
- it { @v0_0_1.should <= Gitlab::VersionInfo.new(0, 0, 1) }
- it { @v0_0_1.should <= @v0_1_0 }
+ it { expect(@v0_0_1).to be <= Gitlab::VersionInfo.new(0, 0, 1) }
+ it { expect(@v0_0_1).to be <= @v0_1_0 }
end
context '==' do
- it { @v0_0_1.should == Gitlab::VersionInfo.new(0, 0, 1) }
- it { @v0_1_0.should == Gitlab::VersionInfo.new(0, 1, 0) }
- it { @v1_0_0.should == Gitlab::VersionInfo.new(1, 0, 0) }
+ it { expect(@v0_0_1).to eq(Gitlab::VersionInfo.new(0, 0, 1)) }
+ it { expect(@v0_1_0).to eq(Gitlab::VersionInfo.new(0, 1, 0)) }
+ it { expect(@v1_0_0).to eq(Gitlab::VersionInfo.new(1, 0, 0)) }
end
context '!=' do
- it { @v0_0_1.should_not == @v0_1_0 }
+ it { expect(@v0_0_1).not_to eq(@v0_1_0) }
end
context 'unknown' do
- it { @unknown.should_not be @v0_0_1 }
- it { @unknown.should_not be Gitlab::VersionInfo.new }
+ it { expect(@unknown).not_to be @v0_0_1 }
+ it { expect(@unknown).not_to be Gitlab::VersionInfo.new }
it { expect{@unknown > @v0_0_1}.to raise_error(ArgumentError) }
it { expect{@unknown < @v0_0_1}.to raise_error(ArgumentError) }
end
context 'parse' do
- it { Gitlab::VersionInfo.parse("1.0.0").should == @v1_0_0 }
- it { Gitlab::VersionInfo.parse("1.0.0.1").should == @v1_0_0 }
- it { Gitlab::VersionInfo.parse("git 1.0.0b1").should == @v1_0_0 }
- it { Gitlab::VersionInfo.parse("git 1.0b1").should_not be_valid }
+ it { expect(Gitlab::VersionInfo.parse("1.0.0")).to eq(@v1_0_0) }
+ it { expect(Gitlab::VersionInfo.parse("1.0.0.1")).to eq(@v1_0_0) }
+ it { expect(Gitlab::VersionInfo.parse("git 1.0.0b1")).to eq(@v1_0_0) }
+ it { expect(Gitlab::VersionInfo.parse("git 1.0b1")).not_to be_valid }
end
context 'to_s' do
- it { @v1_0_0.to_s.should == "1.0.0" }
- it { @unknown.to_s.should == "Unknown" }
+ it { expect(@v1_0_0.to_s).to eq("1.0.0") }
+ it { expect(@unknown.to_s).to eq("Unknown") }
end
end
diff --git a/spec/lib/votes_spec.rb b/spec/lib/votes_spec.rb
index a88a10d927f..df243a26008 100644
--- a/spec/lib/votes_spec.rb
+++ b/spec/lib/votes_spec.rb
@@ -5,107 +5,107 @@ describe Issue, 'Votes' do
describe "#upvotes" do
it "with no notes has a 0/0 score" do
- issue.upvotes.should == 0
+ expect(issue.upvotes).to eq(0)
end
it "should recognize non-+1 notes" do
add_note "No +1 here"
- issue.should have(1).note
- issue.notes.first.upvote?.should be_false
- issue.upvotes.should == 0
+ expect(issue.notes.size).to eq(1)
+ expect(issue.notes.first.upvote?).to be_falsey
+ expect(issue.upvotes).to eq(0)
end
it "should recognize a single +1 note" do
add_note "+1 This is awesome"
- issue.upvotes.should == 1
+ expect(issue.upvotes).to eq(1)
end
it 'should recognize multiple +1 notes' do
add_note '+1 This is awesome', create(:user)
add_note '+1 I want this', create(:user)
- issue.upvotes.should == 2
+ expect(issue.upvotes).to eq(2)
end
it 'should not count 2 +1 votes from the same user' do
add_note '+1 This is awesome'
add_note '+1 I want this'
- issue.upvotes.should == 1
+ expect(issue.upvotes).to eq(1)
end
end
describe "#downvotes" do
it "with no notes has a 0/0 score" do
- issue.downvotes.should == 0
+ expect(issue.downvotes).to eq(0)
end
it "should recognize non--1 notes" do
add_note "Almost got a -1"
- issue.should have(1).note
- issue.notes.first.downvote?.should be_false
- issue.downvotes.should == 0
+ expect(issue.notes.size).to eq(1)
+ expect(issue.notes.first.downvote?).to be_falsey
+ expect(issue.downvotes).to eq(0)
end
it "should recognize a single -1 note" do
add_note "-1 This is bad"
- issue.downvotes.should == 1
+ expect(issue.downvotes).to eq(1)
end
it "should recognize multiple -1 notes" do
add_note('-1 This is bad', create(:user))
add_note('-1 Away with this', create(:user))
- issue.downvotes.should == 2
+ expect(issue.downvotes).to eq(2)
end
end
describe "#votes_count" do
it "with no notes has a 0/0 score" do
- issue.votes_count.should == 0
+ expect(issue.votes_count).to eq(0)
end
it "should recognize non notes" do
add_note "No +1 here"
- issue.should have(1).note
- issue.votes_count.should == 0
+ expect(issue.notes.size).to eq(1)
+ expect(issue.votes_count).to eq(0)
end
it "should recognize a single +1 note" do
add_note "+1 This is awesome"
- issue.votes_count.should == 1
+ expect(issue.votes_count).to eq(1)
end
it "should recognize a single -1 note" do
add_note "-1 This is bad"
- issue.votes_count.should == 1
+ expect(issue.votes_count).to eq(1)
end
it "should recognize multiple notes" do
add_note('+1 This is awesome', create(:user))
add_note('-1 This is bad', create(:user))
add_note('+1 I want this', create(:user))
- issue.votes_count.should == 3
+ expect(issue.votes_count).to eq(3)
end
it 'should not count 2 -1 votes from the same user' do
add_note '-1 This is suspicious'
add_note '-1 This is bad'
- issue.votes_count.should == 1
+ expect(issue.votes_count).to eq(1)
end
end
describe "#upvotes_in_percent" do
it "with no notes has a 0% score" do
- issue.upvotes_in_percent.should == 0
+ expect(issue.upvotes_in_percent).to eq(0)
end
it "should count a single 1 note as 100%" do
add_note "+1 This is awesome"
- issue.upvotes_in_percent.should == 100
+ expect(issue.upvotes_in_percent).to eq(100)
end
it 'should count multiple +1 notes as 100%' do
add_note('+1 This is awesome', create(:user))
add_note('+1 I want this', create(:user))
- issue.upvotes_in_percent.should == 100
+ expect(issue.upvotes_in_percent).to eq(100)
end
it 'should count fractions for multiple +1 and -1 notes correctly' do
@@ -113,24 +113,24 @@ describe Issue, 'Votes' do
add_note('+1 I want this', create(:user))
add_note('-1 This is bad', create(:user))
add_note('+1 me too', create(:user))
- issue.upvotes_in_percent.should == 75
+ expect(issue.upvotes_in_percent).to eq(75)
end
end
describe "#downvotes_in_percent" do
it "with no notes has a 0% score" do
- issue.downvotes_in_percent.should == 0
+ expect(issue.downvotes_in_percent).to eq(0)
end
it "should count a single -1 note as 100%" do
add_note "-1 This is bad"
- issue.downvotes_in_percent.should == 100
+ expect(issue.downvotes_in_percent).to eq(100)
end
it 'should count multiple -1 notes as 100%' do
add_note('-1 This is bad', create(:user))
add_note('-1 Away with this', create(:user))
- issue.downvotes_in_percent.should == 100
+ expect(issue.downvotes_in_percent).to eq(100)
end
it 'should count fractions for multiple +1 and -1 notes correctly' do
@@ -138,7 +138,7 @@ describe Issue, 'Votes' do
add_note('+1 I want this', create(:user))
add_note('-1 This is bad', create(:user))
add_note('+1 me too', create(:user))
- issue.downvotes_in_percent.should == 25
+ expect(issue.downvotes_in_percent).to eq(25)
end
end
@@ -151,8 +151,8 @@ describe Issue, 'Votes' do
add_note('+1 this looks good now')
add_note('+1 This is awesome', create(:user))
add_note('+1 me too', create(:user))
- issue.downvotes.should == 0
- issue.upvotes.should == 5
+ expect(issue.downvotes).to eq(0)
+ expect(issue.upvotes).to eq(5)
end
it 'should count each users vote only once' do
@@ -161,8 +161,8 @@ describe Issue, 'Votes' do
add_note '+1 I still like this'
add_note '+1 I really like this'
add_note '+1 Give me this now!!!!'
- issue.downvotes.should == 0
- issue.upvotes.should == 1
+ expect(issue.downvotes).to eq(0)
+ expect(issue.upvotes).to eq(1)
end
it 'should count a users vote only once without caring about comments' do
@@ -171,8 +171,8 @@ describe Issue, 'Votes' do
add_note 'Another comment'
add_note '+1 vote'
add_note 'final comment'
- issue.downvotes.should == 0
- issue.upvotes.should == 1
+ expect(issue.downvotes).to eq(0)
+ expect(issue.upvotes).to eq(1)
end
end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index c045f85052c..64367ed9d80 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -16,34 +16,34 @@ describe Notify do
shared_examples 'a multiple recipients email' do
it 'is sent to the given recipient' do
- should deliver_to recipient.notification_email
+ is_expected.to deliver_to recipient.notification_email
end
end
shared_examples 'an email sent from GitLab' do
it 'is sent from GitLab' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq('GitLab')
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq('GitLab')
+ expect(sender.address).to eq(gitlab_sender)
end
end
shared_examples 'an email starting a new thread' do |message_id_prefix|
it 'has a discussion identifier' do
- should have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
- should have_header 'X-GitLab-Project', /#{project.name}/
+ is_expected.to have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ is_expected.to have_header 'X-GitLab-Project', /#{project.name}/
end
end
shared_examples 'an answer to an existing thread' do |thread_id_prefix|
it 'has a subject that begins with Re: ' do
- should have_subject /^Re: /
+ is_expected.to have_subject /^Re: /
end
it 'has headers that reference an existing thread' do
- should have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
- should have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
- should have_header 'X-GitLab-Project', /#{project.name}/
+ is_expected.to have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ is_expected.to have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/
+ is_expected.to have_header 'X-GitLab-Project', /#{project.name}/
end
end
@@ -58,30 +58,30 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to new_user.email
+ is_expected.to deliver_to new_user.email
end
it 'has the correct subject' do
- should have_subject /^Account was created for you$/i
+ is_expected.to have_subject /^Account was created for you$/i
end
it 'contains the new user\'s login name' do
- should have_body_text /#{new_user.email}/
+ is_expected.to have_body_text /#{new_user.email}/
end
it 'contains the password text' do
- should have_body_text /Click here to set your password/
+ is_expected.to have_body_text /Click here to set your password/
end
it 'includes a link for user to set password' do
params = "reset_password_token=#{token}"
- should have_body_text(
+ is_expected.to have_body_text(
%r{http://localhost(:\d+)?/users/password/edit\?#{params}}
)
end
it 'includes a link to the site' do
- should have_body_text /#{example_site_path}/
+ is_expected.to have_body_text /#{example_site_path}/
end
end
@@ -95,23 +95,23 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to new_user.email
+ is_expected.to deliver_to new_user.email
end
it 'has the correct subject' do
- should have_subject /^Account was created for you$/i
+ is_expected.to have_subject /^Account was created for you$/i
end
it 'contains the new user\'s login name' do
- should have_body_text /#{new_user.email}/
+ is_expected.to have_body_text /#{new_user.email}/
end
it 'should not contain the new user\'s password' do
- should_not have_body_text /password/
+ is_expected.not_to have_body_text /password/
end
it 'includes a link to the site' do
- should have_body_text /#{example_site_path}/
+ is_expected.to have_body_text /#{example_site_path}/
end
end
@@ -123,19 +123,19 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to key.user.email
+ is_expected.to deliver_to key.user.email
end
it 'has the correct subject' do
- should have_subject /^SSH key was added to your account$/i
+ is_expected.to have_subject /^SSH key was added to your account$/i
end
it 'contains the new ssh key title' do
- should have_body_text /#{key.title}/
+ is_expected.to have_body_text /#{key.title}/
end
it 'includes a link to ssh keys page' do
- should have_body_text /#{profile_keys_path}/
+ is_expected.to have_body_text /#{profile_keys_path}/
end
end
@@ -145,19 +145,19 @@ describe Notify do
subject { Notify.new_email_email(email.id) }
it 'is sent to the new user' do
- should deliver_to email.user.email
+ is_expected.to deliver_to email.user.email
end
it 'has the correct subject' do
- should have_subject /^Email was added to your account$/i
+ is_expected.to have_subject /^Email was added to your account$/i
end
it 'contains the new email address' do
- should have_body_text /#{email.email}/
+ is_expected.to have_body_text /#{email.email}/
end
it 'includes a link to emails page' do
- should have_body_text /#{profile_emails_path}/
+ is_expected.to have_body_text /#{profile_emails_path}/
end
end
@@ -170,12 +170,12 @@ describe Notify do
shared_examples 'an assignee email' do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to the assignee' do
- should deliver_to assignee.email
+ is_expected.to deliver_to assignee.email
end
end
@@ -190,11 +190,11 @@ describe Notify do
it_behaves_like 'an email starting a new thread', 'issue'
it 'has the correct subject' do
- should have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
+ is_expected.to have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/
end
it 'contains a link to the new issue' do
- should have_body_text /#{project_issue_path project, issue}/
+ is_expected.to have_body_text /#{project_issue_path project, issue}/
end
end
@@ -202,7 +202,7 @@ describe Notify do
subject { Notify.new_issue_email(issue_with_description.assignee_id, issue_with_description.id) }
it 'contains the description' do
- should have_body_text /#{issue_with_description.description}/
+ is_expected.to have_body_text /#{issue_with_description.description}/
end
end
@@ -214,24 +214,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{issue.title} \(##{issue.iid}\)/
+ is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/
end
it 'contains the name of the previous assignee' do
- should have_body_text /#{previous_assignee.name}/
+ is_expected.to have_body_text /#{previous_assignee.name}/
end
it 'contains the name of the new assignee' do
- should have_body_text /#{assignee.name}/
+ is_expected.to have_body_text /#{assignee.name}/
end
it 'contains a link to the issue' do
- should have_body_text /#{project_issue_path project, issue}/
+ is_expected.to have_body_text /#{project_issue_path project, issue}/
end
end
@@ -243,24 +243,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{issue.title} \(##{issue.iid}\)/i
+ is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/i
end
it 'contains the new status' do
- should have_body_text /#{status}/i
+ is_expected.to have_body_text /#{status}/i
end
it 'contains the user name' do
- should have_body_text /#{current_user.name}/i
+ is_expected.to have_body_text /#{current_user.name}/i
end
it 'contains a link to the issue' do
- should have_body_text /#{project_issue_path project, issue}/
+ is_expected.to have_body_text /#{project_issue_path project, issue}/
end
end
@@ -278,23 +278,23 @@ describe Notify do
it_behaves_like 'an email starting a new thread', 'merge_request'
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains a link to the new merge request' do
- should have_body_text /#{project_merge_request_path(project, merge_request)}/
+ is_expected.to have_body_text /#{project_merge_request_path(project, merge_request)}/
end
it 'contains the source branch for the merge request' do
- should have_body_text /#{merge_request.source_branch}/
+ is_expected.to have_body_text /#{merge_request.source_branch}/
end
it 'contains the target branch for the merge request' do
- should have_body_text /#{merge_request.target_branch}/
+ is_expected.to have_body_text /#{merge_request.target_branch}/
end
it 'has the correct message-id set' do
- should have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
+ is_expected.to have_header 'Message-ID', "<merge_request_#{merge_request.id}@#{Gitlab.config.gitlab.host}>"
end
end
@@ -302,7 +302,7 @@ describe Notify do
subject { Notify.new_merge_request_email(merge_request_with_description.assignee_id, merge_request_with_description.id) }
it 'contains the description' do
- should have_body_text /#{merge_request_with_description.description}/
+ is_expected.to have_body_text /#{merge_request_with_description.description}/
end
end
@@ -314,24 +314,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains the name of the previous assignee' do
- should have_body_text /#{previous_assignee.name}/
+ is_expected.to have_body_text /#{previous_assignee.name}/
end
it 'contains the name of the new assignee' do
- should have_body_text /#{assignee.name}/
+ is_expected.to have_body_text /#{assignee.name}/
end
it 'contains a link to the merge request' do
- should have_body_text /#{project_merge_request_path project, merge_request}/
+ is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
end
end
@@ -343,24 +343,24 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(current_user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(current_user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i
end
it 'contains the new status' do
- should have_body_text /#{status}/i
+ is_expected.to have_body_text /#{status}/i
end
it 'contains the user name' do
- should have_body_text /#{current_user.name}/i
+ is_expected.to have_body_text /#{current_user.name}/i
end
it 'contains a link to the merge request' do
- should have_body_text /#{project_merge_request_path project, merge_request}/
+ is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
end
end
@@ -372,20 +372,20 @@ describe Notify do
it 'is sent as the merge author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(merge_author.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(merge_author.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains the new status' do
- should have_body_text /merged/i
+ is_expected.to have_body_text /merged/i
end
it 'contains a link to the merge request' do
- should have_body_text /#{project_merge_request_path project, merge_request}/
+ is_expected.to have_body_text /#{project_merge_request_path project, merge_request}/
end
end
end
@@ -399,15 +399,15 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'has the correct subject' do
- should have_subject /Project was moved/
+ is_expected.to have_subject /Project was moved/
end
it 'contains name of project' do
- should have_body_text /#{project.name_with_namespace}/
+ is_expected.to have_body_text /#{project.name_with_namespace}/
end
it 'contains new user role' do
- should have_body_text /#{project.ssh_url_to_repo}/
+ is_expected.to have_body_text /#{project.ssh_url_to_repo}/
end
end
@@ -422,13 +422,13 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'has the correct subject' do
- should have_subject /Access to project was granted/
+ is_expected.to have_subject /Access to project was granted/
end
it 'contains name of project' do
- should have_body_text /#{project.name}/
+ is_expected.to have_body_text /#{project.name}/
end
it 'contains new user role' do
- should have_body_text /#{project_member.human_access}/
+ is_expected.to have_body_text /#{project_member.human_access}/
end
end
@@ -437,29 +437,29 @@ describe Notify do
let(:note) { create(:note, project: project, author: note_author) }
before :each do
- Note.stub(:find).with(note.id).and_return(note)
+ allow(Note).to receive(:find).with(note.id).and_return(note)
end
shared_examples 'a note email' do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(note_author.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(note_author.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to the given recipient' do
- should deliver_to recipient.notification_email
+ is_expected.to deliver_to recipient.notification_email
end
it 'contains the message from the note' do
- should have_body_text /#{note.note}/
+ is_expected.to have_body_text /#{note.note}/
end
end
describe 'on a commit' do
let(:commit) { project.repository.commit }
- before(:each) { note.stub(:noteable).and_return(commit) }
+ before(:each) { allow(note).to receive(:noteable).and_return(commit) }
subject { Notify.note_commit_email(recipient.id, note.id) }
@@ -467,18 +467,18 @@ describe Notify do
it_behaves_like 'an answer to an existing thread', 'commits'
it 'has the correct subject' do
- should have_subject /#{commit.title} \(#{commit.short_id}\)/
+ is_expected.to have_subject /#{commit.title} \(#{commit.short_id}\)/
end
it 'contains a link to the commit' do
- should have_body_text commit.short_id
+ is_expected.to have_body_text commit.short_id
end
end
describe 'on a merge request' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") }
- before(:each) { note.stub(:noteable).and_return(merge_request) }
+ before(:each) { allow(note).to receive(:noteable).and_return(merge_request) }
subject { Notify.note_merge_request_email(recipient.id, note.id) }
@@ -486,18 +486,18 @@ describe Notify do
it_behaves_like 'an answer to an existing thread', 'merge_request'
it 'has the correct subject' do
- should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
+ is_expected.to have_subject /#{merge_request.title} \(##{merge_request.iid}\)/
end
it 'contains a link to the merge request note' do
- should have_body_text /#{note_on_merge_request_path}/
+ is_expected.to have_body_text /#{note_on_merge_request_path}/
end
end
describe 'on an issue' do
let(:issue) { create(:issue, project: project) }
let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
- before(:each) { note.stub(:noteable).and_return(issue) }
+ before(:each) { allow(note).to receive(:noteable).and_return(issue) }
subject { Notify.note_issue_email(recipient.id, note.id) }
@@ -505,11 +505,11 @@ describe Notify do
it_behaves_like 'an answer to an existing thread', 'issue'
it 'has the correct subject' do
- should have_subject /#{issue.title} \(##{issue.iid}\)/
+ is_expected.to have_subject /#{issue.title} \(##{issue.iid}\)/
end
it 'contains a link to the issue note' do
- should have_body_text /#{note_on_issue_path}/
+ is_expected.to have_body_text /#{note_on_issue_path}/
end
end
end
@@ -525,15 +525,15 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'has the correct subject' do
- should have_subject /Access to group was granted/
+ is_expected.to have_subject /Access to group was granted/
end
it 'contains name of project' do
- should have_body_text /#{group.name}/
+ is_expected.to have_body_text /#{group.name}/
end
it 'contains new user role' do
- should have_body_text /#{membership.human_access}/
+ is_expected.to have_body_text /#{membership.human_access}/
end
end
@@ -551,15 +551,15 @@ describe Notify do
it_behaves_like 'an email sent from GitLab'
it 'is sent to the new user' do
- should deliver_to 'new-email@mail.com'
+ is_expected.to deliver_to 'new-email@mail.com'
end
it 'has the correct subject' do
- should have_subject "Confirmation instructions"
+ is_expected.to have_subject "Confirmation instructions"
end
it 'includes a link to the site' do
- should have_body_text /#{example_site_path}/
+ is_expected.to have_body_text /#{example_site_path}/
end
end
@@ -574,28 +574,28 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to recipient' do
- should deliver_to 'devs@company.name'
+ is_expected.to deliver_to 'devs@company.name'
end
it 'has the correct subject' do
- should have_subject /#{commits.length} new commits pushed to repository/
+ is_expected.to have_subject /#{commits.length} new commits pushed to repository/
end
it 'includes commits list' do
- should have_body_text /Change some files/
+ is_expected.to have_body_text /Change some files/
end
it 'includes diffs' do
- should have_body_text /def archive_formats_regex/
+ is_expected.to have_body_text /def archive_formats_regex/
end
it 'contains a link to the diff' do
- should have_body_text /#{diff_path}/
+ is_expected.to have_body_text /#{diff_path}/
end
end
@@ -610,28 +610,28 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
- sender.display_name.should eq(user.name)
- sender.address.should eq(gitlab_sender)
+ expect(sender.display_name).to eq(user.name)
+ expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to recipient' do
- should deliver_to 'devs@company.name'
+ is_expected.to deliver_to 'devs@company.name'
end
it 'has the correct subject' do
- should have_subject /#{commits.first.title}/
+ is_expected.to have_subject /#{commits.first.title}/
end
it 'includes commits list' do
- should have_body_text /Change some files/
+ is_expected.to have_body_text /Change some files/
end
it 'includes diffs' do
- should have_body_text /def archive_formats_regex/
+ is_expected.to have_body_text /def archive_formats_regex/
end
it 'contains a link to the diff' do
- should have_body_text /#{diff_path}/
+ is_expected.to have_body_text /#{diff_path}/
end
end
end
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index cd6d03e6c1a..cb43fdb7fc7 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -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
diff --git a/spec/models/asana_service_spec.rb b/spec/models/asana_service_spec.rb
index 6bebb76f8c7..83e39f87f33 100644
--- a/spec/models/asana_service_spec.rb
+++ b/spec/models/asana_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe AsanaService, models: true do
describe 'Associations' do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe 'Validations' do
@@ -26,7 +26,7 @@ describe AsanaService, models: true do
subject.active = true
end
- it { should validate_presence_of :api_key }
+ it { is_expected.to validate_presence_of :api_key }
end
end
@@ -46,13 +46,13 @@ describe AsanaService, models: true do
end
it 'should call Asana service to created a story' do
- Asana::Task.should_receive(:find).with('123456').once
+ expect(Asana::Task).to receive(:find).with('123456').once
@asana.check_commit('related to #123456', 'pushed')
end
it 'should call Asana service to created a story and close a task' do
- Asana::Task.should_receive(:find).with('456789').twice
+ expect(Asana::Task).to receive(:find).with('456789').twice
@asana.check_commit('fix #456789', 'pushed')
end
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 0f31c407c90..8ab72151a69 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -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
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 7a2a7a4ce9b..8b3d88640da 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -6,22 +6,22 @@ describe Commit do
describe '#title' do
it "returns no_commit_message when safe_message is blank" do
- commit.stub(:safe_message).and_return('')
- commit.title.should == "--no commit message"
+ allow(commit).to receive(:safe_message).and_return('')
+ expect(commit.title).to eq("--no commit message")
end
it "truncates a message without a newline at 80 characters" do
message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.'
- commit.stub(:safe_message).and_return(message)
- commit.title.should == "#{message[0..79]}&hellip;"
+ allow(commit).to receive(:safe_message).and_return(message)
+ expect(commit.title).to eq("#{message[0..79]}&hellip;")
end
it "truncates a message with a newline before 80 characters at the newline" do
message = commit.safe_message.split(" ").first
- commit.stub(:safe_message).and_return(message + "\n" + message)
- commit.title.should == message
+ allow(commit).to receive(:safe_message).and_return(message + "\n" + message)
+ expect(commit.title).to eq(message)
end
it "does not truncates a message with a newline after 80 but less 100 characters" do
@@ -30,25 +30,25 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis
Vivamus egestas lacinia lacus, sed rutrum mauris.
eos
- commit.stub(:safe_message).and_return(message)
- commit.title.should == message.split("\n").first
+ allow(commit).to receive(:safe_message).and_return(message)
+ expect(commit.title).to eq(message.split("\n").first)
end
end
describe "delegation" do
subject { commit }
- it { should respond_to(:message) }
- it { should respond_to(:authored_date) }
- it { should respond_to(:committed_date) }
- it { should respond_to(:committer_email) }
- it { should respond_to(:author_email) }
- it { should respond_to(:parents) }
- it { should respond_to(:date) }
- it { should respond_to(:diffs) }
- it { should respond_to(:tree) }
- it { should respond_to(:id) }
- it { should respond_to(:to_patch) }
+ it { is_expected.to respond_to(:message) }
+ it { is_expected.to respond_to(:authored_date) }
+ it { is_expected.to respond_to(:committed_date) }
+ it { is_expected.to respond_to(:committer_email) }
+ it { is_expected.to respond_to(:author_email) }
+ it { is_expected.to respond_to(:parents) }
+ it { is_expected.to respond_to(:date) }
+ it { is_expected.to respond_to(:diffs) }
+ it { is_expected.to respond_to(:tree) }
+ it { is_expected.to respond_to(:id) }
+ it { is_expected.to respond_to(:to_patch) }
end
describe '#closes_issues' do
@@ -58,13 +58,13 @@ eos
it 'detects issues that this commit is marked as closing' do
commit.stub(safe_message: "Fixes ##{issue.iid}")
- commit.closes_issues(project).should == [issue]
+ expect(commit.closes_issues(project)).to eq([issue])
end
it 'does not detect issues from other projects' do
ext_ref = "#{other_project.path_with_namespace}##{other_issue.iid}"
commit.stub(safe_message: "Fixes #{ext_ref}")
- commit.closes_issues(project).should be_empty
+ expect(commit.closes_issues(project)).to be_empty
end
end
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 9cbc8990676..557c71b4d2c 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -4,63 +4,63 @@ describe Issue, "Issuable" do
let(:issue) { create(:issue) }
describe "Associations" do
- it { should belong_to(:project) }
- it { should belong_to(:author) }
- it { should belong_to(:assignee) }
- it { should have_many(:notes).dependent(:destroy) }
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:author) }
+ it { is_expected.to belong_to(:assignee) }
+ it { is_expected.to have_many(:notes).dependent(:destroy) }
end
describe "Validation" do
before { subject.stub(set_iid: false) }
- it { should validate_presence_of(:project) }
- it { should validate_presence_of(:iid) }
- it { should validate_presence_of(:author) }
- it { should validate_presence_of(:title) }
- it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) }
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:iid) }
+ it { is_expected.to validate_presence_of(:author) }
+ it { is_expected.to validate_presence_of(:title) }
+ it { is_expected.to ensure_length_of(:title).is_at_least(0).is_at_most(255) }
end
describe "Scope" do
- it { described_class.should respond_to(:opened) }
- it { described_class.should respond_to(:closed) }
- it { described_class.should respond_to(:assigned) }
+ it { expect(described_class).to respond_to(:opened) }
+ it { expect(described_class).to respond_to(:closed) }
+ it { expect(described_class).to respond_to(:assigned) }
end
describe ".search" do
let!(:searchable_issue) { create(:issue, title: "Searchable issue") }
it "matches by title" do
- described_class.search('able').should == [searchable_issue]
+ expect(described_class.search('able')).to eq([searchable_issue])
end
end
describe "#today?" do
it "returns true when created today" do
# Avoid timezone differences and just return exactly what we want
- Date.stub(:today).and_return(issue.created_at.to_date)
- issue.today?.should be_true
+ allow(Date).to receive(:today).and_return(issue.created_at.to_date)
+ expect(issue.today?).to be_truthy
end
it "returns false when not created today" do
- Date.stub(:today).and_return(Date.yesterday)
- issue.today?.should be_false
+ allow(Date).to receive(:today).and_return(Date.yesterday)
+ expect(issue.today?).to be_falsey
end
end
describe "#new?" do
it "returns true when created today and record hasn't been updated" do
- issue.stub(:today?).and_return(true)
- issue.new?.should be_true
+ allow(issue).to receive(:today?).and_return(true)
+ expect(issue.new?).to be_truthy
end
it "returns false when not created today" do
- issue.stub(:today?).and_return(false)
- issue.new?.should be_false
+ allow(issue).to receive(:today?).and_return(false)
+ expect(issue.new?).to be_falsey
end
it "returns false when record has been updated" do
- issue.stub(:today?).and_return(true)
+ allow(issue).to receive(:today?).and_return(true)
issue.touch
- issue.new?.should be_false
+ expect(issue.new?).to be_falsey
end
end
end
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb
index ca6f11b2a4d..eadb941a3fa 100644
--- a/spec/models/concerns/mentionable_spec.rb
+++ b/spec/models/concerns/mentionable_spec.rb
@@ -8,7 +8,7 @@ describe Issue, "Mentionable" do
subject { issue.mentioned_users }
- it { should include(user) }
- it { should_not include(user2) }
+ it { is_expected.to include(user) }
+ it { is_expected.not_to include(user2) }
end
end
diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb
index adbbbac875f..b32be8d7a7c 100644
--- a/spec/models/deploy_key_spec.rb
+++ b/spec/models/deploy_key_spec.rb
@@ -19,7 +19,7 @@ describe DeployKey do
let(:deploy_key) { create(:deploy_key, projects: [project]) }
describe "Associations" do
- it { should have_many(:deploy_keys_projects) }
- it { should have_many(:projects) }
+ it { is_expected.to have_many(:deploy_keys_projects) }
+ it { is_expected.to have_many(:projects) }
end
end
diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb
index 3e0e25ee39a..aacd9bf38bf 100644
--- a/spec/models/deploy_keys_project_spec.rb
+++ b/spec/models/deploy_keys_project_spec.rb
@@ -13,12 +13,12 @@ require 'spec_helper'
describe DeployKeysProject do
describe "Associations" do
- it { should belong_to(:deploy_key) }
- it { should belong_to(:project) }
+ it { is_expected.to belong_to(:deploy_key) }
+ it { is_expected.to belong_to(:project) }
end
describe "Validation" do
- it { should validate_presence_of(:project_id) }
- it { should validate_presence_of(:deploy_key_id) }
+ it { is_expected.to validate_presence_of(:project_id) }
+ it { is_expected.to validate_presence_of(:deploy_key_id) }
end
end
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 204ae9da704..0f32f162a10 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -18,16 +18,16 @@ require 'spec_helper'
describe Event do
describe "Associations" do
- it { should belong_to(:project) }
- it { should belong_to(:target) }
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:target) }
end
describe "Respond to" do
- it { should respond_to(:author_name) }
- it { should respond_to(:author_email) }
- it { should respond_to(:issue_title) }
- it { should respond_to(:merge_request_title) }
- it { should respond_to(:commits) }
+ it { is_expected.to respond_to(:author_name) }
+ it { is_expected.to respond_to(:author_email) }
+ it { is_expected.to respond_to(:issue_title) }
+ it { is_expected.to respond_to(:merge_request_title) }
+ it { is_expected.to respond_to(:commits) }
end
describe "Push event" do
@@ -58,10 +58,10 @@ describe Event do
)
end
- it { @event.push?.should be_true }
- it { @event.proper?.should be_true }
- it { @event.tag?.should be_false }
- it { @event.branch_name.should == "master" }
- it { @event.author.should == @user }
+ it { expect(@event.push?).to be_truthy }
+ it { expect(@event.proper?).to be_truthy }
+ it { expect(@event.tag?).to be_falsey }
+ it { expect(@event.branch_name).to eq("master") }
+ it { expect(@event.author).to eq(@user) }
end
end
diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb
index 1845c6103f5..7d0ad44a92c 100644
--- a/spec/models/forked_project_link_spec.rb
+++ b/spec/models/forked_project_link_spec.rb
@@ -21,11 +21,11 @@ describe ForkedProjectLink, "add link on fork" do
end
it "project_to should know it is forked" do
- @project_to.forked?.should be_true
+ expect(@project_to.forked?).to be_truthy
end
it "project should know who it is forked from" do
- @project_to.forked_from_project.should == project_from
+ expect(@project_to.forked_from_project).to eq(project_from)
end
end
@@ -43,15 +43,15 @@ describe :forked_from_project do
it "project_to should know it is forked" do
- project_to.forked?.should be_true
+ expect(project_to.forked?).to be_truthy
end
it "project_from should not be forked" do
- project_from.forked?.should be_false
+ expect(project_from.forked?).to be_falsey
end
it "project_to.destroy should destroy fork_link" do
- forked_project_link.should_receive(:destroy)
+ expect(forked_project_link).to receive(:destroy)
project_to.destroy
end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 1d4ba8a2b85..9428224a64f 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -19,29 +19,29 @@ describe Group do
let!(:group) { create(:group) }
describe "Associations" do
- it { should have_many :projects }
- it { should have_many :group_members }
+ it { is_expected.to have_many :projects }
+ it { is_expected.to have_many :group_members }
end
- it { should validate_presence_of :name }
- it { should validate_uniqueness_of(:name) }
- it { should validate_presence_of :path }
- it { should validate_uniqueness_of(:path) }
- it { should_not validate_presence_of :owner }
+ it { is_expected.to validate_presence_of :name }
+ it { is_expected.to validate_uniqueness_of(:name) }
+ it { is_expected.to validate_presence_of :path }
+ it { is_expected.to validate_uniqueness_of(:path) }
+ it { is_expected.not_to validate_presence_of :owner }
describe :users do
- it { group.users.should == group.owners }
+ it { expect(group.users).to eq(group.owners) }
end
describe :human_name do
- it { group.human_name.should == group.name }
+ it { expect(group.human_name).to eq(group.name) }
end
describe :add_users do
let(:user) { create(:user) }
before { group.add_user(user, GroupMember::MASTER) }
- it { group.group_members.masters.map(&:user).should include(user) }
+ it { expect(group.group_members.masters.map(&:user)).to include(user) }
end
describe :add_users do
@@ -49,10 +49,10 @@ describe Group do
before { group.add_users([user.id], GroupMember::GUEST) }
it "should update the group permission" do
- group.group_members.guests.map(&:user).should include(user)
+ expect(group.group_members.guests.map(&:user)).to include(user)
group.add_users([user.id], GroupMember::DEVELOPER)
- group.group_members.developers.map(&:user).should include(user)
- group.group_members.guests.map(&:user).should_not include(user)
+ expect(group.group_members.developers.map(&:user)).to include(user)
+ expect(group.group_members.guests.map(&:user)).not_to include(user)
end
end
@@ -62,12 +62,12 @@ describe Group do
it "should be true if avatar is image" do
group.update_attribute(:avatar, 'uploads/avatar.png')
- group.avatar_type.should be_true
+ expect(group.avatar_type).to be_truthy
end
it "should be false if avatar is html page" do
group.update_attribute(:avatar, 'uploads/avatar.html')
- group.avatar_type.should == ["only images allowed"]
+ expect(group.avatar_type).to eq(["only images allowed"])
end
end
end
diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb
index 6ec82438dfe..96bf74d45da 100644
--- a/spec/models/hooks/service_hook_spec.rb
+++ b/spec/models/hooks/service_hook_spec.rb
@@ -19,6 +19,6 @@ require "spec_helper"
describe ServiceHook do
describe "Associations" do
- it { should belong_to :service }
+ it { is_expected.to belong_to :service }
end
end
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb
index 8deb732de9c..810b311a40b 100644
--- a/spec/models/hooks/system_hook_spec.rb
+++ b/spec/models/hooks/system_hook_spec.rb
@@ -26,32 +26,32 @@ describe SystemHook do
it "project_create hook" do
Projects::CreateService.new(create(:user), name: 'empty').execute
- WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_create/).once
end
it "project_destroy hook" do
user = create(:user)
project = create(:empty_project, namespace: user.namespace)
Projects::DestroyService.new(project, user, {}).execute
- WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /project_destroy/).once
end
it "user_create hook" do
create(:user)
- WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_create/).once
end
it "user_destroy hook" do
user = create(:user)
user.destroy
- WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_destroy/).once
end
it "project_create hook" do
user = create(:user)
project = create(:project)
project.team << [user, :master]
- WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once
end
it "project_destroy hook" do
@@ -59,12 +59,12 @@ describe SystemHook do
project = create(:project)
project.team << [user, :master]
project.project_members.destroy_all
- WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once
end
it 'group create hook' do
create(:group)
- WebMock.should have_requested(:post, @system_hook.url).with(
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /group_create/
).once
end
@@ -72,7 +72,7 @@ describe SystemHook do
it 'group destroy hook' do
group = create(:group)
group.destroy
- WebMock.should have_requested(:post, @system_hook.url).with(
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /group_destroy/
).once
end
@@ -81,7 +81,7 @@ describe SystemHook do
group = create(:group)
user = create(:user)
group.add_user(user, Gitlab::Access::MASTER)
- WebMock.should have_requested(:post, @system_hook.url).with(
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_add_to_group/
).once
end
@@ -91,7 +91,7 @@ describe SystemHook do
user = create(:user)
group.add_user(user, Gitlab::Access::MASTER)
group.group_members.destroy_all
- WebMock.should have_requested(:post, @system_hook.url).with(
+ expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_remove_from_group/
).once
end
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index e9c04ee89cb..67ec9193ad7 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -19,25 +19,25 @@ require 'spec_helper'
describe ProjectHook do
describe "Associations" do
- it { should belong_to :project }
+ it { is_expected.to belong_to :project }
end
describe "Mass assignment" do
end
describe "Validations" do
- it { should validate_presence_of(:url) }
+ it { is_expected.to validate_presence_of(:url) }
context "url format" do
- it { should allow_value("http://example.com").for(:url) }
- it { should allow_value("https://excample.com").for(:url) }
- it { should allow_value("http://test.com/api").for(:url) }
- it { should allow_value("http://test.com/api?key=abc").for(:url) }
- it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) }
+ it { is_expected.to allow_value("http://example.com").for(:url) }
+ it { is_expected.to allow_value("https://excample.com").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
- it { should_not allow_value("example.com").for(:url) }
- it { should_not allow_value("ftp://example.com").for(:url) }
- it { should_not allow_value("herp-and-derp").for(:url) }
+ it { is_expected.not_to allow_value("example.com").for(:url) }
+ it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
+ it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
end
end
@@ -53,22 +53,22 @@ describe ProjectHook do
it "POSTs to the web hook URL" do
@project_hook.execute(@data)
- WebMock.should have_requested(:post, @project_hook.url).once
+ expect(WebMock).to have_requested(:post, @project_hook.url).once
end
it "POSTs the data as JSON" do
json = @data.to_json
@project_hook.execute(@data)
- WebMock.should have_requested(:post, @project_hook.url).with(body: json).once
+ expect(WebMock).to have_requested(:post, @project_hook.url).with(body: json).once
end
it "catches exceptions" do
- WebHook.should_receive(:post).and_raise("Some HTTP Post error")
+ expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
- lambda {
+ expect {
@project_hook.execute(@data)
- }.should raise_error
+ }.to raise_error
end
end
end
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 6b6efe832e5..087e40c3d84 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -21,14 +21,14 @@ require 'spec_helper'
describe Issue do
describe "Associations" do
- it { should belong_to(:milestone) }
+ it { is_expected.to belong_to(:milestone) }
end
describe "Mass assignment" do
end
describe 'modules' do
- it { should include_module(Issuable) }
+ it { is_expected.to include_module(Issuable) }
end
subject { create(:issue) }
@@ -36,10 +36,10 @@ describe Issue do
describe '#is_being_reassigned?' do
it 'returns true if the issue assignee has changed' do
subject.assignee = create(:user)
- subject.is_being_reassigned?.should be_true
+ expect(subject.is_being_reassigned?).to be_truthy
end
it 'returns false if the issue assignee has not changed' do
- subject.is_being_reassigned?.should be_false
+ expect(subject.is_being_reassigned?).to be_falsey
end
end
@@ -51,7 +51,7 @@ describe Issue do
issue = create :issue, assignee: user
end
- Issue.open_for(user).count.should eq 2
+ expect(Issue.open_for(user).count).to eq 2
end
end
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 95c0aed0ffe..a212b95a7d6 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -16,67 +16,67 @@ require 'spec_helper'
describe Key do
describe "Associations" do
- it { should belong_to(:user) }
+ it { is_expected.to belong_to(:user) }
end
describe "Mass assignment" do
end
describe "Validation" do
- it { should validate_presence_of(:title) }
- it { should validate_presence_of(:key) }
- it { should ensure_length_of(:title).is_within(0..255) }
- it { should ensure_length_of(:key).is_within(0..5000) }
+ it { is_expected.to validate_presence_of(:title) }
+ it { is_expected.to validate_presence_of(:key) }
+ it { is_expected.to ensure_length_of(:title).is_within(0..255) }
+ it { is_expected.to ensure_length_of(:key).is_within(0..5000) }
end
describe "Methods" do
- it { should respond_to :projects }
+ it { is_expected.to respond_to :projects }
end
context "validation of uniqueness" do
let(:user) { create(:user) }
it "accepts the key once" do
- build(:key, user: user).should be_valid
+ expect(build(:key, user: user)).to be_valid
end
it "does not accept the exact same key twice" do
create(:key, user: user)
- build(:key, user: user).should_not be_valid
+ expect(build(:key, user: user)).not_to be_valid
end
it "does not accept a duplicate key with a different comment" do
create(:key, user: user)
duplicate = build(:key, user: user)
duplicate.key << ' extra comment'
- duplicate.should_not be_valid
+ expect(duplicate).not_to be_valid
end
end
context "validate it is a fingerprintable key" do
it "accepts the fingerprintable key" do
- build(:key).should be_valid
+ expect(build(:key)).to be_valid
end
it "rejects the unfingerprintable key (contains space in middle)" do
- build(:key_with_a_space_in_the_middle).should_not be_valid
+ expect(build(:key_with_a_space_in_the_middle)).not_to be_valid
end
it "rejects the unfingerprintable key (not a key)" do
- build(:invalid_key).should_not be_valid
+ expect(build(:invalid_key)).not_to be_valid
end
end
context 'callbacks' do
it 'should add new key to authorized_file' do
@key = build(:personal_key, id: 7)
- GitlabShellWorker.should_receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
+ expect(GitlabShellWorker).to receive(:perform_async).with(:add_key, @key.shell_id, @key.key)
@key.save
end
it 'should remove key from authorized_file' do
@key = create(:personal_key)
- GitlabShellWorker.should_receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
+ expect(GitlabShellWorker).to receive(:perform_async).with(:remove_key, @key.shell_id, @key.key)
@key.destroy
end
end
diff --git a/spec/models/label_link_spec.rb b/spec/models/label_link_spec.rb
index 0db60432ad3..8c240826582 100644
--- a/spec/models/label_link_spec.rb
+++ b/spec/models/label_link_spec.rb
@@ -14,8 +14,8 @@ require 'spec_helper'
describe LabelLink do
let(:label) { create(:label_link) }
- it { label.should be_valid }
+ it { expect(label).to be_valid }
- it { should belong_to(:label) }
- it { should belong_to(:target) }
+ it { is_expected.to belong_to(:label) }
+ it { is_expected.to belong_to(:target) }
end
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 31634648f04..8644ac46605 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -14,30 +14,30 @@ require 'spec_helper'
describe Label do
let(:label) { create(:label) }
- it { label.should be_valid }
+ it { expect(label).to be_valid }
- it { should belong_to(:project) }
+ it { is_expected.to belong_to(:project) }
describe 'Validation' do
it 'should validate color code' do
- build(:label, color: 'G-ITLAB').should_not be_valid
- build(:label, color: 'AABBCC').should_not be_valid
- build(:label, color: '#AABBCCEE').should_not be_valid
- build(:label, color: '#GGHHII').should_not be_valid
- build(:label, color: '#').should_not be_valid
- build(:label, color: '').should_not be_valid
+ expect(build(:label, color: 'G-ITLAB')).not_to be_valid
+ expect(build(:label, color: 'AABBCC')).not_to be_valid
+ expect(build(:label, color: '#AABBCCEE')).not_to be_valid
+ expect(build(:label, color: '#GGHHII')).not_to be_valid
+ expect(build(:label, color: '#')).not_to be_valid
+ expect(build(:label, color: '')).not_to be_valid
- build(:label, color: '#AABBCC').should be_valid
+ expect(build(:label, color: '#AABBCC')).to be_valid
end
it 'should validate title' do
- build(:label, title: 'G,ITLAB').should_not be_valid
- build(:label, title: 'G?ITLAB').should_not be_valid
- build(:label, title: 'G&ITLAB').should_not be_valid
- build(:label, title: '').should_not be_valid
+ expect(build(:label, title: 'G,ITLAB')).not_to be_valid
+ expect(build(:label, title: 'G?ITLAB')).not_to be_valid
+ expect(build(:label, title: 'G&ITLAB')).not_to be_valid
+ expect(build(:label, title: '')).not_to be_valid
- build(:label, title: 'GITLAB').should be_valid
- build(:label, title: 'gitlab').should be_valid
+ expect(build(:label, title: 'GITLAB')).to be_valid
+ expect(build(:label, title: 'gitlab')).to be_valid
end
end
end
diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb
index 38657de6793..e04f1741b24 100644
--- a/spec/models/members/group_member_spec.rb
+++ b/spec/models/members/group_member_spec.rb
@@ -21,7 +21,7 @@ describe GroupMember do
it "should send email to user" do
membership = build(:group_member)
membership.stub(notification_service: double('NotificationService').as_null_object)
- membership.should_receive(:notification_service)
+ expect(membership).to receive(:notification_service)
membership.save
end
end
@@ -33,12 +33,12 @@ describe GroupMember do
end
it "should send email to user" do
- @membership.should_receive(:notification_service)
+ expect(@membership).to receive(:notification_service)
@membership.update_attribute(:access_level, GroupMember::MASTER)
end
it "does not send an email when the access level has not changed" do
- @membership.should_not_receive(:notification_service)
+ expect(@membership).not_to receive(:notification_service)
@membership.update_attribute(:access_level, GroupMember::OWNER)
end
end
diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb
index 9b5f89b6d7d..521721f3577 100644
--- a/spec/models/members/project_member_spec.rb
+++ b/spec/models/members/project_member_spec.rb
@@ -33,19 +33,19 @@ describe ProjectMember do
@status = @project_2.team.import(@project_1)
end
- it { @status.should be_true }
+ it { expect(@status).to be_truthy }
describe 'project 2 should get user 1 as developer. user_2 should not be changed' do
- it { @project_2.users.should include(@user_1) }
- it { @project_2.users.should include(@user_2) }
+ it { expect(@project_2.users).to include(@user_1) }
+ it { expect(@project_2.users).to include(@user_2) }
- it { @abilities.allowed?(@user_1, :write_project, @project_2).should be_true }
- it { @abilities.allowed?(@user_2, :read_project, @project_2).should be_true }
+ it { expect(@abilities.allowed?(@user_1, :write_project, @project_2)).to be_truthy }
+ it { expect(@abilities.allowed?(@user_2, :read_project, @project_2)).to be_truthy }
end
describe 'project 1 should not be changed' do
- it { @project_1.users.should include(@user_1) }
- it { @project_1.users.should_not include(@user_2) }
+ it { expect(@project_1.users).to include(@user_1) }
+ it { expect(@project_1.users).not_to include(@user_2) }
end
end
@@ -64,12 +64,12 @@ describe ProjectMember do
)
end
- it { @project_1.users.should include(@user_1) }
- it { @project_1.users.should include(@user_2) }
+ it { expect(@project_1.users).to include(@user_1) }
+ it { expect(@project_1.users).to include(@user_2) }
- it { @project_2.users.should include(@user_1) }
- it { @project_2.users.should include(@user_2) }
+ it { expect(@project_2.users).to include(@user_1) }
+ it { expect(@project_2.users).to include(@user_2) }
end
describe :truncate_teams do
@@ -86,7 +86,7 @@ describe ProjectMember do
ProjectMember.truncate_teams([@project_1.id, @project_2.id])
end
- it { @project_1.users.should be_empty }
- it { @project_2.users.should be_empty }
+ it { expect(@project_1.users).to be_empty }
+ it { expect(@project_2.users).to be_empty }
end
end
diff --git a/spec/models/members_spec.rb b/spec/models/members_spec.rb
index cea653ec285..dfd3f7feb6b 100644
--- a/spec/models/members_spec.rb
+++ b/spec/models/members_spec.rb
@@ -2,19 +2,19 @@ require 'spec_helper'
describe Member do
describe "Associations" do
- it { should belong_to(:user) }
+ it { is_expected.to belong_to(:user) }
end
describe "Validation" do
subject { Member.new(access_level: Member::GUEST) }
- it { should validate_presence_of(:user) }
- it { should validate_presence_of(:source) }
- it { should validate_inclusion_of(:access_level).in_array(Gitlab::Access.values) }
+ it { is_expected.to validate_presence_of(:user) }
+ it { is_expected.to validate_presence_of(:source) }
+ it { is_expected.to validate_inclusion_of(:access_level).in_array(Gitlab::Access.values) }
end
describe "Delegate methods" do
- it { should respond_to(:user_name) }
- it { should respond_to(:user_email) }
+ it { is_expected.to respond_to(:user_name) }
+ it { is_expected.to respond_to(:user_email) }
end
end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 9585cf09768..d40503d791c 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -25,35 +25,35 @@ require 'spec_helper'
describe MergeRequest do
describe "Validation" do
- it { should validate_presence_of(:target_branch) }
- it { should validate_presence_of(:source_branch) }
+ it { is_expected.to validate_presence_of(:target_branch) }
+ it { is_expected.to validate_presence_of(:source_branch) }
end
describe "Mass assignment" do
end
describe "Respond to" do
- it { should respond_to(:unchecked?) }
- it { should respond_to(:can_be_merged?) }
- it { should respond_to(:cannot_be_merged?) }
+ it { is_expected.to respond_to(:unchecked?) }
+ it { is_expected.to respond_to(:can_be_merged?) }
+ it { is_expected.to respond_to(:cannot_be_merged?) }
end
describe 'modules' do
- it { should include_module(Issuable) }
+ it { is_expected.to include_module(Issuable) }
end
describe "#mr_and_commit_notes" do
let!(:merge_request) { create(:merge_request) }
before do
- merge_request.stub(:commits) { [merge_request.source_project.repository.commit] }
+ allow(merge_request).to receive(:commits) { [merge_request.source_project.repository.commit] }
create(:note, commit_id: merge_request.commits.first.id, noteable_type: 'Commit', project: merge_request.project)
create(:note, noteable: merge_request, project: merge_request.project)
end
it "should include notes for commits" do
- merge_request.commits.should_not be_empty
- merge_request.mr_and_commit_notes.count.should == 2
+ expect(merge_request.commits).not_to be_empty
+ expect(merge_request.mr_and_commit_notes.count).to eq(2)
end
end
@@ -62,10 +62,10 @@ describe MergeRequest do
describe '#is_being_reassigned?' do
it 'returns true if the merge_request assignee has changed' do
subject.assignee = create(:user)
- subject.is_being_reassigned?.should be_true
+ expect(subject.is_being_reassigned?).to be_truthy
end
it 'returns false if the merge request assignee has not changed' do
- subject.is_being_reassigned?.should be_false
+ expect(subject.is_being_reassigned?).to be_falsey
end
end
@@ -74,11 +74,11 @@ describe MergeRequest do
subject.source_project = create(:project, namespace: create(:group))
subject.target_project = create(:project, namespace: create(:group))
- subject.for_fork?.should be_true
+ expect(subject.for_fork?).to be_truthy
end
it 'returns false if is not for a fork' do
- subject.for_fork?.should be_false
+ expect(subject.for_fork?).to be_falsey
end
end
@@ -96,14 +96,14 @@ describe MergeRequest do
it 'accesses the set of issues that will be closed on acceptance' do
subject.project.stub(default_branch: subject.target_branch)
- subject.closes_issues.should == [issue0, issue1].sort_by(&:id)
+ expect(subject.closes_issues).to eq([issue0, issue1].sort_by(&:id))
end
it 'only lists issues as to be closed if it targets the default branch' do
subject.project.stub(default_branch: 'master')
subject.target_branch = 'something-else'
- subject.closes_issues.should be_empty
+ expect(subject.closes_issues).to be_empty
end
it 'detects issues mentioned in the description' do
@@ -111,7 +111,7 @@ describe MergeRequest do
subject.description = "Closes ##{issue2.iid}"
subject.project.stub(default_branch: subject.target_branch)
- subject.closes_issues.should include(issue2)
+ expect(subject.closes_issues).to include(issue2)
end
end
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index a3071c3251a..45171e1bf64 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -17,8 +17,8 @@ require 'spec_helper'
describe Milestone do
describe "Associations" do
- it { should belong_to(:project) }
- it { should have_many(:issues) }
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to have_many(:issues) }
end
describe "Mass assignment" do
@@ -26,8 +26,8 @@ describe Milestone do
describe "Validation" do
before { subject.stub(set_iid: false) }
- it { should validate_presence_of(:title) }
- it { should validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:title) }
+ it { is_expected.to validate_presence_of(:project) }
end
let(:milestone) { create(:milestone) }
@@ -36,30 +36,30 @@ describe Milestone do
describe "#percent_complete" do
it "should not count open issues" do
milestone.issues << issue
- milestone.percent_complete.should == 0
+ expect(milestone.percent_complete).to eq(0)
end
it "should count closed issues" do
issue.close
milestone.issues << issue
- milestone.percent_complete.should == 100
+ expect(milestone.percent_complete).to eq(100)
end
it "should recover from dividing by zero" do
- milestone.issues.should_receive(:count).and_return(0)
- milestone.percent_complete.should == 100
+ expect(milestone.issues).to receive(:count).and_return(0)
+ expect(milestone.percent_complete).to eq(100)
end
end
describe "#expires_at" do
it "should be nil when due_date is unset" do
milestone.update_attributes(due_date: nil)
- milestone.expires_at.should be_nil
+ expect(milestone.expires_at).to be_nil
end
it "should not be nil when due_date is set" do
milestone.update_attributes(due_date: Date.tomorrow)
- milestone.expires_at.should be_present
+ expect(milestone.expires_at).to be_present
end
end
@@ -69,7 +69,7 @@ describe Milestone do
milestone.stub(due_date: Date.today.prev_year)
end
- it { milestone.expired?.should be_true }
+ it { expect(milestone.expired?).to be_truthy }
end
context "not expired" do
@@ -77,7 +77,7 @@ describe Milestone do
milestone.stub(due_date: Date.today.next_year)
end
- it { milestone.expired?.should be_false }
+ it { expect(milestone.expired?).to be_falsey }
end
end
@@ -89,7 +89,7 @@ describe Milestone do
)
end
- it { milestone.percent_complete.should == 75 }
+ it { expect(milestone.percent_complete).to eq(75) }
end
describe :items_count do
@@ -99,14 +99,14 @@ describe Milestone do
milestone.merge_requests << create(:merge_request)
end
- it { milestone.closed_items_count.should == 1 }
- it { milestone.open_items_count.should == 2 }
- it { milestone.total_items_count.should == 3 }
- it { milestone.is_empty?.should be_false }
+ it { expect(milestone.closed_items_count).to eq(1) }
+ it { expect(milestone.open_items_count).to eq(2) }
+ it { expect(milestone.total_items_count).to eq(3) }
+ it { expect(milestone.is_empty?).to be_falsey }
end
describe :can_be_closed? do
- it { milestone.can_be_closed?.should be_true }
+ it { expect(milestone.can_be_closed?).to be_truthy }
end
describe :is_empty? do
@@ -116,7 +116,7 @@ describe Milestone do
end
it 'Should return total count of issues and merge requests assigned to milestone' do
- milestone.total_items_count.should eq 2
+ expect(milestone.total_items_count).to eq 2
end
end
@@ -129,14 +129,14 @@ describe Milestone do
end
it 'should be true if milestone active and all nested issues closed' do
- milestone.can_be_closed?.should be_true
+ expect(milestone.can_be_closed?).to be_truthy
end
it 'should be false if milestone active and not all nested issues closed' do
issue.milestone = milestone
issue.save
- milestone.can_be_closed?.should be_false
+ expect(milestone.can_be_closed?).to be_falsey
end
end
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index 3562ebed1ff..4e268f8d8fa 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -18,29 +18,29 @@ require 'spec_helper'
describe Namespace do
let!(:namespace) { create(:namespace) }
- it { should have_many :projects }
- it { should validate_presence_of :name }
- it { should validate_uniqueness_of(:name) }
- it { should validate_presence_of :path }
- it { should validate_uniqueness_of(:path) }
- it { should validate_presence_of :owner }
+ it { is_expected.to have_many :projects }
+ it { is_expected.to validate_presence_of :name }
+ it { is_expected.to validate_uniqueness_of(:name) }
+ it { is_expected.to validate_presence_of :path }
+ it { is_expected.to validate_uniqueness_of(:path) }
+ it { is_expected.to validate_presence_of :owner }
describe "Mass assignment" do
end
describe "Respond to" do
- it { should respond_to(:human_name) }
- it { should respond_to(:to_param) }
+ it { is_expected.to respond_to(:human_name) }
+ it { is_expected.to respond_to(:to_param) }
end
- it { Namespace.global_id.should == 'GLN' }
+ it { expect(Namespace.global_id).to eq('GLN') }
describe :to_param do
- it { namespace.to_param.should == namespace.path }
+ it { expect(namespace.to_param).to eq(namespace.path) }
end
describe :human_name do
- it { namespace.human_name.should == namespace.owner_name }
+ it { expect(namespace.human_name).to eq(namespace.owner_name) }
end
describe :search do
@@ -48,8 +48,8 @@ describe Namespace do
@namespace = create :namespace
end
- it { Namespace.search(@namespace.path).should == [@namespace] }
- it { Namespace.search('unknown').should == [] }
+ it { expect(Namespace.search(@namespace.path)).to eq([@namespace]) }
+ it { expect(Namespace.search('unknown')).to eq([]) }
end
describe :move_dir do
@@ -66,13 +66,13 @@ describe Namespace do
new_path = @namespace.path + "_new"
@namespace.stub(path_was: @namespace.path)
@namespace.stub(path: new_path)
- @namespace.move_dir.should be_true
+ expect(@namespace.move_dir).to be_truthy
end
end
describe :rm_dir do
it "should remove dir" do
- namespace.rm_dir.should be_true
+ expect(namespace.rm_dir).to be_truthy
end
end
end
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 6ab7162c15c..17cb439c90e 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -21,17 +21,17 @@ require 'spec_helper'
describe Note do
describe "Associations" do
- it { should belong_to(:project) }
- it { should belong_to(:noteable) }
- it { should belong_to(:author).class_name('User') }
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to belong_to(:noteable) }
+ it { is_expected.to belong_to(:author).class_name('User') }
end
describe "Mass assignment" do
end
describe "Validation" do
- it { should validate_presence_of(:note) }
- it { should validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:note) }
+ it { is_expected.to validate_presence_of(:project) }
end
describe "Voting score" do
@@ -39,44 +39,44 @@ describe Note do
it "recognizes a neutral note" do
note = create(:votable_note, note: "This is not a +1 note")
- note.should_not be_upvote
- note.should_not be_downvote
+ expect(note).not_to be_upvote
+ expect(note).not_to be_downvote
end
it "recognizes a neutral emoji note" do
note = build(:votable_note, note: "I would :+1: this, but I don't want to")
- note.should_not be_upvote
- note.should_not be_downvote
+ expect(note).not_to be_upvote
+ expect(note).not_to be_downvote
end
it "recognizes a +1 note" do
note = create(:votable_note, note: "+1 for this")
- note.should be_upvote
+ expect(note).to be_upvote
end
it "recognizes a +1 emoji as a vote" do
note = build(:votable_note, note: ":+1: for this")
- note.should be_upvote
+ expect(note).to be_upvote
end
it "recognizes a thumbsup emoji as a vote" do
note = build(:votable_note, note: ":thumbsup: for this")
- note.should be_upvote
+ expect(note).to be_upvote
end
it "recognizes a -1 note" do
note = create(:votable_note, note: "-1 for this")
- note.should be_downvote
+ expect(note).to be_downvote
end
it "recognizes a -1 emoji as a vote" do
note = build(:votable_note, note: ":-1: for this")
- note.should be_downvote
+ expect(note).to be_downvote
end
it "recognizes a thumbsdown emoji as a vote" do
note = build(:votable_note, note: ":thumbsdown: for this")
- note.should be_downvote
+ expect(note).to be_downvote
end
end
@@ -87,22 +87,22 @@ describe Note do
let!(:commit) { note.noteable }
it "should be accessible through #noteable" do
- note.commit_id.should == commit.id
- note.noteable.should be_a(Commit)
- note.noteable.should == commit
+ expect(note.commit_id).to eq(commit.id)
+ expect(note.noteable).to be_a(Commit)
+ expect(note.noteable).to eq(commit)
end
it "should save a valid note" do
- note.commit_id.should == commit.id
+ expect(note.commit_id).to eq(commit.id)
note.noteable == commit
end
it "should be recognized by #for_commit?" do
- note.should be_for_commit
+ expect(note).to be_for_commit
end
it "should not be votable" do
- note.should_not be_votable
+ expect(note).not_to be_votable
end
end
@@ -111,20 +111,20 @@ describe Note do
let!(:commit) { note.noteable }
it "should save a valid note" do
- note.commit_id.should == commit.id
- note.noteable.id.should == commit.id
+ expect(note.commit_id).to eq(commit.id)
+ expect(note.noteable.id).to eq(commit.id)
end
it "should be recognized by #for_diff_line?" do
- note.should be_for_diff_line
+ expect(note).to be_for_diff_line
end
it "should be recognized by #for_commit_diff_line?" do
- note.should be_for_commit_diff_line
+ expect(note).to be_for_commit_diff_line
end
it "should not be votable" do
- note.should_not be_votable
+ expect(note).not_to be_votable
end
end
@@ -132,7 +132,7 @@ describe Note do
let!(:note) { create(:note_on_issue, note: "+1 from me") }
it "should not be votable" do
- note.should be_votable
+ expect(note).to be_votable
end
end
@@ -140,7 +140,7 @@ describe Note do
let!(:note) { create(:note_on_merge_request, note: "+1 from me") }
it "should be votable" do
- note.should be_votable
+ expect(note).to be_votable
end
end
@@ -148,7 +148,7 @@ describe Note do
let!(:note) { create(:note_on_merge_request_diff, note: "+1 from me") }
it "should not be votable" do
- note.should_not be_votable
+ expect(note).not_to be_votable
end
end
@@ -161,20 +161,35 @@ describe Note do
subject { Note.create_status_change_note(thing, project, author, status, nil) }
it 'creates and saves a Note' do
- should be_a Note
- subject.id.should_not be_nil
+ is_expected.to be_a Note
+ expect(subject.id).not_to be_nil
end
- its(:noteable) { should == thing }
- its(:project) { should == thing.project }
- its(:author) { should == author }
- its(:note) { should =~ /Status changed to #{status}/ }
+ describe '#noteable' do
+ subject { super().noteable }
+ it { is_expected.to eq(thing) }
+ end
+
+ describe '#project' do
+ subject { super().project }
+ it { is_expected.to eq(thing.project) }
+ end
+
+ describe '#author' do
+ subject { super().author }
+ it { is_expected.to eq(author) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to match(/Status changed to #{status}/) }
+ end
it 'appends a back-reference if a closing mentionable is supplied' do
commit = double('commit', gfm_reference: 'commit 123456')
n = Note.create_status_change_note(thing, project, author, status, commit)
- n.note.should =~ /Status changed to #{status} by commit 123456/
+ expect(n.note).to match(/Status changed to #{status} by commit 123456/)
end
end
@@ -187,19 +202,41 @@ describe Note do
subject { Note.create_assignee_change_note(thing, project, author, assignee) }
context 'creates and saves a Note' do
- it { should be_a Note }
- its(:id) { should_not be_nil }
+ it { is_expected.to be_a Note }
+
+ describe '#id' do
+ subject { super().id }
+ it { is_expected.not_to be_nil }
+ end
+ end
+
+ describe '#noteable' do
+ subject { super().noteable }
+ it { is_expected.to eq(thing) }
end
- its(:noteable) { should == thing }
- its(:project) { should == thing.project }
- its(:author) { should == author }
- its(:note) { should =~ /Reassigned to @#{assignee.username}/ }
+ describe '#project' do
+ subject { super().project }
+ it { is_expected.to eq(thing.project) }
+ end
+
+ describe '#author' do
+ subject { super().author }
+ it { is_expected.to eq(author) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to match(/Reassigned to @#{assignee.username}/) }
+ end
context 'assignee is removed' do
let(:assignee) { nil }
- its(:note) { should =~ /Assignee removed/ }
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to match(/Assignee removed/) }
+ end
end
end
@@ -216,64 +253,144 @@ describe Note do
context 'issue from a merge request' do
subject { Note.create_cross_reference_note(issue, mergereq, author, project) }
- it { should be_valid }
- its(:noteable) { should == issue }
- its(:project) { should == issue.project }
- its(:author) { should == author }
- its(:note) { should == "_mentioned in merge request !#{mergereq.iid}_" }
+ it { is_expected.to be_valid }
+
+ describe '#noteable' do
+ subject { super().noteable }
+ it { is_expected.to eq(issue) }
+ end
+
+ describe '#project' do
+ subject { super().project }
+ it { is_expected.to eq(issue.project) }
+ end
+
+ describe '#author' do
+ subject { super().author }
+ it { is_expected.to eq(author) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to eq("_mentioned in merge request !#{mergereq.iid}_") }
+ end
end
context 'issue from a commit' do
subject { Note.create_cross_reference_note(issue, commit, author, project) }
- it { should be_valid }
- its(:noteable) { should == issue }
- its(:note) { should == "_mentioned in commit #{commit.sha}_" }
+ it { is_expected.to be_valid }
+
+ describe '#noteable' do
+ subject { super().noteable }
+ it { is_expected.to eq(issue) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to eq("_mentioned in commit #{commit.sha}_") }
+ end
end
context 'merge request from an issue' do
subject { Note.create_cross_reference_note(mergereq, issue, author, project) }
- it { should be_valid }
- its(:noteable) { should == mergereq }
- its(:project) { should == mergereq.project }
- its(:note) { should == "_mentioned in issue ##{issue.iid}_" }
+ it { is_expected.to be_valid }
+
+ describe '#noteable' do
+ subject { super().noteable }
+ it { is_expected.to eq(mergereq) }
+ end
+
+ describe '#project' do
+ subject { super().project }
+ it { is_expected.to eq(mergereq.project) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to eq("_mentioned in issue ##{issue.iid}_") }
+ end
end
context 'commit from a merge request' do
subject { Note.create_cross_reference_note(commit, mergereq, author, project) }
- it { should be_valid }
- its(:noteable) { should == commit }
- its(:project) { should == project }
- its(:note) { should == "_mentioned in merge request !#{mergereq.iid}_" }
+ it { is_expected.to be_valid }
+
+ describe '#noteable' do
+ subject { super().noteable }
+ it { is_expected.to eq(commit) }
+ end
+
+ describe '#project' do
+ subject { super().project }
+ it { is_expected.to eq(project) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to eq("_mentioned in merge request !#{mergereq.iid}_") }
+ end
end
context 'commit contained in a merge request' do
subject { Note.create_cross_reference_note(mergereq.commits.first, mergereq, author, project) }
- it { should be_nil }
+ it { is_expected.to be_nil }
end
context 'commit from issue' do
subject { Note.create_cross_reference_note(commit, issue, author, project) }
- it { should be_valid }
- its(:noteable_type) { should == "Commit" }
- its(:noteable_id) { should be_nil }
- its(:commit_id) { should == commit.id }
- its(:note) { should == "_mentioned in issue ##{issue.iid}_" }
+ it { is_expected.to be_valid }
+
+ describe '#noteable_type' do
+ subject { super().noteable_type }
+ it { is_expected.to eq("Commit") }
+ end
+
+ describe '#noteable_id' do
+ subject { super().noteable_id }
+ it { is_expected.to be_nil }
+ end
+
+ describe '#commit_id' do
+ subject { super().commit_id }
+ it { is_expected.to eq(commit.id) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to eq("_mentioned in issue ##{issue.iid}_") }
+ end
end
context 'commit from commit' do
let(:parent_commit) { commit.parents.first }
subject { Note.create_cross_reference_note(commit, parent_commit, author, project) }
- it { should be_valid }
- its(:noteable_type) { should == "Commit" }
- its(:noteable_id) { should be_nil }
- its(:commit_id) { should == commit.id }
- its(:note) { should == "_mentioned in commit #{parent_commit.id}_" }
+ it { is_expected.to be_valid }
+
+ describe '#noteable_type' do
+ subject { super().noteable_type }
+ it { is_expected.to eq("Commit") }
+ end
+
+ describe '#noteable_id' do
+ subject { super().noteable_id }
+ it { is_expected.to be_nil }
+ end
+
+ describe '#commit_id' do
+ subject { super().commit_id }
+ it { is_expected.to eq(commit.id) }
+ end
+
+ describe '#note' do
+ subject { super().note }
+ it { is_expected.to eq("_mentioned in commit #{parent_commit.id}_") }
+ end
end
end
@@ -289,11 +406,11 @@ describe Note do
end
it 'detects if a mentionable has already been mentioned' do
- Note.cross_reference_exists?(issue, commit0).should be_true
+ expect(Note.cross_reference_exists?(issue, commit0)).to be_truthy
end
it 'detects if a mentionable has not already been mentioned' do
- Note.cross_reference_exists?(issue, commit1).should be_false
+ expect(Note.cross_reference_exists?(issue, commit1)).to be_falsey
end
context 'commit on commit' do
@@ -301,8 +418,8 @@ describe Note do
Note.create_cross_reference_note(commit0, commit1, author, project)
end
- it { Note.cross_reference_exists?(commit0, commit1).should be_true }
- it { Note.cross_reference_exists?(commit1, commit0).should be_false }
+ it { expect(Note.cross_reference_exists?(commit0, commit1)).to be_truthy }
+ it { expect(Note.cross_reference_exists?(commit1, commit0)).to be_falsey }
end
end
@@ -315,22 +432,22 @@ describe Note do
it 'should recognize user-supplied notes as non-system' do
@note = create(:note_on_issue)
- @note.should_not be_system
+ expect(@note).not_to be_system
end
it 'should identify status-change notes as system notes' do
@note = Note.create_status_change_note(issue, project, author, 'closed', nil)
- @note.should be_system
+ expect(@note).to be_system
end
it 'should identify cross-reference notes as system notes' do
@note = Note.create_cross_reference_note(issue, other, author, project)
- @note.should be_system
+ expect(@note).to be_system
end
it 'should identify assignee-change notes as system notes' do
@note = Note.create_assignee_change_note(issue, project, author, assignee)
- @note.should be_system
+ expect(@note).to be_system
end
end
@@ -351,9 +468,9 @@ describe Note do
@p2.project_members.create(user: @u3, access_level: ProjectMember::GUEST)
end
- it { @abilities.allowed?(@u1, :read_note, @p1).should be_false }
- it { @abilities.allowed?(@u2, :read_note, @p1).should be_true }
- it { @abilities.allowed?(@u3, :read_note, @p1).should be_false }
+ it { expect(@abilities.allowed?(@u1, :read_note, @p1)).to be_falsey }
+ it { expect(@abilities.allowed?(@u2, :read_note, @p1)).to be_truthy }
+ it { expect(@abilities.allowed?(@u3, :read_note, @p1)).to be_falsey }
end
describe :write do
@@ -362,9 +479,9 @@ describe Note do
@p2.project_members.create(user: @u3, access_level: ProjectMember::DEVELOPER)
end
- it { @abilities.allowed?(@u1, :write_note, @p1).should be_false }
- it { @abilities.allowed?(@u2, :write_note, @p1).should be_true }
- it { @abilities.allowed?(@u3, :write_note, @p1).should be_false }
+ it { expect(@abilities.allowed?(@u1, :write_note, @p1)).to be_falsey }
+ it { expect(@abilities.allowed?(@u2, :write_note, @p1)).to be_truthy }
+ it { expect(@abilities.allowed?(@u3, :write_note, @p1)).to be_falsey }
end
describe :admin do
@@ -374,9 +491,9 @@ describe Note do
@p2.project_members.create(user: @u3, access_level: ProjectMember::MASTER)
end
- it { @abilities.allowed?(@u1, :admin_note, @p1).should be_false }
- it { @abilities.allowed?(@u2, :admin_note, @p1).should be_true }
- it { @abilities.allowed?(@u3, :admin_note, @p1).should be_false }
+ it { expect(@abilities.allowed?(@u1, :admin_note, @p1)).to be_falsey }
+ it { expect(@abilities.allowed?(@u2, :admin_note, @p1)).to be_truthy }
+ it { expect(@abilities.allowed?(@u3, :admin_note, @p1)).to be_falsey }
end
end
diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb
index 5c8d1e7438b..1ee19003543 100644
--- a/spec/models/project_security_spec.rb
+++ b/spec/models/project_security_spec.rb
@@ -23,7 +23,7 @@ describe Project do
describe "Non member rules" do
it "should deny for non-project users any actions" do
admin_actions.each do |action|
- @abilities.allowed?(@u1, action, @p1).should be_false
+ expect(@abilities.allowed?(@u1, action, @p1)).to be_falsey
end
end
end
@@ -35,7 +35,7 @@ describe Project do
it "should allow for project user any guest actions" do
guest_actions.each do |action|
- @abilities.allowed?(@u2, action, @p1).should be_true
+ expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy
end
end
end
@@ -47,7 +47,7 @@ describe Project do
it "should allow for project user any report actions" do
report_actions.each do |action|
- @abilities.allowed?(@u2, action, @p1).should be_true
+ expect(@abilities.allowed?(@u2, action, @p1)).to be_truthy
end
end
end
@@ -60,13 +60,13 @@ describe Project do
it "should deny for developer master-specific actions" do
[dev_actions - report_actions].each do |action|
- @abilities.allowed?(@u2, action, @p1).should be_false
+ expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
end
end
it "should allow for project user any dev actions" do
dev_actions.each do |action|
- @abilities.allowed?(@u3, action, @p1).should be_true
+ expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy
end
end
end
@@ -79,13 +79,13 @@ describe Project do
it "should deny for developer master-specific actions" do
[master_actions - dev_actions].each do |action|
- @abilities.allowed?(@u2, action, @p1).should be_false
+ expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
end
end
it "should allow for project user any master actions" do
master_actions.each do |action|
- @abilities.allowed?(@u3, action, @p1).should be_true
+ expect(@abilities.allowed?(@u3, action, @p1)).to be_truthy
end
end
end
@@ -98,13 +98,13 @@ describe Project do
it "should deny for masters admin-specific actions" do
[admin_actions - master_actions].each do |action|
- @abilities.allowed?(@u2, action, @p1).should be_false
+ expect(@abilities.allowed?(@u2, action, @p1)).to be_falsey
end
end
it "should allow for project owner any admin actions" do
admin_actions.each do |action|
- @abilities.allowed?(@u4, action, @p1).should be_true
+ expect(@abilities.allowed?(@u4, action, @p1)).to be_truthy
end
end
end
diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb
index 005dd41fea9..ee7f780c8f6 100644
--- a/spec/models/project_services/assembla_service_spec.rb
+++ b/spec/models/project_services/assembla_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe AssemblaService, models: true do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Execute" do
@@ -40,7 +40,7 @@ describe AssemblaService, models: true do
it "should call Assembla API" do
@assembla_service.execute(@sample_data)
- WebMock.should have_requested(:post, @api_url).with(
+ expect(WebMock).to have_requested(:post, @api_url).with(
body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
).once
end
diff --git a/spec/models/project_services/buildbox_service_spec.rb b/spec/models/project_services/buildbox_service_spec.rb
index 1d9ca51be16..050363e14c7 100644
--- a/spec/models/project_services/buildbox_service_spec.rb
+++ b/spec/models/project_services/buildbox_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe BuildboxService do
describe 'Associations' do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe 'commits methods' do
@@ -38,35 +38,39 @@ describe BuildboxService do
describe :webhook_url do
it 'returns the webhook url' do
- @service.webhook_url.should ==
+ expect(@service.webhook_url).to eq(
'https://webhook.buildbox.io/deliver/secret-sauce-webhook-token'
+ )
end
end
describe :commit_status_path do
it 'returns the correct status page' do
- @service.commit_status_path('2ab7834c').should ==
+ expect(@service.commit_status_path('2ab7834c')).to eq(
'https://gitlab.buildbox.io/status/secret-sauce-status-token.json?commit=2ab7834c'
+ )
end
end
describe :build_page do
it 'returns the correct build page' do
- @service.build_page('2ab7834c').should ==
+ expect(@service.build_page('2ab7834c')).to eq(
'https://buildbox.io/account-name/example-project/builds?commit=2ab7834c'
+ )
end
end
describe :builds_page do
it 'returns the correct path to the builds page' do
- @service.builds_path.should ==
+ expect(@service.builds_path).to eq(
'https://buildbox.io/account-name/example-project/builds?branch=default-brancho'
+ )
end
end
describe :status_img_path do
it 'returns the correct path to the status image' do
- @service.status_img_path.should == 'https://badge.buildbox.io/secret-sauce-status-token.svg'
+ expect(@service.status_img_path).to eq('https://badge.buildbox.io/secret-sauce-status-token.svg')
end
end
end
diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb
index ac156719b43..b34e36bc940 100644
--- a/spec/models/project_services/flowdock_service_spec.rb
+++ b/spec/models/project_services/flowdock_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe FlowdockService do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Execute" do
@@ -39,7 +39,7 @@ describe FlowdockService do
it "should call FlowDock API" do
@flowdock_service.execute(@sample_data)
- WebMock.should have_requested(:post, @api_url).with(
+ expect(WebMock).to have_requested(:post, @api_url).with(
body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
).once
end
diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb
index 2c560c11dac..fe5d62b2f53 100644
--- a/spec/models/project_services/gemnasium_service_spec.rb
+++ b/spec/models/project_services/gemnasium_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe GemnasiumService do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Execute" do
@@ -36,7 +36,7 @@ describe GemnasiumService do
@sample_data = Gitlab::PushDataBuilder.build_sample(project, user)
end
it "should call Gemnasium service" do
- Gemnasium::GitlabService.should_receive(:execute).with(an_instance_of(Hash)).once
+ expect(Gemnasium::GitlabService).to receive(:execute).with(an_instance_of(Hash)).once
@gemnasium_service.execute(@sample_data)
end
end
diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb
index 83277058fbb..0cd255f08ea 100644
--- a/spec/models/project_services/gitlab_ci_service_spec.rb
+++ b/spec/models/project_services/gitlab_ci_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe GitlabCiService do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Mass assignment" do
@@ -34,11 +34,11 @@ describe GitlabCiService do
end
describe :commit_status_path do
- it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret"}
+ it { expect(@service.commit_status_path("2ab7834c")).to eq("http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret")}
end
describe :build_page do
- it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c"}
+ it { expect(@service.build_page("2ab7834c")).to eq("http://ci.gitlab.org/projects/2/commits/2ab7834c")}
end
end
end
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 99ca04eff6e..6ef4d036c3f 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe JiraService do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Validations" do
@@ -26,9 +26,9 @@ describe JiraService do
subject.active = true
end
- it { should validate_presence_of :project_url }
- it { should validate_presence_of :issues_url }
- it { should validate_presence_of :new_issue_url }
+ it { is_expected.to validate_presence_of :project_url }
+ it { is_expected.to validate_presence_of :issues_url }
+ it { is_expected.to validate_presence_of :new_issue_url }
end
end
@@ -79,7 +79,7 @@ describe JiraService do
"new_issue_url" => "http://jira.sample/projects/project_a/issues/new"
}
}
- Gitlab.config.stub(:issues_tracker).and_return(settings)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(settings)
@service = project.create_jira_service(active: true)
end
diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb
index f2813d66c7d..188626a7a27 100644
--- a/spec/models/project_services/pushover_service_spec.rb
+++ b/spec/models/project_services/pushover_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe PushoverService do
describe 'Associations' do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe 'Validations' do
@@ -26,9 +26,9 @@ describe PushoverService do
subject.active = true
end
- it { should validate_presence_of :api_key }
- it { should validate_presence_of :user_key }
- it { should validate_presence_of :priority }
+ it { is_expected.to validate_presence_of :api_key }
+ it { is_expected.to validate_presence_of :user_key }
+ it { is_expected.to validate_presence_of :priority }
end
end
@@ -63,7 +63,7 @@ describe PushoverService do
it 'should call Pushover API' do
pushover.execute(sample_data)
- WebMock.should have_requested(:post, api_url).once
+ expect(WebMock).to have_requested(:post, api_url).once
end
end
end
diff --git a/spec/models/project_services/slack_message_spec.rb b/spec/models/project_services/slack_message_spec.rb
index c530fad619b..7197a94e53f 100644
--- a/spec/models/project_services/slack_message_spec.rb
+++ b/spec/models/project_services/slack_message_spec.rb
@@ -25,16 +25,17 @@ describe SlackMessage do
end
it 'returns a message regarding pushes' do
- subject.pretext.should ==
+ expect(subject.pretext).to eq(
'user_name pushed to branch <url/commits/master|master> of '\
'<url|project_name> (<url/compare/before...after|Compare changes>)'
- subject.attachments.should == [
+ )
+ expect(subject.attachments).to eq([
{
text: "<url1|abcdefghi>: message1 - author1\n"\
"<url2|123456789>: message2 - author2",
color: color,
}
- ]
+ ])
end
end
@@ -44,10 +45,11 @@ describe SlackMessage do
end
it 'returns a message regarding a new branch' do
- subject.pretext.should ==
+ expect(subject.pretext).to eq(
'user_name pushed new branch <url/commits/master|master> to '\
'<url|project_name>'
- subject.attachments.should be_empty
+ )
+ expect(subject.attachments).to be_empty
end
end
@@ -57,9 +59,10 @@ describe SlackMessage do
end
it 'returns a message regarding a removed branch' do
- subject.pretext.should ==
+ expect(subject.pretext).to eq(
'user_name removed branch master from <url|project_name>'
- subject.attachments.should be_empty
+ )
+ expect(subject.attachments).to be_empty
end
end
end
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb
index 34594072409..90b385423f1 100644
--- a/spec/models/project_services/slack_service_spec.rb
+++ b/spec/models/project_services/slack_service_spec.rb
@@ -16,8 +16,8 @@ require 'spec_helper'
describe SlackService do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Validations" do
@@ -26,7 +26,7 @@ describe SlackService do
subject.active = true
end
- it { should validate_presence_of :webhook }
+ it { is_expected.to validate_presence_of :webhook }
end
end
@@ -51,7 +51,7 @@ describe SlackService do
it "should call Slack API" do
slack.execute(sample_data)
- WebMock.should have_requested(:post, webhook_url).once
+ expect(WebMock).to have_requested(:post, webhook_url).once
end
end
end
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb
index a6e1d9eef50..3e8f106d27f 100644
--- a/spec/models/project_snippet_spec.rb
+++ b/spec/models/project_snippet_spec.rb
@@ -19,13 +19,13 @@ require 'spec_helper'
describe ProjectSnippet do
describe "Associations" do
- it { should belong_to(:project) }
+ it { is_expected.to belong_to(:project) }
end
describe "Mass assignment" do
end
describe "Validation" do
- it { should validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:project) }
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index e2197420018..ad7a0f0a1e3 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -33,25 +33,25 @@ require 'spec_helper'
describe Project do
describe 'Associations' do
- it { should belong_to(:group) }
- it { should belong_to(:namespace) }
- it { should belong_to(:creator).class_name('User') }
- it { should have_many(:users) }
- it { should have_many(:events).dependent(:destroy) }
- it { should have_many(:merge_requests).dependent(:destroy) }
- it { should have_many(:issues).dependent(:destroy) }
- it { should have_many(:milestones).dependent(:destroy) }
- it { should have_many(:project_members).dependent(:destroy) }
- it { should have_many(:notes).dependent(:destroy) }
- it { should have_many(:snippets).class_name('ProjectSnippet').dependent(:destroy) }
- it { should have_many(:deploy_keys_projects).dependent(:destroy) }
- it { should have_many(:deploy_keys) }
- it { should have_many(:hooks).dependent(:destroy) }
- it { should have_many(:protected_branches).dependent(:destroy) }
- it { should have_one(:forked_project_link).dependent(:destroy) }
- it { should have_one(:slack_service).dependent(:destroy) }
- it { should have_one(:pushover_service).dependent(:destroy) }
- it { should have_one(:asana_service).dependent(:destroy) }
+ it { is_expected.to belong_to(:group) }
+ it { is_expected.to belong_to(:namespace) }
+ it { is_expected.to belong_to(:creator).class_name('User') }
+ it { is_expected.to have_many(:users) }
+ it { is_expected.to have_many(:events).dependent(:destroy) }
+ it { is_expected.to have_many(:merge_requests).dependent(:destroy) }
+ it { is_expected.to have_many(:issues).dependent(:destroy) }
+ it { is_expected.to have_many(:milestones).dependent(:destroy) }
+ it { is_expected.to have_many(:project_members).dependent(:destroy) }
+ it { is_expected.to have_many(:notes).dependent(:destroy) }
+ it { is_expected.to have_many(:snippets).class_name('ProjectSnippet').dependent(:destroy) }
+ it { is_expected.to have_many(:deploy_keys_projects).dependent(:destroy) }
+ it { is_expected.to have_many(:deploy_keys) }
+ it { is_expected.to have_many(:hooks).dependent(:destroy) }
+ it { is_expected.to have_many(:protected_branches).dependent(:destroy) }
+ it { is_expected.to have_one(:forked_project_link).dependent(:destroy) }
+ it { is_expected.to have_one(:slack_service).dependent(:destroy) }
+ it { is_expected.to have_one(:pushover_service).dependent(:destroy) }
+ it { is_expected.to have_one(:asana_service).dependent(:destroy) }
end
describe 'Mass assignment' do
@@ -60,50 +60,50 @@ describe Project do
describe 'Validation' do
let!(:project) { create(:project) }
- it { should validate_presence_of(:name) }
- it { should validate_uniqueness_of(:name).scoped_to(:namespace_id) }
- it { should ensure_length_of(:name).is_within(0..255) }
+ it { is_expected.to validate_presence_of(:name) }
+ it { is_expected.to validate_uniqueness_of(:name).scoped_to(:namespace_id) }
+ it { is_expected.to ensure_length_of(:name).is_within(0..255) }
- it { should validate_presence_of(:path) }
- it { should validate_uniqueness_of(:path).scoped_to(:namespace_id) }
- it { should ensure_length_of(:path).is_within(0..255) }
- it { should ensure_length_of(:description).is_within(0..2000) }
- it { should validate_presence_of(:creator) }
- it { should ensure_length_of(:issues_tracker_id).is_within(0..255) }
- it { should validate_presence_of(:namespace) }
+ it { is_expected.to validate_presence_of(:path) }
+ it { is_expected.to validate_uniqueness_of(:path).scoped_to(:namespace_id) }
+ it { is_expected.to ensure_length_of(:path).is_within(0..255) }
+ it { is_expected.to ensure_length_of(:description).is_within(0..2000) }
+ it { is_expected.to validate_presence_of(:creator) }
+ it { is_expected.to ensure_length_of(:issues_tracker_id).is_within(0..255) }
+ it { is_expected.to validate_presence_of(:namespace) }
it 'should not allow new projects beyond user limits' do
project2 = build(:project)
- project2.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object)
- project2.should_not be_valid
- project2.errors[:limit_reached].first.should match(/Your project limit is 0/)
+ allow(project2).to receive(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object)
+ expect(project2).not_to be_valid
+ expect(project2.errors[:limit_reached].first).to match(/Your project limit is 0/)
end
end
describe 'Respond to' do
- it { should respond_to(:url_to_repo) }
- it { should respond_to(:repo_exists?) }
- it { should respond_to(:satellite) }
- it { should respond_to(:update_merge_requests) }
- it { should respond_to(:execute_hooks) }
- it { should respond_to(:name_with_namespace) }
- it { should respond_to(:owner) }
- it { should respond_to(:path_with_namespace) }
+ it { is_expected.to respond_to(:url_to_repo) }
+ it { is_expected.to respond_to(:repo_exists?) }
+ it { is_expected.to respond_to(:satellite) }
+ it { is_expected.to respond_to(:update_merge_requests) }
+ it { is_expected.to respond_to(:execute_hooks) }
+ it { is_expected.to respond_to(:name_with_namespace) }
+ it { is_expected.to respond_to(:owner) }
+ it { is_expected.to respond_to(:path_with_namespace) }
end
it 'should return valid url to repo' do
project = Project.new(path: 'somewhere')
- project.url_to_repo.should == Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git'
+ expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git')
end
it 'returns the full web URL for this repo' do
project = Project.new(path: 'somewhere')
- project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere"
+ expect(project.web_url).to eq("#{Gitlab.config.gitlab.url}/somewhere")
end
it 'returns the web URL without the protocol for this repo' do
project = Project.new(path: 'somewhere')
- project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.url.split('://')[1]}/somewhere"
+ expect(project.web_url_without_protocol).to eq("#{Gitlab.config.gitlab.url.split('://')[1]}/somewhere")
end
describe 'last_activity methods' do
@@ -113,18 +113,18 @@ describe Project do
describe 'last_activity' do
it 'should alias last_activity to last_event' do
project.stub(last_event: last_event)
- project.last_activity.should == last_event
+ expect(project.last_activity).to eq(last_event)
end
end
describe 'last_activity_date' do
it 'returns the creation date of the project\'s last event if present' do
last_activity_event = create(:event, project: project)
- project.last_activity_at.to_i.should == last_event.created_at.to_i
+ expect(project.last_activity_at.to_i).to eq(last_event.created_at.to_i)
end
it 'returns the project\'s last update date if it has no events' do
- project.last_activity_date.should == project.updated_at
+ expect(project.last_activity_date).to eq(project.updated_at)
end
end
end
@@ -139,13 +139,13 @@ describe Project do
it 'should close merge request if last commit from source branch was pushed to target branch' do
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user)
merge_request.reload
- merge_request.merged?.should be_true
+ expect(merge_request.merged?).to be_truthy
end
it 'should update merge request commits with new one if pushed to source branch' do
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user)
merge_request.reload
- merge_request.last_commit.id.should == commit_id
+ expect(merge_request.last_commit.id).to eq(commit_id)
end
end
@@ -156,8 +156,8 @@ describe Project do
@project = create(:project, name: 'gitlabhq', namespace: @group)
end
- it { Project.find_with_namespace('gitlab/gitlabhq').should == @project }
- it { Project.find_with_namespace('gitlab-ci').should be_nil }
+ it { expect(Project.find_with_namespace('gitlab/gitlabhq')).to eq(@project) }
+ it { expect(Project.find_with_namespace('gitlab-ci')).to be_nil }
end
end
@@ -168,7 +168,7 @@ describe Project do
@project = create(:project, name: 'gitlabhq', namespace: @group)
end
- it { @project.to_param.should == 'gitlab/gitlabhq' }
+ it { expect(@project.to_param).to eq('gitlab/gitlabhq') }
end
end
@@ -176,7 +176,7 @@ describe Project do
let(:project) { create(:project) }
it 'should return valid repo' do
- project.repository.should be_kind_of(Repository)
+ expect(project.repository).to be_kind_of(Repository)
end
end
@@ -187,15 +187,15 @@ describe Project do
let(:ext_project) { create(:redmine_project) }
it 'should be true or if used internal tracker and issue exists' do
- project.issue_exists?(existed_issue.iid).should be_true
+ expect(project.issue_exists?(existed_issue.iid)).to be_truthy
end
it 'should be false or if used internal tracker and issue not exists' do
- project.issue_exists?(not_existed_issue.iid).should be_false
+ expect(project.issue_exists?(not_existed_issue.iid)).to be_falsey
end
it 'should always be true if used other tracker' do
- ext_project.issue_exists?(rand(100)).should be_true
+ expect(ext_project.issue_exists?(rand(100))).to be_truthy
end
end
@@ -204,11 +204,11 @@ describe Project do
let(:ext_project) { create(:redmine_project) }
it "should be true if used internal tracker" do
- project.default_issues_tracker?.should be_true
+ expect(project.default_issues_tracker?).to be_truthy
end
it "should be false if used other tracker" do
- ext_project.default_issues_tracker?.should be_false
+ expect(ext_project.default_issues_tracker?).to be_falsey
end
end
@@ -217,19 +217,19 @@ describe Project do
let(:ext_project) { create(:redmine_project) }
it 'should be true for projects with external issues tracker if issues enabled' do
- ext_project.can_have_issues_tracker_id?.should be_true
+ expect(ext_project.can_have_issues_tracker_id?).to be_truthy
end
it 'should be false for projects with internal issue tracker if issues enabled' do
- project.can_have_issues_tracker_id?.should be_false
+ expect(project.can_have_issues_tracker_id?).to be_falsey
end
it 'should be always false if issues disabled' do
project.issues_enabled = false
ext_project.issues_enabled = false
- project.can_have_issues_tracker_id?.should be_false
- ext_project.can_have_issues_tracker_id?.should be_false
+ expect(project.can_have_issues_tracker_id?).to be_falsey
+ expect(ext_project.can_have_issues_tracker_id?).to be_falsey
end
end
@@ -240,8 +240,8 @@ describe Project do
project.protected_branches.create(name: 'master')
end
- it { project.open_branches.map(&:name).should include('feature') }
- it { project.open_branches.map(&:name).should_not include('master') }
+ it { expect(project.open_branches.map(&:name)).to include('feature') }
+ it { expect(project.open_branches.map(&:name)).not_to include('master') }
end
describe '#star_count' do
@@ -318,12 +318,12 @@ describe Project do
it 'should be true if avatar is image' do
project.update_attribute(:avatar, 'uploads/avatar.png')
- project.avatar_type.should be_true
+ expect(project.avatar_type).to be_truthy
end
it 'should be false if avatar is html page' do
project.update_attribute(:avatar, 'uploads/avatar.html')
- project.avatar_type.should == ['only images allowed']
+ expect(project.avatar_type).to eq(['only images allowed'])
end
end
end
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
index bbf50b654f4..19201cc15a7 100644
--- a/spec/models/project_team_spec.rb
+++ b/spec/models/project_team_spec.rb
@@ -16,19 +16,19 @@ describe ProjectTeam do
end
describe 'members collection' do
- it { project.team.masters.should include(master) }
- it { project.team.masters.should_not include(guest) }
- it { project.team.masters.should_not include(reporter) }
- it { project.team.masters.should_not include(nonmember) }
+ it { expect(project.team.masters).to include(master) }
+ it { expect(project.team.masters).not_to include(guest) }
+ it { expect(project.team.masters).not_to include(reporter) }
+ it { expect(project.team.masters).not_to include(nonmember) }
end
describe 'access methods' do
- it { project.team.master?(master).should be_true }
- it { project.team.master?(guest).should be_false }
- it { project.team.master?(reporter).should be_false }
- it { project.team.master?(nonmember).should be_false }
- it { project.team.member?(nonmember).should be_false }
- it { project.team.member?(guest).should be_true }
+ it { expect(project.team.master?(master)).to be_truthy }
+ it { expect(project.team.master?(guest)).to be_falsey }
+ it { expect(project.team.master?(reporter)).to be_falsey }
+ it { expect(project.team.master?(nonmember)).to be_falsey }
+ it { expect(project.team.member?(nonmember)).to be_falsey }
+ it { expect(project.team.member?(guest)).to be_truthy }
end
end
@@ -49,21 +49,21 @@ describe ProjectTeam do
end
describe 'members collection' do
- it { project.team.reporters.should include(reporter) }
- it { project.team.masters.should include(master) }
- it { project.team.masters.should include(guest) }
- it { project.team.masters.should_not include(reporter) }
- it { project.team.masters.should_not include(nonmember) }
+ it { expect(project.team.reporters).to include(reporter) }
+ it { expect(project.team.masters).to include(master) }
+ it { expect(project.team.masters).to include(guest) }
+ it { expect(project.team.masters).not_to include(reporter) }
+ it { expect(project.team.masters).not_to include(nonmember) }
end
describe 'access methods' do
- it { project.team.reporter?(reporter).should be_true }
- it { project.team.master?(master).should be_true }
- it { project.team.master?(guest).should be_true }
- it { project.team.master?(reporter).should be_false }
- it { project.team.master?(nonmember).should be_false }
- it { project.team.member?(nonmember).should be_false }
- it { project.team.member?(guest).should be_true }
+ it { expect(project.team.reporter?(reporter)).to be_truthy }
+ it { expect(project.team.master?(master)).to be_truthy }
+ it { expect(project.team.master?(guest)).to be_truthy }
+ it { expect(project.team.master?(reporter)).to be_falsey }
+ it { expect(project.team.master?(nonmember)).to be_falsey }
+ it { expect(project.team.member?(nonmember)).to be_falsey }
+ it { expect(project.team.member?(guest)).to be_truthy }
end
end
end
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index e4ee2fc5b13..2acdb7dfddc 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -12,19 +12,19 @@ describe ProjectWiki do
describe "#path_with_namespace" do
it "returns the project path with namespace with the .wiki extension" do
- subject.path_with_namespace.should == project.path_with_namespace + ".wiki"
+ expect(subject.path_with_namespace).to eq(project.path_with_namespace + ".wiki")
end
end
describe "#url_to_repo" do
it "returns the correct ssh url to the repo" do
- subject.url_to_repo.should == gitlab_shell.url_to_repo(subject.path_with_namespace)
+ expect(subject.url_to_repo).to eq(gitlab_shell.url_to_repo(subject.path_with_namespace))
end
end
describe "#ssh_url_to_repo" do
it "equals #url_to_repo" do
- subject.ssh_url_to_repo.should == subject.url_to_repo
+ expect(subject.ssh_url_to_repo).to eq(subject.url_to_repo)
end
end
@@ -32,21 +32,21 @@ describe ProjectWiki do
it "provides the full http url to the repo" do
gitlab_url = Gitlab.config.gitlab.url
repo_http_url = "#{gitlab_url}/#{subject.path_with_namespace}.git"
- subject.http_url_to_repo.should == repo_http_url
+ expect(subject.http_url_to_repo).to eq(repo_http_url)
end
end
describe "#wiki" do
it "contains a Gollum::Wiki instance" do
- subject.wiki.should be_a Gollum::Wiki
+ expect(subject.wiki).to be_a Gollum::Wiki
end
it "creates a new wiki repo if one does not yet exist" do
- project_wiki.create_page("index", "test content").should be_true
+ expect(project_wiki.create_page("index", "test content")).to be_truthy
end
it "raises CouldNotCreateWikiError if it can't create the wiki repository" do
- project_wiki.stub(:init_repo).and_return(false)
+ allow(project_wiki).to receive(:init_repo).and_return(false)
expect { project_wiki.send(:create_repo!) }.to raise_exception(ProjectWiki::CouldNotCreateWikiError)
end
end
@@ -54,21 +54,27 @@ describe ProjectWiki do
describe "#empty?" do
context "when the wiki repository is empty" do
before do
- Gitlab::Shell.any_instance.stub(:add_repository) do
+ allow_any_instance_of(Gitlab::Shell).to receive(:add_repository) do
create_temp_repo("#{Rails.root}/tmp/test-git-base-path/non-existant.wiki.git")
end
- project.stub(:path_with_namespace).and_return("non-existant")
+ allow(project).to receive(:path_with_namespace).and_return("non-existant")
end
- its(:empty?) { should be_true }
+ describe '#empty?' do
+ subject { super().empty? }
+ it { is_expected.to be_truthy }
+ end
end
context "when the wiki has pages" do
before do
- create_page("index", "This is an awesome new Gollum Wiki")
+ project_wiki.create_page("index", "This is an awesome new Gollum Wiki")
end
- its(:empty?) { should be_false }
+ describe '#empty?' do
+ subject { super().empty? }
+ it { is_expected.to be_falsey }
+ end
end
end
@@ -83,11 +89,11 @@ describe ProjectWiki do
end
it "returns an array of WikiPage instances" do
- @pages.first.should be_a WikiPage
+ expect(@pages.first).to be_a WikiPage
end
it "returns the correct number of pages" do
- @pages.count.should == 1
+ expect(@pages.count).to eq(1)
end
end
@@ -102,55 +108,55 @@ describe ProjectWiki do
it "returns the latest version of the page if it exists" do
page = subject.find_page("index page")
- page.title.should == "index page"
+ expect(page.title).to eq("index page")
end
it "returns nil if the page does not exist" do
- subject.find_page("non-existant").should == nil
+ expect(subject.find_page("non-existant")).to eq(nil)
end
it "can find a page by slug" do
page = subject.find_page("index-page")
- page.title.should == "index page"
+ expect(page.title).to eq("index page")
end
it "returns a WikiPage instance" do
page = subject.find_page("index page")
- page.should be_a WikiPage
+ expect(page).to be_a WikiPage
end
end
describe '#find_file' do
before do
file = Gollum::File.new(subject.wiki)
- Gollum::Wiki.any_instance.
- stub(:file).with('image.jpg', 'master', true).
+ allow_any_instance_of(Gollum::Wiki).
+ to receive(:file).with('image.jpg', 'master', true).
and_return(file)
- Gollum::File.any_instance.
- stub(:mime_type).
+ allow_any_instance_of(Gollum::File).
+ to receive(:mime_type).
and_return('image/jpeg')
- Gollum::Wiki.any_instance.
- stub(:file).with('non-existant', 'master', true).
+ allow_any_instance_of(Gollum::Wiki).
+ to receive(:file).with('non-existant', 'master', true).
and_return(nil)
end
after do
- Gollum::Wiki.any_instance.unstub(:file)
- Gollum::File.any_instance.unstub(:mime_type)
+ allow_any_instance_of(Gollum::Wiki).to receive(:file).and_call_original
+ allow_any_instance_of(Gollum::File).to receive(:mime_type).and_call_original
end
it 'returns the latest version of the file if it exists' do
file = subject.find_file('image.jpg')
- file.mime_type.should == 'image/jpeg'
+ expect(file.mime_type).to eq('image/jpeg')
end
it 'returns nil if the page does not exist' do
- subject.find_file('non-existant').should == nil
+ expect(subject.find_file('non-existant')).to eq(nil)
end
it 'returns a Gollum::File instance' do
file = subject.find_file('image.jpg')
- file.should be_a Gollum::File
+ expect(file).to be_a Gollum::File
end
end
@@ -160,23 +166,23 @@ describe ProjectWiki do
end
it "creates a new wiki page" do
- subject.create_page("test page", "this is content").should_not == false
- subject.pages.count.should == 1
+ expect(subject.create_page("test page", "this is content")).not_to eq(false)
+ expect(subject.pages.count).to eq(1)
end
it "returns false when a duplicate page exists" do
subject.create_page("test page", "content")
- subject.create_page("test page", "content").should == false
+ expect(subject.create_page("test page", "content")).to eq(false)
end
it "stores an error message when a duplicate page exists" do
2.times { subject.create_page("test page", "content") }
- subject.error_message.should =~ /Duplicate page:/
+ expect(subject.error_message).to match(/Duplicate page:/)
end
it "sets the correct commit message" do
subject.create_page("test page", "some content", :markdown, "commit message")
- subject.pages.first.page.version.message.should == "commit message"
+ expect(subject.pages.first.page.version.message).to eq("commit message")
end
end
@@ -193,11 +199,11 @@ describe ProjectWiki do
end
it "updates the content of the page" do
- @page.raw_data.should == "some other content"
+ expect(@page.raw_data).to eq("some other content")
end
it "sets the correct commit message" do
- @page.version.message.should == "updated page"
+ expect(@page.version.message).to eq("updated page")
end
end
@@ -209,7 +215,7 @@ describe ProjectWiki do
it "deletes the page" do
subject.delete_page(@page)
- subject.pages.count.should == 0
+ expect(subject.pages.count).to eq(0)
end
end
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index b0f57e8a206..1e6937b536c 100644
--- a/spec/models/protected_branch_spec.rb
+++ b/spec/models/protected_branch_spec.rb
@@ -14,14 +14,14 @@ require 'spec_helper'
describe ProtectedBranch do
describe 'Associations' do
- it { should belong_to(:project) }
+ it { is_expected.to belong_to(:project) }
end
describe "Mass assignment" do
end
describe 'Validation' do
- it { should validate_presence_of(:project) }
- it { should validate_presence_of(:name) }
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:name) }
end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 6c3e221f343..eeb0f3d9ee0 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -8,14 +8,14 @@ describe Repository do
describe :branch_names_contains do
subject { repository.branch_names_contains(sample_commit.id) }
- it { should include('master') }
- it { should_not include('feature') }
- it { should_not include('fix') }
+ it { is_expected.to include('master') }
+ it { is_expected.not_to include('feature') }
+ it { is_expected.not_to include('fix') }
end
describe :last_commit_for_path do
subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id }
- it { should eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
+ it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
end
end
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 1df34f56cf1..9a1248055b1 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -18,8 +18,8 @@ require 'spec_helper'
describe Service do
describe "Associations" do
- it { should belong_to :project }
- it { should have_one :service_hook }
+ it { is_expected.to belong_to :project }
+ it { is_expected.to have_one :service_hook }
end
describe "Mass assignment" do
@@ -41,7 +41,7 @@ describe Service do
end
describe :can_test do
- it { @testable.should == true }
+ it { expect(@testable).to eq(true) }
end
end
@@ -56,7 +56,7 @@ describe Service do
end
describe :can_test do
- it { @testable.should == true }
+ it { expect(@testable).to eq(true) }
end
end
end
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index 1ef2c512c1f..e37dcc75230 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -19,22 +19,22 @@ require 'spec_helper'
describe Snippet do
describe "Associations" do
- it { should belong_to(:author).class_name('User') }
- it { should have_many(:notes).dependent(:destroy) }
+ it { is_expected.to belong_to(:author).class_name('User') }
+ it { is_expected.to have_many(:notes).dependent(:destroy) }
end
describe "Mass assignment" do
end
describe "Validation" do
- it { should validate_presence_of(:author) }
+ it { is_expected.to validate_presence_of(:author) }
- it { should validate_presence_of(:title) }
- it { should ensure_length_of(:title).is_within(0..255) }
+ it { is_expected.to validate_presence_of(:title) }
+ it { is_expected.to ensure_length_of(:title).is_within(0..255) }
- it { should validate_presence_of(:file_name) }
- it { should ensure_length_of(:title).is_within(0..255) }
+ it { is_expected.to validate_presence_of(:file_name) }
+ it { is_expected.to ensure_length_of(:title).is_within(0..255) }
- it { should validate_presence_of(:content) }
+ it { is_expected.to validate_presence_of(:content) }
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 7473054f481..6102b2e30be 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -49,32 +49,32 @@ require 'spec_helper'
describe User do
describe "Associations" do
- it { should have_one(:namespace) }
- it { should have_many(:snippets).class_name('Snippet').dependent(:destroy) }
- it { should have_many(:project_members).dependent(:destroy) }
- it { should have_many(:groups) }
- it { should have_many(:keys).dependent(:destroy) }
- it { should have_many(:events).class_name('Event').dependent(:destroy) }
- it { should have_many(:recent_events).class_name('Event') }
- it { should have_many(:issues).dependent(:destroy) }
- it { should have_many(:notes).dependent(:destroy) }
- it { should have_many(:assigned_issues).dependent(:destroy) }
- it { should have_many(:merge_requests).dependent(:destroy) }
- it { should have_many(:assigned_merge_requests).dependent(:destroy) }
- it { should have_many(:identities).dependent(:destroy) }
+ it { is_expected.to have_one(:namespace) }
+ it { is_expected.to have_many(:snippets).class_name('Snippet').dependent(:destroy) }
+ it { is_expected.to have_many(:project_members).dependent(:destroy) }
+ it { is_expected.to have_many(:groups) }
+ it { is_expected.to have_many(:keys).dependent(:destroy) }
+ it { is_expected.to have_many(:events).class_name('Event').dependent(:destroy) }
+ it { is_expected.to have_many(:recent_events).class_name('Event') }
+ it { is_expected.to have_many(:issues).dependent(:destroy) }
+ it { is_expected.to have_many(:notes).dependent(:destroy) }
+ it { is_expected.to have_many(:assigned_issues).dependent(:destroy) }
+ it { is_expected.to have_many(:merge_requests).dependent(:destroy) }
+ it { is_expected.to have_many(:assigned_merge_requests).dependent(:destroy) }
+ it { is_expected.to have_many(:identities).dependent(:destroy) }
end
describe "Mass assignment" do
end
describe 'validations' do
- it { should validate_presence_of(:username) }
- it { should validate_presence_of(:projects_limit) }
- it { should validate_numericality_of(:projects_limit) }
- it { should allow_value(0).for(:projects_limit) }
- it { should_not allow_value(-1).for(:projects_limit) }
+ it { is_expected.to validate_presence_of(:username) }
+ it { is_expected.to validate_presence_of(:projects_limit) }
+ it { is_expected.to validate_numericality_of(:projects_limit) }
+ it { is_expected.to allow_value(0).for(:projects_limit) }
+ it { is_expected.not_to allow_value(-1).for(:projects_limit) }
- it { should ensure_length_of(:bio).is_within(0..255) }
+ it { is_expected.to ensure_length_of(:bio).is_within(0..255) }
describe 'email' do
it 'accepts info@example.com' do
@@ -110,34 +110,34 @@ describe User do
end
describe "Respond to" do
- it { should respond_to(:is_admin?) }
- it { should respond_to(:name) }
- it { should respond_to(:private_token) }
+ it { is_expected.to respond_to(:is_admin?) }
+ it { is_expected.to respond_to(:name) }
+ it { is_expected.to respond_to(:private_token) }
end
describe '#generate_password' do
it "should execute callback when force_random_password specified" do
user = build(:user, force_random_password: true)
- user.should_receive(:generate_password)
+ expect(user).to receive(:generate_password)
user.save
end
it "should not generate password by default" do
user = create(:user, password: 'abcdefghe')
- user.password.should == 'abcdefghe'
+ expect(user.password).to eq('abcdefghe')
end
it "should generate password when forcing random password" do
- Devise.stub(:friendly_token).and_return('123456789')
+ allow(Devise).to receive(:friendly_token).and_return('123456789')
user = create(:user, password: 'abcdefg', force_random_password: true)
- user.password.should == '12345678'
+ expect(user.password).to eq('12345678')
end
end
describe 'authentication token' do
it "should have authentication token" do
user = create(:user)
- user.authentication_token.should_not be_blank
+ expect(user.authentication_token).not_to be_blank
end
end
@@ -152,15 +152,15 @@ describe User do
@project_3.team << [@user, :developer]
end
- it { @user.authorized_projects.should include(@project) }
- it { @user.authorized_projects.should include(@project_2) }
- it { @user.authorized_projects.should include(@project_3) }
- it { @user.owned_projects.should include(@project) }
- it { @user.owned_projects.should_not include(@project_2) }
- it { @user.owned_projects.should_not include(@project_3) }
- it { @user.personal_projects.should include(@project) }
- it { @user.personal_projects.should_not include(@project_2) }
- it { @user.personal_projects.should_not include(@project_3) }
+ it { expect(@user.authorized_projects).to include(@project) }
+ it { expect(@user.authorized_projects).to include(@project_2) }
+ it { expect(@user.authorized_projects).to include(@project_3) }
+ it { expect(@user.owned_projects).to include(@project) }
+ it { expect(@user.owned_projects).not_to include(@project_2) }
+ it { expect(@user.owned_projects).not_to include(@project_3) }
+ it { expect(@user.personal_projects).to include(@project) }
+ it { expect(@user.personal_projects).not_to include(@project_2) }
+ it { expect(@user.personal_projects).not_to include(@project_3) }
end
describe 'groups' do
@@ -170,9 +170,9 @@ describe User do
@group.add_owner(@user)
end
- it { @user.several_namespaces?.should be_true }
- it { @user.authorized_groups.should == [@group] }
- it { @user.owned_groups.should == [@group] }
+ it { expect(@user.several_namespaces?).to be_truthy }
+ it { expect(@user.authorized_groups).to eq([@group]) }
+ it { expect(@user.owned_groups).to eq([@group]) }
end
describe 'group multiple owners' do
@@ -185,7 +185,7 @@ describe User do
@group.add_user(@user2, GroupMember::OWNER)
end
- it { @user2.several_namespaces?.should be_true }
+ it { expect(@user2.several_namespaces?).to be_truthy }
end
describe 'namespaced' do
@@ -194,7 +194,7 @@ describe User do
@project = create :project, namespace: @user.namespace
end
- it { @user.several_namespaces?.should be_false }
+ it { expect(@user.several_namespaces?).to be_falsey }
end
describe 'blocking user' do
@@ -202,7 +202,7 @@ describe User do
it "should block user" do
user.block
- user.blocked?.should be_true
+ expect(user.blocked?).to be_truthy
end
end
@@ -214,10 +214,10 @@ describe User do
@blocked = create :user, state: :blocked
end
- it { User.filter("admins").should == [@admin] }
- it { User.filter("blocked").should == [@blocked] }
- it { User.filter("wop").should include(@user, @admin, @blocked) }
- it { User.filter(nil).should include(@user, @admin) }
+ it { expect(User.filter("admins")).to eq([@admin]) }
+ it { expect(User.filter("blocked")).to eq([@blocked]) }
+ it { expect(User.filter("wop")).to include(@user, @admin, @blocked) }
+ it { expect(User.filter(nil)).to include(@user, @admin) }
end
describe :not_in_project do
@@ -227,27 +227,27 @@ describe User do
@project = create :project
end
- it { User.not_in_project(@project).should include(@user, @project.owner) }
+ it { expect(User.not_in_project(@project)).to include(@user, @project.owner) }
end
describe 'user creation' do
describe 'normal user' do
let(:user) { create(:user, name: 'John Smith') }
- it { user.is_admin?.should be_false }
- it { user.require_ssh_key?.should be_true }
- it { user.can_create_group?.should be_true }
- it { user.can_create_project?.should be_true }
- it { user.first_name.should == 'John' }
+ it { expect(user.is_admin?).to be_falsey }
+ it { expect(user.require_ssh_key?).to be_truthy }
+ it { expect(user.can_create_group?).to be_truthy }
+ it { expect(user.can_create_project?).to be_truthy }
+ it { expect(user.first_name).to eq('John') }
end
describe 'with defaults' do
let(:user) { User.new }
it "should apply defaults to user" do
- user.projects_limit.should == Gitlab.config.gitlab.default_projects_limit
- user.can_create_group.should == Gitlab.config.gitlab.default_can_create_group
- user.theme_id.should == Gitlab.config.gitlab.default_theme
+ 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)
+ expect(user.theme_id).to eq(Gitlab.config.gitlab.default_theme)
end
end
@@ -255,9 +255,9 @@ describe User do
let(:user) { User.new(projects_limit: 123, can_create_group: false, can_create_team: true, theme_id: Gitlab::Theme::BASIC) }
it "should apply defaults to user" do
- user.projects_limit.should == 123
- user.can_create_group.should be_false
- user.theme_id.should == Gitlab::Theme::BASIC
+ expect(user.projects_limit).to eq(123)
+ expect(user.can_create_group).to be_falsey
+ expect(user.theme_id).to eq(Gitlab::Theme::BASIC)
end
end
end
@@ -267,12 +267,12 @@ describe User do
let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') }
it "should be case insensitive" do
- User.search(user1.username.upcase).to_a.should == [user1]
- User.search(user1.username.downcase).to_a.should == [user1]
- User.search(user2.username.upcase).to_a.should == [user2]
- User.search(user2.username.downcase).to_a.should == [user2]
- User.search(user1.username.downcase).to_a.count.should == 2
- User.search(user2.username.downcase).to_a.count.should == 1
+ expect(User.search(user1.username.upcase).to_a).to eq([user1])
+ expect(User.search(user1.username.downcase).to_a).to eq([user1])
+ expect(User.search(user2.username.upcase).to_a).to eq([user2])
+ expect(User.search(user2.username.downcase).to_a).to eq([user2])
+ expect(User.search(user1.username.downcase).to_a.count).to eq(2)
+ expect(User.search(user2.username.downcase).to_a.count).to eq(1)
end
end
@@ -280,10 +280,10 @@ describe User do
let(:user1) { create(:user, username: 'foo') }
it "should get the correct user" do
- User.by_username_or_id(user1.id).should == user1
- User.by_username_or_id('foo').should == user1
- User.by_username_or_id(-1).should be_nil
- User.by_username_or_id('bar').should be_nil
+ expect(User.by_username_or_id(user1.id)).to eq(user1)
+ expect(User.by_username_or_id('foo')).to eq(user1)
+ expect(User.by_username_or_id(-1)).to be_nil
+ expect(User.by_username_or_id('bar')).to be_nil
end
end
@@ -312,13 +312,13 @@ describe User do
end
describe 'all_ssh_keys' do
- it { should have_many(:keys).dependent(:destroy) }
+ it { is_expected.to have_many(:keys).dependent(:destroy) }
it "should have all ssh keys" do
user = create :user
key = create :key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH", user_id: user.id
- user.all_ssh_keys.should include(key.key)
+ expect(user.all_ssh_keys).to include(key.key)
end
end
@@ -327,12 +327,12 @@ describe User do
it "should be true if avatar is image" do
user.update_attribute(:avatar, 'uploads/avatar.png')
- user.avatar_type.should be_true
+ expect(user.avatar_type).to be_truthy
end
it "should be false if avatar is html page" do
user.update_attribute(:avatar, 'uploads/avatar.html')
- user.avatar_type.should == ["only images allowed"]
+ expect(user.avatar_type).to eq(["only images allowed"])
end
end
@@ -343,7 +343,7 @@ describe User do
# Create a condition which would otherwise cause 'true' to be returned
user.stub(ldap_user?: true)
user.last_credential_check_at = nil
- expect(user.requires_ldap_check?).to be_false
+ expect(user.requires_ldap_check?).to be_falsey
end
context 'when LDAP is enabled' do
@@ -351,7 +351,7 @@ describe User do
it 'is false for non-LDAP users' do
user.stub(ldap_user?: false)
- expect(user.requires_ldap_check?).to be_false
+ expect(user.requires_ldap_check?).to be_falsey
end
context 'and when the user is an LDAP user' do
@@ -359,12 +359,12 @@ describe User do
it 'is true when the user has never had an LDAP check before' do
user.last_credential_check_at = nil
- expect(user.requires_ldap_check?).to be_true
+ expect(user.requires_ldap_check?).to be_truthy
end
it 'is true when the last LDAP check happened over 1 hour ago' do
user.last_credential_check_at = 2.hours.ago
- expect(user.requires_ldap_check?).to be_true
+ expect(user.requires_ldap_check?).to be_truthy
end
end
end
@@ -373,24 +373,24 @@ describe User do
describe :ldap_user? do
it "is true if provider name starts with ldap" do
user = create(:omniauth_user, provider: 'ldapmain')
- expect( user.ldap_user? ).to be_true
+ expect( user.ldap_user? ).to be_truthy
end
it "is false for other providers" do
user = create(:omniauth_user, provider: 'other-provider')
- expect( user.ldap_user? ).to be_false
+ expect( user.ldap_user? ).to be_falsey
end
it "is false if no extern_uid is provided" do
user = create(:omniauth_user, extern_uid: nil)
- expect( user.ldap_user? ).to be_false
+ expect( user.ldap_user? ).to be_falsey
end
end
describe :ldap_identity do
it "returns ldap identity" do
user = create :omniauth_user
- user.ldap_identity.provider.should_not be_empty
+ expect(user.ldap_identity.provider).not_to be_empty
end
end
@@ -444,24 +444,24 @@ describe User do
project1 = create :project, :public
project2 = create :project, :public
- expect(user.starred?(project1)).to be_false
- expect(user.starred?(project2)).to be_false
+ expect(user.starred?(project1)).to be_falsey
+ expect(user.starred?(project2)).to be_falsey
star1 = UsersStarProject.create!(project: project1, user: user)
- expect(user.starred?(project1)).to be_true
- expect(user.starred?(project2)).to be_false
+ expect(user.starred?(project1)).to be_truthy
+ expect(user.starred?(project2)).to be_falsey
star2 = UsersStarProject.create!(project: project2, user: user)
- expect(user.starred?(project1)).to be_true
- expect(user.starred?(project2)).to be_true
+ expect(user.starred?(project1)).to be_truthy
+ expect(user.starred?(project2)).to be_truthy
star1.destroy
- expect(user.starred?(project1)).to be_false
- expect(user.starred?(project2)).to be_true
+ expect(user.starred?(project1)).to be_falsey
+ expect(user.starred?(project2)).to be_truthy
star2.destroy
- expect(user.starred?(project1)).to be_false
- expect(user.starred?(project2)).to be_false
+ expect(user.starred?(project1)).to be_falsey
+ expect(user.starred?(project2)).to be_falsey
end
end
@@ -470,11 +470,11 @@ describe User do
user = create :user
project = create :project, :public
- expect(user.starred?(project)).to be_false
+ expect(user.starred?(project)).to be_falsey
user.toggle_star(project)
- expect(user.starred?(project)).to be_true
+ expect(user.starred?(project)).to be_truthy
user.toggle_star(project)
- expect(user.starred?(project)).to be_false
+ expect(user.starred?(project)).to be_falsey
end
end
@@ -486,23 +486,23 @@ describe User do
end
it "sorts users as recently_signed_in" do
- User.sort('recent_sign_in').first.should == @user
+ expect(User.sort('recent_sign_in').first).to eq(@user)
end
it "sorts users as late_signed_in" do
- User.sort('oldest_sign_in').first.should == @user1
+ expect(User.sort('oldest_sign_in').first).to eq(@user1)
end
it "sorts users as recently_created" do
- User.sort('created_desc').first.should == @user
+ expect(User.sort('created_desc').first).to eq(@user)
end
it "sorts users as late_created" do
- User.sort('created_asc').first.should == @user1
+ expect(User.sort('created_asc').first).to eq(@user1)
end
it "sorts users by name when nil is passed" do
- User.sort(nil).first.should == @user
+ expect(User.sort(nil).first).to eq(@user)
end
end
end
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index 78877db61b7..f3fd805783f 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -16,27 +16,27 @@ describe WikiPage do
end
it "sets the slug attribute" do
- @wiki_page.slug.should == "test-page"
+ expect(@wiki_page.slug).to eq("test-page")
end
it "sets the title attribute" do
- @wiki_page.title.should == "test page"
+ expect(@wiki_page.title).to eq("test page")
end
it "sets the formatted content attribute" do
- @wiki_page.content.should == "test content"
+ expect(@wiki_page.content).to eq("test content")
end
it "sets the format attribute" do
- @wiki_page.format.should == :markdown
+ expect(@wiki_page.format).to eq(:markdown)
end
it "sets the message attribute" do
- @wiki_page.message.should == "test commit"
+ expect(@wiki_page.message).to eq("test commit")
end
it "sets the version attribute" do
- @wiki_page.version.should be_a Gollum::Git::Commit
+ expect(@wiki_page.version).to be_a Gollum::Git::Commit
end
end
end
@@ -48,12 +48,12 @@ describe WikiPage do
it "validates presence of title" do
subject.attributes.delete(:title)
- subject.valid?.should be_false
+ expect(subject.valid?).to be_falsey
end
it "validates presence of content" do
subject.attributes.delete(:content)
- subject.valid?.should be_false
+ expect(subject.valid?).to be_falsey
end
end
@@ -69,11 +69,11 @@ describe WikiPage do
context "with valid attributes" do
it "saves the wiki page" do
subject.create(@wiki_attr)
- wiki.find_page("Index").should_not be_nil
+ expect(wiki.find_page("Index")).not_to be_nil
end
it "returns true" do
- subject.create(@wiki_attr).should == true
+ expect(subject.create(@wiki_attr)).to eq(true)
end
end
end
@@ -95,7 +95,7 @@ describe WikiPage do
end
it "returns true" do
- @page.update("more content").should be_true
+ expect(@page.update("more content")).to be_truthy
end
end
end
@@ -108,11 +108,11 @@ describe WikiPage do
it "should delete the page" do
@page.delete
- wiki.pages.should be_empty
+ expect(wiki.pages).to be_empty
end
it "should return true" do
- @page.delete.should == true
+ expect(@page.delete).to eq(true)
end
end
@@ -128,7 +128,7 @@ describe WikiPage do
it "returns an array of all commits for the page" do
3.times { |i| @page.update("content #{i}") }
- @page.versions.count.should == 4
+ expect(@page.versions.count).to eq(4)
end
end
@@ -144,7 +144,7 @@ describe WikiPage do
it "should be replace a hyphen to a space" do
@page.title = "Import-existing-repositories-into-GitLab"
- @page.title.should == "Import existing repositories into GitLab"
+ expect(@page.title).to eq("Import existing repositories into GitLab")
end
end
diff --git a/spec/requests/api/api_helpers_spec.rb b/spec/requests/api/api_helpers_spec.rb
index cc071342d7c..20cb30a39bb 100644
--- a/spec/requests/api/api_helpers_spec.rb
+++ b/spec/requests/api/api_helpers_spec.rb
@@ -41,33 +41,33 @@ describe API, api: true do
describe ".current_user" do
it "should return nil for an invalid token" do
env[API::APIHelpers::PRIVATE_TOKEN_HEADER] = 'invalid token'
- self.class.any_instance.stub(:doorkeeper_guard){ false }
- current_user.should be_nil
+ allow_any_instance_of(self.class).to receive(:doorkeeper_guard){ false }
+ expect(current_user).to be_nil
end
it "should return nil for a user without access" do
env[API::APIHelpers::PRIVATE_TOKEN_HEADER] = user.private_token
Gitlab::UserAccess.stub(allowed?: false)
- current_user.should be_nil
+ expect(current_user).to be_nil
end
it "should leave user as is when sudo not specified" do
env[API::APIHelpers::PRIVATE_TOKEN_HEADER] = user.private_token
- current_user.should == user
+ expect(current_user).to eq(user)
clear_env
params[API::APIHelpers::PRIVATE_TOKEN_PARAM] = user.private_token
- current_user.should == user
+ expect(current_user).to eq(user)
end
it "should change current user to sudo when admin" do
set_env(admin, user.id)
- current_user.should == user
+ expect(current_user).to eq(user)
set_param(admin, user.id)
- current_user.should == user
+ expect(current_user).to eq(user)
set_env(admin, user.username)
- current_user.should == user
+ expect(current_user).to eq(user)
set_param(admin, user.username)
- current_user.should == user
+ expect(current_user).to eq(user)
end
it "should throw an error when the current user is not an admin and attempting to sudo" do
@@ -83,8 +83,8 @@ describe API, api: true do
it "should throw an error when the user cannot be found for a given id" do
id = user.id + admin.id
- user.id.should_not == id
- admin.id.should_not == id
+ expect(user.id).not_to eq(id)
+ expect(admin.id).not_to eq(id)
set_env(admin, id)
expect { current_user }.to raise_error
@@ -94,8 +94,8 @@ describe API, api: true do
it "should throw an error when the user cannot be found for a given username" do
username = "#{user.username}#{admin.username}"
- user.username.should_not == username
- admin.username.should_not == username
+ expect(user.username).not_to eq(username)
+ expect(admin.username).not_to eq(username)
set_env(admin, username)
expect { current_user }.to raise_error
@@ -105,69 +105,69 @@ describe API, api: true do
it "should handle sudo's to oneself" do
set_env(admin, admin.id)
- current_user.should == admin
+ expect(current_user).to eq(admin)
set_param(admin, admin.id)
- current_user.should == admin
+ expect(current_user).to eq(admin)
set_env(admin, admin.username)
- current_user.should == admin
+ expect(current_user).to eq(admin)
set_param(admin, admin.username)
- current_user.should == admin
+ expect(current_user).to eq(admin)
end
it "should handle multiple sudo's to oneself" do
set_env(admin, user.id)
- current_user.should == user
- current_user.should == user
+ expect(current_user).to eq(user)
+ expect(current_user).to eq(user)
set_env(admin, user.username)
- current_user.should == user
- current_user.should == user
+ expect(current_user).to eq(user)
+ expect(current_user).to eq(user)
set_param(admin, user.id)
- current_user.should == user
- current_user.should == user
+ expect(current_user).to eq(user)
+ expect(current_user).to eq(user)
set_param(admin, user.username)
- current_user.should == user
- current_user.should == user
+ expect(current_user).to eq(user)
+ expect(current_user).to eq(user)
end
it "should handle multiple sudo's to oneself using string ids" do
set_env(admin, user.id.to_s)
- current_user.should == user
- current_user.should == user
+ expect(current_user).to eq(user)
+ expect(current_user).to eq(user)
set_param(admin, user.id.to_s)
- current_user.should == user
- current_user.should == user
+ expect(current_user).to eq(user)
+ expect(current_user).to eq(user)
end
end
describe '.sudo_identifier' do
it "should return integers when input is an int" do
set_env(admin, '123')
- sudo_identifier.should == 123
+ expect(sudo_identifier).to eq(123)
set_env(admin, '0001234567890')
- sudo_identifier.should == 1234567890
+ expect(sudo_identifier).to eq(1234567890)
set_param(admin, '123')
- sudo_identifier.should == 123
+ expect(sudo_identifier).to eq(123)
set_param(admin, '0001234567890')
- sudo_identifier.should == 1234567890
+ expect(sudo_identifier).to eq(1234567890)
end
it "should return string when input is an is not an int" do
set_env(admin, '12.30')
- sudo_identifier.should == "12.30"
+ expect(sudo_identifier).to eq("12.30")
set_env(admin, 'hello')
- sudo_identifier.should == 'hello'
+ expect(sudo_identifier).to eq('hello')
set_env(admin, ' 123')
- sudo_identifier.should == ' 123'
+ expect(sudo_identifier).to eq(' 123')
set_param(admin, '12.30')
- sudo_identifier.should == "12.30"
+ expect(sudo_identifier).to eq("12.30")
set_param(admin, 'hello')
- sudo_identifier.should == 'hello'
+ expect(sudo_identifier).to eq('hello')
set_param(admin, ' 123')
- sudo_identifier.should == ' 123'
+ expect(sudo_identifier).to eq(' 123')
end
end
end
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb
index b45572c39fd..f40d68b75a4 100644
--- a/spec/requests/api/branches_spec.rb
+++ b/spec/requests/api/branches_spec.rb
@@ -15,79 +15,79 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/branches" do
it "should return an array of project branches" do
get api("/projects/#{project.id}/repository/branches", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['name'].should == project.repository.branch_names.first
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['name']).to eq(project.repository.branch_names.first)
end
end
describe "GET /projects/:id/repository/branches/:branch" do
it "should return the branch information for a single branch" do
get api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['name'].should == branch_name
- json_response['commit']['id'].should == branch_sha
- json_response['protected'].should == false
+ expect(json_response['name']).to eq(branch_name)
+ expect(json_response['commit']['id']).to eq(branch_sha)
+ expect(json_response['protected']).to eq(false)
end
it "should return a 403 error if guest" do
get api("/projects/#{project.id}/repository/branches", user2)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it "should return a 404 error if branch is not available" do
get api("/projects/#{project.id}/repository/branches/unknown", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe "PUT /projects/:id/repository/branches/:branch/protect" do
it "should protect a single branch" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['name'].should == branch_name
- json_response['commit']['id'].should == branch_sha
- json_response['protected'].should == true
+ expect(json_response['name']).to eq(branch_name)
+ expect(json_response['commit']['id']).to eq(branch_sha)
+ expect(json_response['protected']).to eq(true)
end
it "should return a 404 error if branch not found" do
put api("/projects/#{project.id}/repository/branches/unknown/protect", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return a 403 error if guest" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user2)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it "should return success when protect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/protect", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
describe "PUT /projects/:id/repository/branches/:branch/unprotect" do
it "should unprotect a single branch" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['name'].should == branch_name
- json_response['commit']['id'].should == branch_sha
- json_response['protected'].should == false
+ expect(json_response['name']).to eq(branch_name)
+ expect(json_response['commit']['id']).to eq(branch_sha)
+ expect(json_response['protected']).to eq(false)
end
it "should return success when unprotect branch" do
put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return success when unprotect branch again" do
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
put api("/projects/#{project.id}/repository/branches/#{branch_name}/unprotect", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
@@ -97,46 +97,46 @@ describe API::API, api: true do
branch_name: 'feature1',
ref: branch_sha
- response.status.should == 201
+ expect(response.status).to eq(201)
- json_response['name'].should == 'feature1'
- json_response['commit']['id'].should == branch_sha
+ expect(json_response['name']).to eq('feature1')
+ expect(json_response['commit']['id']).to eq(branch_sha)
end
it "should deny for user without push access" do
post api("/projects/#{project.id}/repository/branches", user2),
branch_name: branch_name,
ref: branch_sha
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should return 400 if branch name is invalid' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new design',
ref: branch_sha
- response.status.should == 400
- json_response['message'].should == 'Branch name invalid'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Branch name invalid')
end
it 'should return 400 if branch already exists' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design1',
ref: branch_sha
- response.status.should == 201
+ expect(response.status).to eq(201)
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design1',
ref: branch_sha
- response.status.should == 400
- json_response['message'].should == 'Branch already exists'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Branch already exists')
end
it 'should return 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/branches", user),
branch_name: 'new_design3',
ref: 'foo'
- response.status.should == 400
- json_response['message'].should == 'Invalid reference name'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Invalid reference name')
end
end
@@ -145,26 +145,26 @@ describe API::API, api: true do
it "should remove branch" do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
- response.status.should == 200
- json_response['branch_name'].should == branch_name
+ expect(response.status).to eq(200)
+ expect(json_response['branch_name']).to eq(branch_name)
end
it 'should return 404 if branch not exists' do
delete api("/projects/#{project.id}/repository/branches/foobar", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should remove protected branch" do
project.protected_branches.create(name: branch_name)
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
- response.status.should == 405
- json_response['message'].should == 'Protected branch cant be removed'
+ expect(response.status).to eq(405)
+ expect(json_response['message']).to eq('Protected branch cant be removed')
end
it "should not remove HEAD branch" do
delete api("/projects/#{project.id}/repository/branches/master", user)
- response.status.should == 405
- json_response['message'].should == 'Cannot remove HEAD branch'
+ expect(response.status).to eq(405)
+ expect(json_response['message']).to eq('Cannot remove HEAD branch')
end
end
end
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index a3f58f50913..9ea60e1a4ad 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -18,17 +18,17 @@ describe API::API, api: true do
it "should return project commits" do
get api("/projects/#{project.id}/repository/commits", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response.should be_an Array
- json_response.first['id'].should == project.repository.commit.id
+ expect(json_response).to be_an Array
+ expect(json_response.first['id']).to eq(project.repository.commit.id)
end
end
context "unauthorized user" do
it "should not return project commits" do
get api("/projects/#{project.id}/repository/commits")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
@@ -37,21 +37,21 @@ describe API::API, api: true do
context "authorized user" do
it "should return a commit by sha" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
- response.status.should == 200
- json_response['id'].should == project.repository.commit.id
- json_response['title'].should == project.repository.commit.title
+ expect(response.status).to eq(200)
+ expect(json_response['id']).to eq(project.repository.commit.id)
+ expect(json_response['title']).to eq(project.repository.commit.title)
end
it "should return a 404 error if not found" do
get api("/projects/#{project.id}/repository/commits/invalid_sha", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context "unauthorized user" do
it "should not return the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
@@ -62,23 +62,23 @@ describe API::API, api: true do
it "should return the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response.should be_an Array
- json_response.length.should >= 1
- json_response.first.keys.should include "diff"
+ expect(json_response).to be_an Array
+ expect(json_response.length).to be >= 1
+ expect(json_response.first.keys).to include "diff"
end
it "should return a 404 error if invalid commit" do
get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context "unauthorized user" do
it "should not return the diff of the selected commit" do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
@@ -87,23 +87,23 @@ describe API::API, api: true do
context 'authorized user' do
it 'should return merge_request comments' do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['note'].should == 'a comment on a commit'
- json_response.first['author']['id'].should == user.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['note']).to eq('a comment on a commit')
+ expect(json_response.first['author']['id']).to eq(user.id)
end
it 'should return a 404 error if merge_request_id not found' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context 'unauthorized user' do
it 'should not return the diff of the selected commit' do
get api("/projects/#{project.id}/repository/commits/1234ab/comments")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
@@ -112,37 +112,37 @@ describe API::API, api: true do
context 'authorized user' do
it 'should return comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment'
- response.status.should == 201
- json_response['note'].should == 'My comment'
- json_response['path'].should be_nil
- json_response['line'].should be_nil
- json_response['line_type'].should be_nil
+ expect(response.status).to eq(201)
+ expect(json_response['note']).to eq('My comment')
+ expect(json_response['path']).to be_nil
+ expect(json_response['line']).to be_nil
+ expect(json_response['line_type']).to be_nil
end
it 'should return the inline comment' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.diffs.first.new_path, line: 7, line_type: 'new'
- response.status.should == 201
- json_response['note'].should == 'My comment'
- json_response['path'].should == project.repository.commit.diffs.first.new_path
- json_response['line'].should == 7
- json_response['line_type'].should == 'new'
+ expect(response.status).to eq(201)
+ expect(json_response['note']).to eq('My comment')
+ expect(json_response['path']).to eq(project.repository.commit.diffs.first.new_path)
+ expect(json_response['line']).to eq(7)
+ expect(json_response['line_type']).to eq('new')
end
it 'should return 400 if note is missing' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 404 if note is attached to non existent commit' do
post api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context 'unauthorized user' do
it 'should not return the diff of the selected commit' do
post api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
diff --git a/spec/requests/api/doorkeeper_access_spec.rb b/spec/requests/api/doorkeeper_access_spec.rb
index ddef99d77af..39949a90422 100644
--- a/spec/requests/api/doorkeeper_access_spec.rb
+++ b/spec/requests/api/doorkeeper_access_spec.rb
@@ -11,21 +11,21 @@ describe API::API, api: true do
describe "when unauthenticated" do
it "returns authentication success" do
get api("/user"), :access_token => token.token
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
describe "when token invalid" do
it "returns authentication error" do
get api("/user"), :access_token => "123a"
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
describe "authorization by private token" do
it "returns authentication success" do
get api("/user", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
end
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index b43a202aec0..cfac7d289ec 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -16,15 +16,15 @@ describe API::API, api: true do
}
get api("/projects/#{project.id}/repository/files", user), params
- response.status.should == 200
- json_response['file_path'].should == file_path
- json_response['file_name'].should == 'popen.rb'
- Base64.decode64(json_response['content']).lines.first.should == "require 'fileutils'\n"
+ expect(response.status).to eq(200)
+ expect(json_response['file_path']).to eq(file_path)
+ expect(json_response['file_name']).to eq('popen.rb')
+ expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n")
end
it "should return a 400 bad request if no params given" do
get api("/projects/#{project.id}/repository/files", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 404 if such file does not exist" do
@@ -34,7 +34,7 @@ describe API::API, api: true do
}
get api("/projects/#{project.id}/repository/files", user), params
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -54,13 +54,13 @@ describe API::API, api: true do
)
post api("/projects/#{project.id}/repository/files", user), valid_params
- response.status.should == 201
- json_response['file_path'].should == 'newfile.rb'
+ expect(response.status).to eq(201)
+ expect(json_response['file_path']).to eq('newfile.rb')
end
it "should return a 400 bad request if no params given" do
post api("/projects/#{project.id}/repository/files", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 400 if satellite fails to create file" do
@@ -69,7 +69,7 @@ describe API::API, api: true do
)
post api("/projects/#{project.id}/repository/files", user), valid_params
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -89,13 +89,13 @@ describe API::API, api: true do
)
put api("/projects/#{project.id}/repository/files", user), valid_params
- response.status.should == 200
- json_response['file_path'].should == file_path
+ expect(response.status).to eq(200)
+ expect(json_response['file_path']).to eq(file_path)
end
it "should return a 400 bad request if no params given" do
put api("/projects/#{project.id}/repository/files", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 400 if satellite fails to create file" do
@@ -104,7 +104,7 @@ describe API::API, api: true do
)
put api("/projects/#{project.id}/repository/files", user), valid_params
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -123,13 +123,13 @@ describe API::API, api: true do
)
delete api("/projects/#{project.id}/repository/files", user), valid_params
- response.status.should == 200
- json_response['file_path'].should == file_path
+ expect(response.status).to eq(200)
+ expect(json_response['file_path']).to eq(file_path)
end
it "should return a 400 bad request if no params given" do
delete api("/projects/#{project.id}/repository/files", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 400 if satellite fails to create file" do
@@ -138,7 +138,7 @@ describe API::API, api: true do
)
delete api("/projects/#{project.id}/repository/files", user), valid_params
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
end
diff --git a/spec/requests/api/fork_spec.rb b/spec/requests/api/fork_spec.rb
index 5921b3e0698..fb3ff552c8d 100644
--- a/spec/requests/api/fork_spec.rb
+++ b/spec/requests/api/fork_spec.rb
@@ -23,50 +23,50 @@ describe API::API, api: true do
context 'when authenticated' do
it 'should fork if user has sufficient access to project' do
post api("/projects/fork/#{project.id}", user2)
- response.status.should == 201
- json_response['name'].should == project.name
- json_response['path'].should == project.path
- json_response['owner']['id'].should == user2.id
- json_response['namespace']['id'].should == user2.namespace.id
- json_response['forked_from_project']['id'].should == project.id
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq(project.name)
+ expect(json_response['path']).to eq(project.path)
+ expect(json_response['owner']['id']).to eq(user2.id)
+ expect(json_response['namespace']['id']).to eq(user2.namespace.id)
+ expect(json_response['forked_from_project']['id']).to eq(project.id)
end
it 'should fork if user is admin' do
post api("/projects/fork/#{project.id}", admin)
- response.status.should == 201
- json_response['name'].should == project.name
- json_response['path'].should == project.path
- json_response['owner']['id'].should == admin.id
- json_response['namespace']['id'].should == admin.namespace.id
- json_response['forked_from_project']['id'].should == project.id
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq(project.name)
+ expect(json_response['path']).to eq(project.path)
+ expect(json_response['owner']['id']).to eq(admin.id)
+ expect(json_response['namespace']['id']).to eq(admin.namespace.id)
+ expect(json_response['forked_from_project']['id']).to eq(project.id)
end
it 'should fail on missing project access for the project to fork' do
post api("/projects/fork/#{project.id}", user3)
- response.status.should == 404
- json_response['message'].should == '404 Project Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Project Not Found')
end
it 'should fail if forked project exists in the user namespace' do
post api("/projects/fork/#{project.id}", user)
- response.status.should == 409
- json_response['message']['base'].should == ['Invalid fork destination']
- json_response['message']['name'].should == ['has already been taken']
- json_response['message']['path'].should == ['has already been taken']
+ expect(response.status).to eq(409)
+ expect(json_response['message']['base']).to eq(['Invalid fork destination'])
+ expect(json_response['message']['name']).to eq(['has already been taken'])
+ expect(json_response['message']['path']).to eq(['has already been taken'])
end
it 'should fail if project to fork from does not exist' do
post api('/projects/fork/424242', user)
- response.status.should == 404
- json_response['message'].should == '404 Project Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Project Not Found')
end
end
context 'when unauthenticated' do
it 'should return authentication error' do
post api("/projects/fork/#{project.id}")
- response.status.should == 401
- json_response['message'].should == '401 Unauthorized'
+ expect(response.status).to eq(401)
+ expect(json_response['message']).to eq('401 Unauthorized')
end
end
end
diff --git a/spec/requests/api/group_members_spec.rb b/spec/requests/api/group_members_spec.rb
index 43d26d67efe..8ba6876a95b 100644
--- a/spec/requests/api/group_members_spec.rb
+++ b/spec/requests/api/group_members_spec.rb
@@ -31,20 +31,20 @@ describe API::API, api: true do
it "each user: should return an array of members groups of group3" do
[owner, master, developer, reporter, guest].each do |user|
get api("/groups/#{group_with_members.id}/members", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.size.should == 5
- json_response.find { |e| e['id']==owner.id }['access_level'].should == GroupMember::OWNER
- json_response.find { |e| e['id']==reporter.id }['access_level'].should == GroupMember::REPORTER
- json_response.find { |e| e['id']==developer.id }['access_level'].should == GroupMember::DEVELOPER
- json_response.find { |e| e['id']==master.id }['access_level'].should == GroupMember::MASTER
- json_response.find { |e| e['id']==guest.id }['access_level'].should == GroupMember::GUEST
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(5)
+ expect(json_response.find { |e| e['id']==owner.id }['access_level']).to eq(GroupMember::OWNER)
+ expect(json_response.find { |e| e['id']==reporter.id }['access_level']).to eq(GroupMember::REPORTER)
+ expect(json_response.find { |e| e['id']==developer.id }['access_level']).to eq(GroupMember::DEVELOPER)
+ expect(json_response.find { |e| e['id']==master.id }['access_level']).to eq(GroupMember::MASTER)
+ expect(json_response.find { |e| e['id']==guest.id }['access_level']).to eq(GroupMember::GUEST)
end
end
it "users not part of the group should get access error" do
get api("/groups/#{group_with_members.id}/members", stranger)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
end
@@ -53,7 +53,7 @@ describe API::API, api: true do
context "when not a member of the group" do
it "should not add guest as member of group_no_members when adding being done by person outside the group" do
post api("/groups/#{group_no_members.id}/members", reporter), user_id: guest.id, access_level: GroupMember::MASTER
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -66,9 +66,9 @@ describe API::API, api: true do
user_id: new_user.id, access_level: GroupMember::MASTER
}.to change { group_no_members.members.count }.by(1)
- response.status.should == 201
- json_response['name'].should == new_user.name
- json_response['access_level'].should == GroupMember::MASTER
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq(new_user.name)
+ expect(json_response['access_level']).to eq(GroupMember::MASTER)
end
it "should not allow guest to modify group members" do
@@ -79,27 +79,27 @@ describe API::API, api: true do
user_id: new_user.id, access_level: GroupMember::MASTER
}.not_to change { group_with_members.members.count }
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it "should return error if member already exists" do
post api("/groups/#{group_with_members.id}/members", owner), user_id: master.id, access_level: GroupMember::MASTER
- response.status.should == 409
+ expect(response.status).to eq(409)
end
it "should return a 400 error when user id is not given" do
post api("/groups/#{group_no_members.id}/members", owner), access_level: GroupMember::MASTER
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 400 error when access level is not given" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 422 error when access level is not known" do
post api("/groups/#{group_no_members.id}/members", owner), user_id: master.id, access_level: 1234
- response.status.should == 422
+ expect(response.status).to eq(422)
end
end
end
@@ -172,7 +172,7 @@ describe API::API, api: true do
it "should not delete guest's membership of group_with_members" do
random_user = create(:user)
delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -182,17 +182,17 @@ describe API::API, api: true do
delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner)
}.to change { group_with_members.members.count }.by(-1)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return a 404 error when user id is not known" do
delete api("/groups/#{group_with_members.id}/members/1328", owner)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should not allow guest to modify group members" do
delete api("/groups/#{group_with_members.id}/members/#{master.id}", guest)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
end
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 8465d765294..d963dbac9f1 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -18,26 +18,26 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
get api("/groups")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when authenticated as user" do
it "normal user: should return an array of groups of user1" do
get api("/groups", user1)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['name'].should == group1.name
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['name']).to eq(group1.name)
end
end
context "when authenticated as admin" do
it "admin: should return an array of all groups" do
get api("/groups", admin)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 2
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(2)
end
end
end
@@ -46,49 +46,49 @@ describe API::API, api: true do
context "when authenticated as user" do
it "should return one of user1's groups" do
get api("/groups/#{group1.id}", user1)
- response.status.should == 200
+ expect(response.status).to eq(200)
json_response['name'] == group1.name
end
it "should not return a non existing group" do
get api("/groups/1328", user1)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should not return a group not attached to user1" do
get api("/groups/#{group2.id}", user1)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
context "when authenticated as admin" do
it "should return any existing group" do
get api("/groups/#{group2.id}", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
json_response['name'] == group2.name
end
it "should not return a non existing group" do
get api("/groups/1328", admin)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context 'when using group path in URL' do
it 'should return any existing group' do
get api("/groups/#{group1.path}", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
json_response['name'] == group2.name
end
it 'should not return a non existing group' do
get api('/groups/unknown', admin)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it 'should not return a group not attached to user1' do
get api("/groups/#{group2.path}", user1)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
end
@@ -97,30 +97,30 @@ describe API::API, api: true do
context "when authenticated as user" do
it "should not create group" do
post api("/groups", user1), attributes_for(:group)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
context "when authenticated as admin" do
it "should create group" do
post api("/groups", admin), attributes_for(:group)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it "should not create group, duplicate" do
post api("/groups", admin), {name: "Duplicate Test", path: group2.path}
- response.status.should == 400
- response.message.should == "Bad Request"
+ expect(response.status).to eq(400)
+ expect(response.message).to eq("Bad Request")
end
it "should return 400 bad request error if name not given" do
post api("/groups", admin), {path: group2.path}
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 400 bad request error if path not given" do
post api("/groups", admin), { name: 'test' }
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
end
@@ -129,36 +129,36 @@ describe API::API, api: true do
context "when authenticated as user" do
it "should remove group" do
delete api("/groups/#{group1.id}", user1)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should not remove a group if not an owner" do
user3 = create(:user)
group1.add_user(user3, Gitlab::Access::MASTER)
delete api("/groups/#{group1.id}", user3)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it "should not remove a non existing group" do
delete api("/groups/1328", user1)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should not remove a group not attached to user1" do
delete api("/groups/#{group2.id}", user1)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
context "when authenticated as admin" do
it "should remove any existing group" do
delete api("/groups/#{group2.id}", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should not remove a non existing group" do
delete api("/groups/1328", admin)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
@@ -167,20 +167,20 @@ describe API::API, api: true do
let(:project) { create(:project) }
before(:each) do
Projects::TransferService.any_instance.stub(execute: true)
- Project.stub(:find).and_return(project)
+ allow(Project).to receive(:find).and_return(project)
end
context "when authenticated as user" do
it "should not transfer project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", user2)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
context "when authenticated as admin" do
it "should transfer project to group" do
post api("/groups/#{group1.id}/projects/#{project.id}", admin)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
end
end
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb
index 1e8e9eb38d6..10b467d85fd 100644
--- a/spec/requests/api/internal_spec.rb
+++ b/spec/requests/api/internal_spec.rb
@@ -11,8 +11,8 @@ describe API::API, api: true do
it do
get api("/internal/check"), secret_token: secret_token
- response.status.should == 200
- json_response['api_version'].should == API::API.version
+ expect(response.status).to eq(200)
+ expect(json_response['api_version']).to eq(API::API.version)
end
end
@@ -23,8 +23,8 @@ describe API::API, api: true do
it do
get api("/internal/broadcast_message"), secret_token: secret_token
- response.status.should == 200
- json_response["message"].should == broadcast_message.message
+ expect(response.status).to eq(200)
+ expect(json_response["message"]).to eq(broadcast_message.message)
end
end
@@ -32,7 +32,7 @@ describe API::API, api: true do
it do
get api("/internal/broadcast_message"), secret_token: secret_token
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
@@ -41,9 +41,9 @@ describe API::API, api: true do
it do
get(api("/internal/discover"), key_id: key.id, secret_token: secret_token)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['name'].should == user.name
+ expect(json_response['name']).to eq(user.name)
end
end
@@ -57,8 +57,8 @@ describe API::API, api: true do
it do
pull(key, project)
- response.status.should == 200
- json_response["status"].should be_true
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_truthy
end
end
@@ -66,8 +66,8 @@ describe API::API, api: true do
it do
push(key, project)
- response.status.should == 200
- json_response["status"].should be_true
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_truthy
end
end
end
@@ -81,8 +81,8 @@ describe API::API, api: true do
it do
pull(key, project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
@@ -90,8 +90,8 @@ describe API::API, api: true do
it do
push(key, project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
end
@@ -107,8 +107,8 @@ describe API::API, api: true do
it do
pull(key, personal_project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
@@ -116,8 +116,8 @@ describe API::API, api: true do
it do
push(key, personal_project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
end
@@ -134,8 +134,8 @@ describe API::API, api: true do
it do
pull(key, project)
- response.status.should == 200
- json_response["status"].should be_true
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_truthy
end
end
@@ -143,8 +143,8 @@ describe API::API, api: true do
it do
push(key, project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
end
@@ -160,8 +160,8 @@ describe API::API, api: true do
it do
archive(key, project)
- response.status.should == 200
- json_response["status"].should be_true
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_truthy
end
end
@@ -169,8 +169,8 @@ describe API::API, api: true do
it do
archive(key, project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
end
@@ -179,8 +179,8 @@ describe API::API, api: true do
it do
pull(key, OpenStruct.new(path_with_namespace: 'gitlab/notexists'))
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
@@ -188,8 +188,8 @@ describe API::API, api: true do
it do
pull(OpenStruct.new(id: 0), project)
- response.status.should == 200
- json_response["status"].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response["status"]).to be_falsey
end
end
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 775d7b4e18d..b6b0427debf 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -34,86 +34,87 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
get api("/issues")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when authenticated" do
it "should return an array of issues" do
get api("/issues", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['title'].should == issue.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(issue.title)
end
it "should add pagination headers" do
get api("/issues?per_page=3", user)
- response.headers['Link'].should ==
+ expect(response.headers['Link']).to eq(
'<http://www.example.com/api/v3/issues?page=1&per_page=3>; rel="first", <http://www.example.com/api/v3/issues?page=1&per_page=3>; rel="last"'
+ )
end
it 'should return an array of closed issues' do
get api('/issues?state=closed', user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['id'].should == closed_issue.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['id']).to eq(closed_issue.id)
end
it 'should return an array of opened issues' do
get api('/issues?state=opened', user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['id'].should == issue.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['id']).to eq(issue.id)
end
it 'should return an array of all issues' do
get api('/issues?state=all', user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 2
- json_response.first['id'].should == issue.id
- json_response.second['id'].should == closed_issue.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(2)
+ expect(json_response.first['id']).to eq(issue.id)
+ expect(json_response.second['id']).to eq(closed_issue.id)
end
it 'should return an array of labeled issues' do
get api("/issues?labels=#{label.title}", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['labels'].should == [label.title]
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['labels']).to eq([label.title])
end
it 'should return an array of labeled issues when at least one label matches' do
get api("/issues?labels=#{label.title},foo,bar", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['labels'].should == [label.title]
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['labels']).to eq([label.title])
end
it 'should return an empty array if no issue matches labels' do
get api('/issues?labels=foo,bar', user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 0
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(0)
end
it 'should return an array of labeled issues matching given state' do
get api("/issues?labels=#{label.title}&state=opened", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['labels'].should == [label.title]
- json_response.first['state'].should == 'opened'
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['labels']).to eq([label.title])
+ expect(json_response.first['state']).to eq('opened')
end
it 'should return an empty array if no issue matches labels and state filters' do
get api("/issues?labels=#{label.title}&state=closed", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 0
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(0)
end
end
end
@@ -124,78 +125,78 @@ describe API::API, api: true do
it "should return project issues" do
get api("#{base_url}/issues", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['title'].should == issue.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(issue.title)
end
it 'should return an array of labeled project issues' do
get api("#{base_url}/issues?labels=#{label.title}", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['labels'].should == [label.title]
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['labels']).to eq([label.title])
end
it 'should return an array of labeled project issues when at least one label matches' do
get api("#{base_url}/issues?labels=#{label.title},foo,bar", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['labels'].should == [label.title]
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['labels']).to eq([label.title])
end
it 'should return an empty array if no project issue matches labels' do
get api("#{base_url}/issues?labels=foo,bar", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 0
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(0)
end
it 'should return an empty array if no issue matches milestone' do
get api("#{base_url}/issues?milestone=#{empty_milestone.title}", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 0
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(0)
end
it 'should return an empty array if milestone does not exist' do
get api("#{base_url}/issues?milestone=foo", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 0
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(0)
end
it 'should return an array of issues in given milestone' do
get api("#{base_url}/issues?milestone=#{title}", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 2
- json_response.first['id'].should == issue.id
- json_response.second['id'].should == closed_issue.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(2)
+ expect(json_response.first['id']).to eq(issue.id)
+ expect(json_response.second['id']).to eq(closed_issue.id)
end
it 'should return an array of issues matching state in milestone' do
get api("#{base_url}/issues?milestone=#{milestone.title}"\
'&state=closed', user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['id'].should == closed_issue.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['id']).to eq(closed_issue.id)
end
end
describe "GET /projects/:id/issues/:issue_id" do
it "should return a project issue by id" do
get api("/projects/#{project.id}/issues/#{issue.id}", user)
- response.status.should == 200
- json_response['title'].should == issue.title
- json_response['iid'].should == issue.iid
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq(issue.title)
+ expect(json_response['iid']).to eq(issue.iid)
end
it "should return 404 if issue id not found" do
get api("/projects/#{project.id}/issues/54321", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -203,32 +204,32 @@ describe API::API, api: true do
it "should create a new project issue" do
post api("/projects/#{project.id}/issues", user),
title: 'new issue', labels: 'label, label2'
- response.status.should == 201
- json_response['title'].should == 'new issue'
- json_response['description'].should be_nil
- json_response['labels'].should == ['label', 'label2']
+ expect(response.status).to eq(201)
+ expect(json_response['title']).to eq('new issue')
+ expect(json_response['description']).to be_nil
+ expect(json_response['labels']).to eq(['label', 'label2'])
end
it "should return a 400 bad request if title not given" do
post api("/projects/#{project.id}/issues", user), labels: 'label, label2'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 400 on invalid label names' do
post api("/projects/#{project.id}/issues", user),
title: 'new issue',
labels: 'label, ?'
- response.status.should == 400
- json_response['message']['labels']['?']['title'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['labels']['?']['title']).to eq(['is invalid'])
end
it 'should return 400 if title is too long' do
post api("/projects/#{project.id}/issues", user),
title: 'g' * 256
- response.status.should == 400
- json_response['message']['title'].should == [
+ expect(response.status).to eq(400)
+ expect(json_response['message']['title']).to eq([
'is too long (maximum is 255 characters)'
- ]
+ ])
end
end
@@ -236,23 +237,23 @@ describe API::API, api: true do
it "should update a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title'
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['title'].should == 'updated title'
+ expect(json_response['title']).to eq('updated title')
end
it "should return 404 error if issue id not found" do
put api("/projects/#{project.id}/issues/44444", user),
title: 'updated title'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it 'should return 400 on invalid label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title',
labels: 'label, ?'
- response.status.should == 400
- json_response['message']['labels']['?']['title'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['labels']['?']['title']).to eq(['is invalid'])
end
end
@@ -263,49 +264,49 @@ describe API::API, api: true do
it 'should not update labels if not present' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title'
- response.status.should == 200
- json_response['labels'].should == [label.title]
+ expect(response.status).to eq(200)
+ expect(json_response['labels']).to eq([label.title])
end
it 'should remove all labels' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: ''
- response.status.should == 200
- json_response['labels'].should == []
+ expect(response.status).to eq(200)
+ expect(json_response['labels']).to eq([])
end
it 'should update labels' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'foo,bar'
- response.status.should == 200
- json_response['labels'].should include 'foo'
- json_response['labels'].should include 'bar'
+ expect(response.status).to eq(200)
+ expect(json_response['labels']).to include 'foo'
+ expect(json_response['labels']).to include 'bar'
end
it 'should return 400 on invalid label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label, ?'
- response.status.should == 400
- json_response['message']['labels']['?']['title'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['labels']['?']['title']).to eq(['is invalid'])
end
it 'should allow special label names' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label:foo, label-bar,label_bar,label/bar'
- response.status.should == 200
- json_response['labels'].should include 'label:foo'
- json_response['labels'].should include 'label-bar'
- json_response['labels'].should include 'label_bar'
- json_response['labels'].should include 'label/bar'
+ expect(response.status).to eq(200)
+ expect(json_response['labels']).to include 'label:foo'
+ expect(json_response['labels']).to include 'label-bar'
+ expect(json_response['labels']).to include 'label_bar'
+ expect(json_response['labels']).to include 'label/bar'
end
it 'should return 400 if title is too long' do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'g' * 256
- response.status.should == 400
- json_response['message']['title'].should == [
+ expect(response.status).to eq(400)
+ expect(json_response['message']['title']).to eq([
'is too long (maximum is 255 characters)'
- ]
+ ])
end
end
@@ -313,17 +314,17 @@ describe API::API, api: true do
it "should update a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label2', state_event: "close"
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['labels'].should include 'label2'
- json_response['state'].should eq "closed"
+ expect(json_response['labels']).to include 'label2'
+ expect(json_response['state']).to eq "closed"
end
end
describe "DELETE /projects/:id/issues/:issue_id" do
it "should delete a project issue" do
delete api("/projects/#{project.id}/issues/#{issue.id}", user)
- response.status.should == 405
+ expect(response.status).to eq(405)
end
end
end
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb
index dbddc8a7da4..aff109a9424 100644
--- a/spec/requests/api/labels_spec.rb
+++ b/spec/requests/api/labels_spec.rb
@@ -15,10 +15,10 @@ describe API::API, api: true do
describe 'GET /projects/:id/labels' do
it 'should return project labels' do
get api("/projects/#{project.id}/labels", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.size.should == 1
- json_response.first['name'].should == label1.name
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(1)
+ expect(json_response.first['name']).to eq(label1.name)
end
end
@@ -27,69 +27,69 @@ describe API::API, api: true do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAABB'
- response.status.should == 201
- json_response['name'].should == 'Foo'
- json_response['color'].should == '#FFAABB'
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq('Foo')
+ expect(json_response['color']).to eq('#FFAABB')
end
it 'should return a 400 bad request if name not given' do
post api("/projects/#{project.id}/labels", user), color: '#FFAABB'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return a 400 bad request if color not given' do
post api("/projects/#{project.id}/labels", user), name: 'Foobar'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 400 for invalid color' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAA'
- response.status.should == 400
- json_response['message']['color'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['color']).to eq(['is invalid'])
end
it 'should return 400 for too long color code' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAAFFFF'
- response.status.should == 400
- json_response['message']['color'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['color']).to eq(['is invalid'])
end
it 'should return 400 for invalid name' do
post api("/projects/#{project.id}/labels", user),
name: '?',
color: '#FFAABB'
- response.status.should == 400
- json_response['message']['title'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['title']).to eq(['is invalid'])
end
it 'should return 409 if label already exists' do
post api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FFAABB'
- response.status.should == 409
- json_response['message'].should == 'Label already exists'
+ expect(response.status).to eq(409)
+ expect(json_response['message']).to eq('Label already exists')
end
end
describe 'DELETE /projects/:id/labels' do
it 'should return 200 for existing label' do
delete api("/projects/#{project.id}/labels", user), name: 'label1'
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should return 404 for non existing label' do
delete api("/projects/#{project.id}/labels", user), name: 'label2'
- response.status.should == 404
- json_response['message'].should == '404 Label Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Label Not Found')
end
it 'should return 400 for wrong parameters' do
delete api("/projects/#{project.id}/labels", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -99,47 +99,47 @@ describe API::API, api: true do
name: 'label1',
new_name: 'New Label',
color: '#FFFFFF'
- response.status.should == 200
- json_response['name'].should == 'New Label'
- json_response['color'].should == '#FFFFFF'
+ expect(response.status).to eq(200)
+ expect(json_response['name']).to eq('New Label')
+ expect(json_response['color']).to eq('#FFFFFF')
end
it 'should return 200 if name is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
new_name: 'New Label'
- response.status.should == 200
- json_response['name'].should == 'New Label'
- json_response['color'].should == label1.color
+ expect(response.status).to eq(200)
+ expect(json_response['name']).to eq('New Label')
+ expect(json_response['color']).to eq(label1.color)
end
it 'should return 200 if colors is changed' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FFFFFF'
- response.status.should == 200
- json_response['name'].should == label1.name
- json_response['color'].should == '#FFFFFF'
+ expect(response.status).to eq(200)
+ expect(json_response['name']).to eq(label1.name)
+ expect(json_response['color']).to eq('#FFFFFF')
end
it 'should return 404 if label does not exist' do
put api("/projects/#{project.id}/labels", user),
name: 'label2',
new_name: 'label3'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it 'should return 400 if no label name given' do
put api("/projects/#{project.id}/labels", user), new_name: 'label2'
- response.status.should == 400
- json_response['message'].should == '400 (Bad request) "name" not given'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('400 (Bad request) "name" not given')
end
it 'should return 400 if no new parameters given' do
put api("/projects/#{project.id}/labels", user), name: 'label1'
- response.status.should == 400
- json_response['message'].should == 'Required parameters '\
- '"new_name" or "color" missing'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Required parameters '\
+ '"new_name" or "color" missing')
end
it 'should return 400 for invalid name' do
@@ -147,24 +147,24 @@ describe API::API, api: true do
name: 'label1',
new_name: '?',
color: '#FFFFFF'
- response.status.should == 400
- json_response['message']['title'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['title']).to eq(['is invalid'])
end
it 'should return 400 for invalid name' do
put api("/projects/#{project.id}/labels", user),
name: 'label1',
color: '#FF'
- response.status.should == 400
- json_response['message']['color'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['color']).to eq(['is invalid'])
end
it 'should return 400 for too long color code' do
post api("/projects/#{project.id}/labels", user),
name: 'Foo',
color: '#FFAAFFFF'
- response.status.should == 400
- json_response['message']['color'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['color']).to eq(['is invalid'])
end
end
end
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index b5deb072cd1..9e252441a4f 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -16,50 +16,50 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
get api("/projects/#{project.id}/merge_requests")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when authenticated" do
it "should return an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 3
- json_response.last['title'].should == merge_request.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(3)
+ expect(json_response.last['title']).to eq(merge_request.title)
end
it "should return an array of all merge_requests" do
get api("/projects/#{project.id}/merge_requests?state", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 3
- json_response.last['title'].should == merge_request.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(3)
+ expect(json_response.last['title']).to eq(merge_request.title)
end
it "should return an array of open merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=opened", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.last['title'].should == merge_request.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.last['title']).to eq(merge_request.title)
end
it "should return an array of closed merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=closed", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 2
- json_response.second['title'].should == merge_request_closed.title
- json_response.first['title'].should == merge_request_merged.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(2)
+ expect(json_response.second['title']).to eq(merge_request_closed.title)
+ expect(json_response.first['title']).to eq(merge_request_merged.title)
end
it "should return an array of merged merge_requests" do
get api("/projects/#{project.id}/merge_requests?state=merged", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['title'].should == merge_request_merged.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['title']).to eq(merge_request_merged.title)
end
context "with ordering" do
@@ -70,38 +70,38 @@ describe API::API, api: true do
it "should return an array of merge_requests in ascending order" do
get api("/projects/#{project.id}/merge_requests?sort=asc", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 3
- json_response.last['id'].should == @mr_earlier.id
- json_response.first['id'].should == @mr_later.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(3)
+ expect(json_response.last['id']).to eq(@mr_earlier.id)
+ expect(json_response.first['id']).to eq(@mr_later.id)
end
it "should return an array of merge_requests in descending order" do
get api("/projects/#{project.id}/merge_requests?sort=desc", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 3
- json_response.first['id'].should == @mr_later.id
- json_response.last['id'].should == @mr_earlier.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(3)
+ expect(json_response.first['id']).to eq(@mr_later.id)
+ expect(json_response.last['id']).to eq(@mr_earlier.id)
end
it "should return an array of merge_requests ordered by updated_at" do
get api("/projects/#{project.id}/merge_requests?order_by=updated_at", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 3
- json_response.last['id'].should == @mr_earlier.id
- json_response.first['id'].should == @mr_later.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(3)
+ expect(json_response.last['id']).to eq(@mr_earlier.id)
+ expect(json_response.first['id']).to eq(@mr_later.id)
end
it "should return an array of merge_requests ordered by created_at" do
get api("/projects/#{project.id}/merge_requests?sort=created_at", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 3
- json_response.last['id'].should == @mr_earlier.id
- json_response.first['id'].should == @mr_later.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(3)
+ expect(json_response.last['id']).to eq(@mr_earlier.id)
+ expect(json_response.first['id']).to eq(@mr_later.id)
end
end
end
@@ -110,14 +110,14 @@ describe API::API, api: true do
describe "GET /projects/:id/merge_request/:merge_request_id" do
it "should return merge_request" do
get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user)
- response.status.should == 200
- json_response['title'].should == merge_request.title
- json_response['iid'].should == merge_request.iid
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq(merge_request.title)
+ expect(json_response['iid']).to eq(merge_request.iid)
end
it "should return a 404 error if merge_request_id not found" do
get api("/projects/#{project.id}/merge_request/999", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -143,33 +143,33 @@ describe API::API, api: true do
target_branch: 'master',
author: user,
labels: 'label, label2'
- response.status.should == 201
- json_response['title'].should == 'Test merge_request'
- json_response['labels'].should == ['label', 'label2']
+ expect(response.status).to eq(201)
+ expect(json_response['title']).to eq('Test merge_request')
+ expect(json_response['labels']).to eq(['label', 'label2'])
end
it "should return 422 when source_branch equals target_branch" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "master", target_branch: "master", author: user
- response.status.should == 422
+ expect(response.status).to eq(422)
end
it "should return 400 when source_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", target_branch: "master", author: user
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 400 when target_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
title: "Test merge_request", source_branch: "stable", author: user
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 400 when title is missing" do
post api("/projects/#{project.id}/merge_requests", user),
target_branch: 'master', source_branch: 'stable'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 400 on invalid label names' do
@@ -179,9 +179,10 @@ describe API::API, api: true do
target_branch: 'master',
author: user,
labels: 'label, ?'
- response.status.should == 400
- json_response['message']['labels']['?']['title'].should ==
+ expect(response.status).to eq(400)
+ expect(json_response['message']['labels']['?']['title']).to eq(
['is invalid']
+ )
end
context 'with existing MR' do
@@ -202,7 +203,7 @@ describe API::API, api: true do
target_branch: 'master',
author: user
end.to change { MergeRequest.count }.by(0)
- response.status.should == 409
+ expect(response.status).to eq(409)
end
end
end
@@ -219,37 +220,37 @@ describe API::API, api: true do
it "should return merge_request" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user2, target_project_id: project.id, description: 'Test description for Test merge_request'
- response.status.should == 201
- json_response['title'].should == 'Test merge_request'
- json_response['description'].should == 'Test description for Test merge_request'
+ expect(response.status).to eq(201)
+ expect(json_response['title']).to eq('Test merge_request')
+ expect(json_response['description']).to eq('Test description for Test merge_request')
end
it "should not return 422 when source_branch equals target_branch" do
- project.id.should_not == fork_project.id
- fork_project.forked?.should be_true
- fork_project.forked_from_project.should == project
+ expect(project.id).not_to eq(fork_project.id)
+ expect(fork_project.forked?).to be_truthy
+ expect(fork_project.forked_from_project).to eq(project)
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id
- response.status.should == 201
- json_response['title'].should == 'Test merge_request'
+ expect(response.status).to eq(201)
+ expect(json_response['title']).to eq('Test merge_request')
end
it "should return 400 when source_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 400 when target_branch is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 400 when title is missing" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: project.id
- response.status.should == 400
+ expect(response.status).to eq(400)
end
context 'when target_branch is specified' do
@@ -260,7 +261,7 @@ describe API::API, api: true do
source_branch: 'stable',
author: user,
target_project_id: fork_project.id
- response.status.should == 422
+ expect(response.status).to eq(422)
end
it 'should return 422 if targeting a different fork' do
@@ -270,14 +271,14 @@ describe API::API, api: true do
source_branch: 'stable',
author: user2,
target_project_id: unrelated_project.id
- response.status.should == 422
+ expect(response.status).to eq(422)
end
end
it "should return 201 when target_branch is specified and for the same project" do
post api("/projects/#{fork_project.id}/merge_requests", user2),
title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id
- response.status.should == 201
+ expect(response.status).to eq(201)
end
end
end
@@ -285,8 +286,8 @@ describe API::API, api: true do
describe "PUT /projects/:id/merge_request/:merge_request_id to close MR" do
it "should return merge_request" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "close"
- response.status.should == 200
- json_response['state'].should == 'closed'
+ expect(response.status).to eq(200)
+ expect(json_response['state']).to eq('closed')
end
end
@@ -294,55 +295,55 @@ describe API::API, api: true do
it "should return merge_request in case of success" do
MergeRequest.any_instance.stub(can_be_merged?: true, automerge!: true)
put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return 405 if branch can't be merged" do
MergeRequest.any_instance.stub(can_be_merged?: false)
put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
- response.status.should == 405
- json_response['message'].should == 'Branch cannot be merged'
+ expect(response.status).to eq(405)
+ expect(json_response['message']).to eq('Branch cannot be merged')
end
it "should return 405 if merge_request is not open" do
merge_request.close
put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user)
- response.status.should == 405
- json_response['message'].should == '405 Method Not Allowed'
+ expect(response.status).to eq(405)
+ expect(json_response['message']).to eq('405 Method Not Allowed')
end
it "should return 401 if user has no permissions to merge" do
user2 = create(:user)
project.team << [user2, :reporter]
put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user2)
- response.status.should == 401
- json_response['message'].should == '401 Unauthorized'
+ expect(response.status).to eq(401)
+ expect(json_response['message']).to eq('401 Unauthorized')
end
end
describe "PUT /projects/:id/merge_request/:merge_request_id" do
it "should return merge_request" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title"
- response.status.should == 200
- json_response['title'].should == 'New title'
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq('New title')
end
it "should return merge_request" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), description: "New description"
- response.status.should == 200
- json_response['description'].should == 'New description'
+ expect(response.status).to eq(200)
+ expect(json_response['description']).to eq('New description')
end
it "should return 422 when source_branch and target_branch are renamed the same" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user),
source_branch: "master", target_branch: "master"
- response.status.should == 422
+ expect(response.status).to eq(422)
end
it "should return merge_request with renamed target_branch" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), target_branch: "wiki"
- response.status.should == 200
- json_response['target_branch'].should == 'wiki'
+ expect(response.status).to eq(200)
+ expect(json_response['target_branch']).to eq('wiki')
end
it 'should return 400 on invalid label names' do
@@ -350,43 +351,43 @@ describe API::API, api: true do
user),
title: 'new issue',
labels: 'label, ?'
- response.status.should == 400
- json_response['message']['labels']['?']['title'].should == ['is invalid']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['labels']['?']['title']).to eq(['is invalid'])
end
end
describe "POST /projects/:id/merge_request/:merge_request_id/comments" do
it "should return comment" do
post api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user), note: "My comment"
- response.status.should == 201
- json_response['note'].should == 'My comment'
+ expect(response.status).to eq(201)
+ expect(json_response['note']).to eq('My comment')
end
it "should return 400 if note is missing" do
post api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 404 if note is attached to non existent merge request" do
post api("/projects/#{project.id}/merge_request/404/comments", user),
note: 'My comment'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe "GET :id/merge_request/:merge_request_id/comments" do
it "should return merge_request comments" do
get api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.length.should == 1
- json_response.first['note'].should == "a comment on a MR"
- json_response.first['author']['id'].should == user.id
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first['note']).to eq("a comment on a MR")
+ expect(json_response.first['author']['id']).to eq(user.id)
end
it "should return a 404 error if merge_request_id not found" do
get api("/projects/#{project.id}/merge_request/999/comments", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb
index 647033309bd..effb0723476 100644
--- a/spec/requests/api/milestones_spec.rb
+++ b/spec/requests/api/milestones_spec.rb
@@ -11,55 +11,55 @@ describe API::API, api: true do
describe 'GET /projects/:id/milestones' do
it 'should return project milestones' do
get api("/projects/#{project.id}/milestones", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['title'].should == milestone.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(milestone.title)
end
it 'should return a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
describe 'GET /projects/:id/milestones/:milestone_id' do
it 'should return a project milestone by id' do
get api("/projects/#{project.id}/milestones/#{milestone.id}", user)
- response.status.should == 200
- json_response['title'].should == milestone.title
- json_response['iid'].should == milestone.iid
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq(milestone.title)
+ expect(json_response['iid']).to eq(milestone.iid)
end
it 'should return 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
it 'should return a 404 error if milestone id not found' do
get api("/projects/#{project.id}/milestones/1234", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe 'POST /projects/:id/milestones' do
it 'should create a new project milestone' do
post api("/projects/#{project.id}/milestones", user), title: 'new milestone'
- response.status.should == 201
- json_response['title'].should == 'new milestone'
- json_response['description'].should be_nil
+ expect(response.status).to eq(201)
+ expect(json_response['title']).to eq('new milestone')
+ expect(json_response['description']).to be_nil
end
it 'should create a new project milestone with description and due date' do
post api("/projects/#{project.id}/milestones", user),
title: 'new milestone', description: 'release', due_date: '2013-03-02'
- response.status.should == 201
- json_response['description'].should == 'release'
- json_response['due_date'].should == '2013-03-02'
+ expect(response.status).to eq(201)
+ expect(json_response['description']).to eq('release')
+ expect(json_response['due_date']).to eq('2013-03-02')
end
it 'should return a 400 error if title is missing' do
post api("/projects/#{project.id}/milestones", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -67,14 +67,14 @@ describe API::API, api: true do
it 'should update a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
title: 'updated title'
- response.status.should == 200
- json_response['title'].should == 'updated title'
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq('updated title')
end
it 'should return a 404 error if milestone id not found' do
put api("/projects/#{project.id}/milestones/1234", user),
title: 'updated title'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -82,15 +82,15 @@ describe API::API, api: true do
it 'should update a project milestone' do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
state_event: 'close'
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response['state'].should == 'closed'
+ expect(json_response['state']).to eq('closed')
end
end
describe 'PUT /projects/:id/milestones/:milestone_id to test observer on close' do
it 'should create an activity event when an milestone is closed' do
- Event.should_receive(:create)
+ expect(Event).to receive(:create)
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
state_event: 'close'
@@ -103,14 +103,14 @@ describe API::API, api: true do
end
it 'should return project issues for a particular milestone' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['milestone']['title'].should == milestone.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['milestone']['title']).to eq(milestone.title)
end
it 'should return a 401 error if user not authenticated' do
get api("/projects/#{project.id}/milestones/#{milestone.id}/issues")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb
index b8943ea0762..6ddaaa0a6dd 100644
--- a/spec/requests/api/namespaces_spec.rb
+++ b/spec/requests/api/namespaces_spec.rb
@@ -10,17 +10,17 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
get api("/namespaces")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when authenticated as admin" do
it "admin: should return an array of all namespaces" do
get api("/namespaces", admin)
- response.status.should == 200
- json_response.should be_an Array
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
- json_response.length.should == Namespace.count
+ expect(json_response.length).to eq(Namespace.count)
end
end
end
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 429824e829a..8b177af4689 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -16,42 +16,42 @@ describe API::API, api: true do
context "when noteable is an Issue" do
it "should return an array of issue notes" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['body'].should == issue_note.note
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['body']).to eq(issue_note.note)
end
it "should return a 404 error when issue id not found" do
get api("/projects/#{project.id}/issues/123/notes", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context "when noteable is a Snippet" do
it "should return an array of snippet notes" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['body'].should == snippet_note.note
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['body']).to eq(snippet_note.note)
end
it "should return a 404 error when snippet id not found" do
get api("/projects/#{project.id}/snippets/42/notes", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context "when noteable is a Merge Request" do
it "should return an array of merge_requests notes" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['body'].should == merge_request_note.note
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['body']).to eq(merge_request_note.note)
end
it "should return a 404 error if merge request id not found" do
get api("/projects/#{project.id}/merge_requests/4444/notes", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
@@ -60,26 +60,26 @@ describe API::API, api: true do
context "when noteable is an Issue" do
it "should return an issue note by id" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", user)
- response.status.should == 200
- json_response['body'].should == issue_note.note
+ expect(response.status).to eq(200)
+ expect(json_response['body']).to eq(issue_note.note)
end
it "should return a 404 error if issue note not found" do
get api("/projects/#{project.id}/issues/#{issue.id}/notes/123", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context "when noteable is a Snippet" do
it "should return a snippet note by id" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user)
- response.status.should == 200
- json_response['body'].should == snippet_note.note
+ expect(response.status).to eq(200)
+ expect(json_response['body']).to eq(snippet_note.note)
end
it "should return a 404 error if snippet note not found" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/123", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
@@ -88,45 +88,45 @@ describe API::API, api: true do
context "when noteable is an Issue" do
it "should create a new issue note" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
- response.status.should == 201
- json_response['body'].should == 'hi!'
- json_response['author']['username'].should == user.username
+ expect(response.status).to eq(201)
+ expect(json_response['body']).to eq('hi!')
+ expect(json_response['author']['username']).to eq(user.username)
end
it "should return a 400 bad request error if body not given" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 401 unauthorized error if user not authenticated" do
post api("/projects/#{project.id}/issues/#{issue.id}/notes"), body: 'hi!'
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when noteable is a Snippet" do
it "should create a new snippet note" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!'
- response.status.should == 201
- json_response['body'].should == 'hi!'
- json_response['author']['username'].should == user.username
+ expect(response.status).to eq(201)
+ expect(json_response['body']).to eq('hi!')
+ expect(json_response['author']['username']).to eq(user.username)
end
it "should return a 400 bad request error if body not given" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 401 unauthorized error if user not authenticated" do
post api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!'
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
describe "POST /projects/:id/noteable/:noteable_id/notes to test observer on create" do
it "should create an activity event when an issue note is created" do
- Event.should_receive(:create)
+ expect(Event).to receive(:create)
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!'
end
@@ -137,20 +137,20 @@ describe API::API, api: true do
it 'should return modified note' do
put api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user), body: 'Hello!'
- response.status.should == 200
- json_response['body'].should == 'Hello!'
+ expect(response.status).to eq(200)
+ expect(json_response['body']).to eq('Hello!')
end
it 'should return a 404 error when note id not found' do
put api("/projects/#{project.id}/issues/#{issue.id}/notes/123", user),
body: 'Hello!'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it 'should return a 400 bad request error if body not given' do
put api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -158,14 +158,14 @@ describe API::API, api: true do
it 'should return modified note' do
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user), body: 'Hello!'
- response.status.should == 200
- json_response['body'].should == 'Hello!'
+ expect(response.status).to eq(200)
+ expect(json_response['body']).to eq('Hello!')
end
it 'should return a 404 error when note id not found' do
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/123", user), body: "Hello!"
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -173,14 +173,14 @@ describe API::API, api: true do
it 'should return modified note' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
"notes/#{merge_request_note.id}", user), body: 'Hello!'
- response.status.should == 200
- json_response['body'].should == 'Hello!'
+ expect(response.status).to eq(200)
+ expect(json_response['body']).to eq('Hello!')
end
it 'should return a 404 error when note id not found' do
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
"notes/123", user), body: "Hello!"
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index cdb5e3d0612..81fe68de662 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -16,18 +16,18 @@ describe API::API, 'ProjectHooks', api: true do
context "authorized user" do
it "should return project hooks" do
get api("/projects/#{project.id}/hooks", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response.should be_an Array
- json_response.count.should == 1
- json_response.first['url'].should == "http://example.com"
+ expect(json_response).to be_an Array
+ expect(json_response.count).to eq(1)
+ expect(json_response.first['url']).to eq("http://example.com")
end
end
context "unauthorized user" do
it "should not access project hooks" do
get api("/projects/#{project.id}/hooks", user3)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
end
@@ -36,26 +36,26 @@ describe API::API, 'ProjectHooks', api: true do
context "authorized user" do
it "should return a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
- response.status.should == 200
- json_response['url'].should == hook.url
+ expect(response.status).to eq(200)
+ expect(json_response['url']).to eq(hook.url)
end
it "should return a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context "unauthorized user" do
it "should not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
it "should return a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -65,17 +65,17 @@ describe API::API, 'ProjectHooks', api: true do
post api("/projects/#{project.id}/hooks", user),
url: "http://example.com", issues_events: true
}.to change {project.hooks.count}.by(1)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it "should return a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com"
- response.status.should == 422
+ expect(response.status).to eq(422)
end
end
@@ -83,23 +83,23 @@ describe API::API, 'ProjectHooks', api: true do
it "should update an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
url: 'http://example.org', push_events: false
- response.status.should == 200
- json_response['url'].should == 'http://example.org'
+ expect(response.status).to eq(200)
+ expect(json_response['url']).to eq('http://example.org')
end
it "should return 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org'
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com'
- response.status.should == 422
+ expect(response.status).to eq(422)
end
end
@@ -108,22 +108,22 @@ describe API::API, 'ProjectHooks', api: true do
expect {
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
}.to change {project.hooks.count}.by(-1)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return success when deleting hook" do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return success when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return a 405 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user)
- response.status.should == 405
+ expect(response.status).to eq(405)
end
end
end
diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb
index 836f21f3e0b..8419a364ed1 100644
--- a/spec/requests/api/project_members_spec.rb
+++ b/spec/requests/api/project_members_spec.rb
@@ -15,23 +15,23 @@ describe API::API, api: true do
it "should return project team members" do
get api("/projects/#{project.id}/members", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.count.should == 2
- json_response.map { |u| u['username'] }.should include user.username
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.count).to eq(2)
+ expect(json_response.map { |u| u['username'] }).to include user.username
end
it "finds team members with query string" do
get api("/projects/#{project.id}/members", user), query: user.username
- response.status.should == 200
- json_response.should be_an Array
- json_response.count.should == 1
- json_response.first['username'].should == user.username
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.count).to eq(1)
+ expect(json_response.first['username']).to eq(user.username)
end
it "should return a 404 error if id not found" do
get api("/projects/9999/members", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -40,14 +40,14 @@ describe API::API, api: true do
it "should return project team member" do
get api("/projects/#{project.id}/members/#{user.id}", user)
- response.status.should == 200
- json_response['username'].should == user.username
- json_response['access_level'].should == ProjectMember::MASTER
+ expect(response.status).to eq(200)
+ expect(json_response['username']).to eq(user.username)
+ expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end
it "should return a 404 error if user id not found" do
get api("/projects/#{project.id}/members/1234", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -58,9 +58,9 @@ describe API::API, api: true do
access_level: ProjectMember::DEVELOPER
}.to change { ProjectMember.count }.by(1)
- response.status.should == 201
- json_response['username'].should == user2.username
- json_response['access_level'].should == ProjectMember::DEVELOPER
+ expect(response.status).to eq(201)
+ expect(json_response['username']).to eq(user2.username)
+ expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end
it "should return a 201 status if user is already project member" do
@@ -69,26 +69,26 @@ describe API::API, api: true do
expect {
post api("/projects/#{project.id}/members", user), user_id: user2.id,
access_level: ProjectMember::DEVELOPER
- }.not_to change { ProjectMember.count }.by(1)
+ }.not_to change { ProjectMember.count }
- response.status.should == 201
- json_response['username'].should == user2.username
- json_response['access_level'].should == ProjectMember::DEVELOPER
+ expect(response.status).to eq(201)
+ expect(json_response['username']).to eq(user2.username)
+ expect(json_response['access_level']).to eq(ProjectMember::DEVELOPER)
end
it "should return a 400 error when user id is not given" do
post api("/projects/#{project.id}/members", user), access_level: ProjectMember::MASTER
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 400 error when access level is not given" do
post api("/projects/#{project.id}/members", user), user_id: user2.id
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 422 error when access level is not known" do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234
- response.status.should == 422
+ expect(response.status).to eq(422)
end
end
@@ -97,24 +97,24 @@ describe API::API, api: true do
it "should update project team member" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: ProjectMember::MASTER
- response.status.should == 200
- json_response['username'].should == user3.username
- json_response['access_level'].should == ProjectMember::MASTER
+ expect(response.status).to eq(200)
+ expect(json_response['username']).to eq(user3.username)
+ expect(json_response['access_level']).to eq(ProjectMember::MASTER)
end
it "should return a 404 error if user_id is not found" do
put api("/projects/#{project.id}/members/1234", user), access_level: ProjectMember::MASTER
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return a 400 error when access level is not given" do
put api("/projects/#{project.id}/members/#{user3.id}", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return a 422 error when access level is not known" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123
- response.status.should == 422
+ expect(response.status).to eq(422)
end
end
@@ -132,22 +132,22 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect {
delete api("/projects/#{project.id}/members/#{user3.id}", user)
- }.to_not change { ProjectMember.count }.by(1)
+ }.to_not change { ProjectMember.count }
end
it "should return 200 if team member already removed" do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
delete api("/projects/#{project.id}/members/#{user3.id}", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return 200 OK when the user was not member" do
expect {
delete api("/projects/#{project.id}/members/1000000", user)
}.to change { ProjectMember.count }.by(0)
- response.status.should == 200
- json_response['message'].should == "Access revoked"
- json_response['id'].should == 1000000
+ expect(response.status).to eq(200)
+ expect(json_response['message']).to eq("Access revoked")
+ expect(json_response['id']).to eq(1000000)
end
end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 65c894ac0c2..170ede57310 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -44,25 +44,25 @@ describe API::API, api: true do
context 'when unauthenticated' do
it 'should return authentication error' do
get api('/projects')
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context 'when authenticated' do
it 'should return an array of projects' do
get api('/projects', user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['name'].should == project.name
- json_response.first['owner']['username'].should == user.username
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['name']).to eq(project.name)
+ expect(json_response.first['owner']['username']).to eq(user.username)
end
context 'and using search' do
it 'should return searched project' do
get api('/projects', user), { search: project.name }
- response.status.should eq(200)
- json_response.should be_an Array
- json_response.length.should eq(1)
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
end
end
@@ -74,9 +74,9 @@ describe API::API, api: true do
it 'should return the correct order when sorted by id' do
get api('/projects', user), { order_by: 'id', sort: 'desc'}
- response.status.should eq(200)
- json_response.should be_an Array
- json_response.first['id'].should eq(project3.id)
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['id']).to eq(project3.id)
end
end
end
@@ -88,31 +88,31 @@ describe API::API, api: true do
context 'when unauthenticated' do
it 'should return authentication error' do
get api('/projects/all')
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context 'when authenticated as regular user' do
it 'should return authentication error' do
get api('/projects/all', user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
context 'when authenticated as admin' do
it 'should return an array of all projects' do
get api('/projects/all', admin)
- response.status.should == 200
- json_response.should be_an Array
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
project_name = project.name
- json_response.detect {
+ expect(json_response.detect {
|project| project['name'] == project_name
- }['name'].should == project_name
+ }['name']).to eq(project_name)
- json_response.detect {
+ expect(json_response.detect {
|project| project['owner']['username'] == user.username
- }['owner']['username'].should == user.username
+ }['owner']['username']).to eq(user.username)
end
end
end
@@ -120,29 +120,29 @@ describe API::API, api: true do
describe 'POST /projects' do
context 'maximum number of projects reached' do
it 'should not create new project and respond with 403' do
- User.any_instance.stub(:projects_limit_left).and_return(0)
+ allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0)
expect {
post api('/projects', user2), name: 'foo'
}.to change {Project.count}.by(0)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
it 'should create new project without path and return 201' do
expect { post api('/projects', user), name: 'foo' }.
to change { Project.count }.by(1)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it 'should create last project before reaching project limit' do
- User.any_instance.stub(:projects_limit_left).and_return(1)
+ allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1)
post api('/projects', user2), name: 'foo'
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it 'should not create new project without name and return 400' do
expect { post api('/projects', user) }.to_not change { Project.count }
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should assign attributes to project" do
@@ -157,50 +157,50 @@ describe API::API, api: true do
post api('/projects', user), project
project.each_pair do |k,v|
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
it 'should set a project as public' do
project = attributes_for(:project, :public)
post api('/projects', user), project
- json_response['public'].should be_true
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC
+ expect(json_response['public']).to be_truthy
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
it 'should set a project as public using :public' do
project = attributes_for(:project, { public: true })
post api('/projects', user), project
- json_response['public'].should be_true
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC
+ expect(json_response['public']).to be_truthy
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
it 'should set a project as internal' do
project = attributes_for(:project, :internal)
post api('/projects', user), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
it 'should set a project as internal overriding :public' do
project = attributes_for(:project, :internal, { public: true })
post api('/projects', user), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
it 'should set a project as private' do
project = attributes_for(:project, :private)
post api('/projects', user), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
it 'should set a project as private using :public' do
project = attributes_for(:project, { public: false })
post api('/projects', user), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
@@ -210,24 +210,24 @@ describe API::API, api: true do
it 'should create new project without path and return 201' do
expect { post api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it 'should respond with 400 on failure and not project' do
expect { post api("/projects/user/#{user.id}", admin) }.
to_not change { Project.count }
- response.status.should == 400
- json_response['message']['name'].should == [
+ expect(response.status).to eq(400)
+ expect(json_response['message']['name']).to eq([
'can\'t be blank',
'is too short (minimum is 0 characters)',
Gitlab::Regex.project_regex_message
- ]
- json_response['message']['path'].should == [
+ ])
+ expect(json_response['message']['path']).to eq([
'can\'t be blank',
'is too short (minimum is 0 characters)',
Gitlab::Regex.send(:default_regex_message)
- ]
+ ])
end
it 'should assign attributes to project' do
@@ -242,50 +242,50 @@ describe API::API, api: true do
project.each_pair do |k,v|
next if k == :path
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
it 'should set a project as public' do
project = attributes_for(:project, :public)
post api("/projects/user/#{user.id}", admin), project
- json_response['public'].should be_true
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC
+ expect(json_response['public']).to be_truthy
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
it 'should set a project as public using :public' do
project = attributes_for(:project, { public: true })
post api("/projects/user/#{user.id}", admin), project
- json_response['public'].should be_true
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC
+ expect(json_response['public']).to be_truthy
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
it 'should set a project as internal' do
project = attributes_for(:project, :internal)
post api("/projects/user/#{user.id}", admin), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
it 'should set a project as internal overriding :public' do
project = attributes_for(:project, :internal, { public: true })
post api("/projects/user/#{user.id}", admin), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
it 'should set a project as private' do
project = attributes_for(:project, :private)
post api("/projects/user/#{user.id}", admin), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
it 'should set a project as private using :public' do
project = attributes_for(:project, { public: false })
post api("/projects/user/#{user.id}", admin), project
- json_response['public'].should be_false
- json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE
+ expect(json_response['public']).to be_falsey
+ expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
@@ -295,27 +295,27 @@ describe API::API, api: true do
it 'should return a project by id' do
get api("/projects/#{project.id}", user)
- response.status.should == 200
- json_response['name'].should == project.name
- json_response['owner']['username'].should == user.username
+ expect(response.status).to eq(200)
+ expect(json_response['name']).to eq(project.name)
+ expect(json_response['owner']['username']).to eq(user.username)
end
it 'should return a project by path name' do
get api("/projects/#{project.id}", user)
- response.status.should == 200
- json_response['name'].should == project.name
+ expect(response.status).to eq(200)
+ expect(json_response['name']).to eq(project.name)
end
it 'should return a 404 error if not found' do
get api('/projects/42', user)
- response.status.should == 404
- json_response['message'].should == '404 Project Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Project Not Found')
end
it 'should return a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}", other_user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
describe 'permissions' do
@@ -351,24 +351,24 @@ describe API::API, api: true do
it 'should return a project events' do
get api("/projects/#{project.id}/events", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
json_event = json_response.first
- json_event['action_name'].should == 'joined'
- json_event['project_id'].to_i.should == project.id
- json_event['author_username'].should == user.username
+ expect(json_event['action_name']).to eq('joined')
+ expect(json_event['project_id'].to_i).to eq(project.id)
+ expect(json_event['author_username']).to eq(user.username)
end
it 'should return a 404 error if not found' do
get api('/projects/42/events', user)
- response.status.should == 404
- json_response['message'].should == '404 Project Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Project Not Found')
end
it 'should return a 404 error if user is not a member' do
other_user = create(:user)
get api("/projects/#{project.id}/events", other_user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -377,22 +377,22 @@ describe API::API, api: true do
it 'should return an array of project snippets' do
get api("/projects/#{project.id}/snippets", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['title'].should == snippet.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(snippet.title)
end
end
describe 'GET /projects/:id/snippets/:snippet_id' do
it 'should return a project snippet' do
get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
- response.status.should == 200
- json_response['title'].should == snippet.title
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq(snippet.title)
end
it 'should return a 404 error if snippet id not found' do
get api("/projects/#{project.id}/snippets/1234", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -400,8 +400,8 @@ describe API::API, api: true do
it 'should create a new project snippet' do
post api("/projects/#{project.id}/snippets", user),
title: 'api test', file_name: 'sample.rb', code: 'test'
- response.status.should == 201
- json_response['title'].should == 'api test'
+ expect(response.status).to eq(201)
+ expect(json_response['title']).to eq('api test')
end
it 'should return a 400 error if invalid snippet is given' do
@@ -414,16 +414,16 @@ describe API::API, api: true do
it 'should update an existing project snippet' do
put api("/projects/#{project.id}/snippets/#{snippet.id}", user),
code: 'updated code'
- response.status.should == 200
- json_response['title'].should == 'example'
- snippet.reload.content.should == 'updated code'
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq('example')
+ expect(snippet.reload.content).to eq('updated code')
end
it 'should update an existing project snippet with new title' do
put api("/projects/#{project.id}/snippets/#{snippet.id}", user),
title: 'other api test'
- response.status.should == 200
- json_response['title'].should == 'other api test'
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq('other api test')
end
end
@@ -434,24 +434,24 @@ describe API::API, api: true do
expect {
delete api("/projects/#{project.id}/snippets/#{snippet.id}", user)
}.to change { Snippet.count }.by(-1)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should return 404 when deleting unknown snippet id' do
delete api("/projects/#{project.id}/snippets/1234", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe 'GET /projects/:id/snippets/:snippet_id/raw' do
it 'should get a raw project snippet' do
get api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should return a 404 error if raw project snippet not found' do
get api("/projects/#{project.id}/snippets/5555/raw", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -464,43 +464,43 @@ describe API::API, api: true do
it 'should return array of ssh keys' do
get api("/projects/#{project.id}/keys", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['title'].should == deploy_key.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(deploy_key.title)
end
end
describe 'GET /projects/:id/keys/:key_id' do
it 'should return a single key' do
get api("/projects/#{project.id}/keys/#{deploy_key.id}", user)
- response.status.should == 200
- json_response['title'].should == deploy_key.title
+ expect(response.status).to eq(200)
+ expect(json_response['title']).to eq(deploy_key.title)
end
it 'should return 404 Not Found with invalid ID' do
get api("/projects/#{project.id}/keys/404", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe 'POST /projects/:id/keys' do
it 'should not create an invalid ssh key' do
post api("/projects/#{project.id}/keys", user), { title: 'invalid key' }
- response.status.should == 400
- json_response['message']['key'].should == [
+ expect(response.status).to eq(400)
+ expect(json_response['message']['key']).to eq([
'can\'t be blank',
'is too short (minimum is 0 characters)',
'is invalid'
- ]
+ ])
end
it 'should not create a key without title' do
post api("/projects/#{project.id}/keys", user), key: 'some key'
- response.status.should == 400
- json_response['message']['title'].should == [
+ expect(response.status).to eq(400)
+ expect(json_response['message']['title']).to eq([
'can\'t be blank',
'is too short (minimum is 0 characters)'
- ]
+ ])
end
it 'should create new ssh key' do
@@ -522,7 +522,7 @@ describe API::API, api: true do
it 'should return 404 Not Found with invalid ID' do
delete api("/projects/#{project.id}/keys/404", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
@@ -536,33 +536,33 @@ describe API::API, api: true do
it "shouldn't available for non admin users" do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should allow project to be forked from an existing project' do
- project_fork_target.forked?.should_not be_true
+ expect(project_fork_target.forked?).not_to be_truthy
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
- response.status.should == 201
+ expect(response.status).to eq(201)
project_fork_target.reload
- project_fork_target.forked_from_project.id.should == project_fork_source.id
- project_fork_target.forked_project_link.should_not be_nil
- project_fork_target.forked?.should be_true
+ expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
+ expect(project_fork_target.forked_project_link).not_to be_nil
+ expect(project_fork_target.forked?).to be_truthy
end
it 'should fail if forked_from project which does not exist' do
post api("/projects/#{project_fork_target.id}/fork/9999", admin)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it 'should fail with 409 if already forked' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
- project_fork_target.forked_from_project.id.should == project_fork_source.id
+ expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
post api("/projects/#{project_fork_target.id}/fork/#{new_project_fork_source.id}", admin)
- response.status.should == 409
+ expect(response.status).to eq(409)
project_fork_target.reload
- project_fork_target.forked_from_project.id.should == project_fork_source.id
- project_fork_target.forked?.should be_true
+ expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id)
+ expect(project_fork_target.forked?).to be_truthy
end
end
@@ -570,26 +570,26 @@ describe API::API, api: true do
it "shouldn't available for non admin users" do
delete api("/projects/#{project_fork_target.id}/fork", user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should make forked project unforked' do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
- project_fork_target.forked_from_project.should_not be_nil
- project_fork_target.forked?.should be_true
+ expect(project_fork_target.forked_from_project).not_to be_nil
+ expect(project_fork_target.forked?).to be_truthy
delete api("/projects/#{project_fork_target.id}/fork", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
project_fork_target.reload
- project_fork_target.forked_from_project.should be_nil
- project_fork_target.forked?.should_not be_true
+ expect(project_fork_target.forked_from_project).to be_nil
+ expect(project_fork_target.forked?).not_to be_truthy
end
it 'should be idempotent if not forked' do
- project_fork_target.forked_from_project.should be_nil
+ expect(project_fork_target.forked_from_project).to be_nil
delete api("/projects/#{project_fork_target.id}/fork", admin)
- response.status.should == 200
- project_fork_target.reload.forked_from_project.should be_nil
+ expect(response.status).to eq(200)
+ expect(project_fork_target.reload.forked_from_project).to be_nil
end
end
end
@@ -609,27 +609,27 @@ describe API::API, api: true do
context 'when unauthenticated' do
it 'should return authentication error' do
get api("/projects/search/#{query}")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context 'when authenticated' do
it 'should return an array of projects' do
get api("/projects/search/#{query}",user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.size.should == 6
- json_response.each {|project| project['name'].should =~ /.*query.*/}
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(6)
+ json_response.each {|project| expect(project['name']).to match(/.*query.*/)}
end
end
context 'when authenticated as a different user' do
it 'should return matching public projects' do
get api("/projects/search/#{query}", user2)
- response.status.should == 200
- json_response.should be_an Array
- json_response.size.should == 2
- json_response.each {|project| project['name'].should =~ /(internal|public) query/}
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(2)
+ json_response.each {|project| expect(project['name']).to match(/(internal|public) query/)}
end
end
end
@@ -648,7 +648,7 @@ describe API::API, api: true do
it 'should return authentication error' do
project_param = { name: 'bar' }
put api("/projects/#{project.id}"), project_param
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -656,34 +656,34 @@ describe API::API, api: true do
it 'should update name' do
project_param = { name: 'bar' }
put api("/projects/#{project.id}", user), project_param
- response.status.should == 200
+ expect(response.status).to eq(200)
project_param.each_pair do |k, v|
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
it 'should update visibility_level' do
project_param = { visibility_level: 20 }
put api("/projects/#{project3.id}", user), project_param
- response.status.should == 200
+ expect(response.status).to eq(200)
project_param.each_pair do |k, v|
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
it 'should not update name to existing name' do
project_param = { name: project3.name }
put api("/projects/#{project.id}", user), project_param
- response.status.should == 400
- json_response['message']['name'].should == ['has already been taken']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['name']).to eq(['has already been taken'])
end
it 'should update path & name to existing path & name in different namespace' do
project_param = { path: project4.path, name: project4.name }
put api("/projects/#{project3.id}", user), project_param
- response.status.should == 200
+ expect(response.status).to eq(200)
project_param.each_pair do |k, v|
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
end
@@ -692,9 +692,9 @@ describe API::API, api: true do
it 'should update path' do
project_param = { path: 'bar' }
put api("/projects/#{project3.id}", user4), project_param
- response.status.should == 200
+ expect(response.status).to eq(200)
project_param.each_pair do |k, v|
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
@@ -706,29 +706,29 @@ describe API::API, api: true do
description: 'new description' }
put api("/projects/#{project3.id}", user4), project_param
- response.status.should == 200
+ expect(response.status).to eq(200)
project_param.each_pair do |k, v|
- json_response[k.to_s].should == v
+ expect(json_response[k.to_s]).to eq(v)
end
end
it 'should not update path to existing path' do
project_param = { path: project.path }
put api("/projects/#{project3.id}", user4), project_param
- response.status.should == 400
- json_response['message']['path'].should == ['has already been taken']
+ expect(response.status).to eq(400)
+ expect(json_response['message']['path']).to eq(['has already been taken'])
end
it 'should not update name' do
project_param = { name: 'bar' }
put api("/projects/#{project3.id}", user4), project_param
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should not update visibility_level' do
project_param = { visibility_level: 20 }
put api("/projects/#{project3.id}", user4), project_param
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
@@ -741,7 +741,7 @@ describe API::API, api: true do
merge_requests_enabled: true,
description: 'new description' }
put api("/projects/#{project.id}", user3), project_param
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
end
@@ -755,36 +755,36 @@ describe API::API, api: true do
).twice
delete api("/projects/#{project.id}", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should not remove a project if not an owner' do
user3 = create(:user)
project.team << [user3, :developer]
delete api("/projects/#{project.id}", user3)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should not remove a non existing project' do
delete api('/projects/1328', user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it 'should not remove a project not attached to user' do
delete api("/projects/#{project.id}", user2)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
context 'when authenticated as admin' do
it 'should remove any existing project' do
delete api("/projects/#{project.id}", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should not remove a non existing project' do
delete api('/projects/1328', admin)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
end
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index 5518d2df566..729970153d1 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -16,9 +16,9 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/tags" do
it "should return an array of project tags" do
get api("/projects/#{project.id}/repository/tags", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['name'].should == project.repo.tags.sort_by(&:name).reverse.first.name
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['name']).to eq(project.repo.tags.sort_by(&:name).reverse.first.name)
end
end
@@ -29,8 +29,8 @@ describe API::API, api: true do
tag_name: 'v7.0.1',
ref: 'master'
- response.status.should == 201
- json_response['name'].should == 'v7.0.1'
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq('v7.0.1')
end
end
@@ -46,9 +46,9 @@ describe API::API, api: true do
ref: 'master',
message: 'Release 7.1.0'
- response.status.should == 201
- json_response['name'].should == 'v7.1.0'
- json_response['message'].should == 'Release 7.1.0'
+ expect(response.status).to eq(201)
+ expect(json_response['name']).to eq('v7.1.0')
+ expect(json_response['message']).to eq('Release 7.1.0')
end
end
@@ -56,35 +56,35 @@ describe API::API, api: true do
post api("/projects/#{project.id}/repository/tags", user2),
tag_name: 'v1.9.0',
ref: '621491c677087aa243f165eab467bfdfbee00be1'
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it 'should return 400 if tag name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v 1.0.0',
ref: 'master'
- response.status.should == 400
- json_response['message'].should == 'Tag name invalid'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Tag name invalid')
end
it 'should return 400 if tag already exists' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v8.0.0',
ref: 'master'
- response.status.should == 201
+ expect(response.status).to eq(201)
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'v8.0.0',
ref: 'master'
- response.status.should == 400
- json_response['message'].should == 'Tag already exists'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Tag already exists')
end
it 'should return 400 if ref name is invalid' do
post api("/projects/#{project.id}/repository/tags", user),
tag_name: 'mytag',
ref: 'foo'
- response.status.should == 400
- json_response['message'].should == 'Invalid reference name'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('Invalid reference name')
end
end
@@ -94,19 +94,19 @@ describe API::API, api: true do
it "should return project commits" do
get api("/projects/#{project.id}/repository/tree", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
- json_response.should be_an Array
- json_response.first['name'].should == 'encoding'
- json_response.first['type'].should == 'tree'
- json_response.first['mode'].should == '040000'
+ expect(json_response).to be_an Array
+ expect(json_response.first['name']).to eq('encoding')
+ expect(json_response.first['type']).to eq('tree')
+ expect(json_response.first['mode']).to eq('040000')
end
it 'should return a 404 for unknown ref' do
get api("/projects/#{project.id}/repository/tree?ref_name=foo", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
- json_response.should be_an Object
+ expect(json_response).to be_an Object
json_response['message'] == '404 Tree Not Found'
end
end
@@ -114,7 +114,7 @@ describe API::API, api: true do
context "unauthorized user" do
it "should not return project commits" do
get api("/projects/#{project.id}/repository/tree")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
@@ -122,43 +122,43 @@ describe API::API, api: true do
describe "GET /projects/:id/repository/blobs/:sha" do
it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.md", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return 404 for invalid branch_name" do
get api("/projects/#{project.id}/repository/blobs/invalid_branch_name?filepath=README.md", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return 404 for invalid file" do
get api("/projects/#{project.id}/repository/blobs/master?filepath=README.invalid", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
it "should return a 400 error if filepath is missing" do
get api("/projects/#{project.id}/repository/blobs/master", user)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
describe "GET /projects/:id/repository/commits/:sha/blob" do
it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/commits/master/blob?filepath=README.md", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
describe "GET /projects/:id/repository/raw_blobs/:sha" do
it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/raw_blobs/#{sample_blob.oid}", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should return a 404 for unknown blob' do
get api("/projects/#{project.id}/repository/raw_blobs/123456", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
- json_response.should be_an Object
+ expect(json_response).to be_an Object
json_response['message'] == '404 Blob Not Found'
end
end
@@ -167,83 +167,83 @@ describe API::API, api: true do
it "should get the archive" do
get api("/projects/#{project.id}/repository/archive", user)
repo_name = project.repository.name.gsub("\.git", "")
- response.status.should == 200
- response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.gz\"/
- response.content_type.should == MIME::Types.type_for('file.tar.gz').first.content_type
+ expect(response.status).to eq(200)
+ expect(response.headers['Content-Disposition']).to match(/filename\=\"#{repo_name}\-[^\.]+\.tar.gz\"/)
+ expect(response.content_type).to eq(MIME::Types.type_for('file.tar.gz').first.content_type)
end
it "should get the archive.zip" do
get api("/projects/#{project.id}/repository/archive.zip", user)
repo_name = project.repository.name.gsub("\.git", "")
- response.status.should == 200
- response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.zip\"/
- response.content_type.should == MIME::Types.type_for('file.zip').first.content_type
+ expect(response.status).to eq(200)
+ expect(response.headers['Content-Disposition']).to match(/filename\=\"#{repo_name}\-[^\.]+\.zip\"/)
+ expect(response.content_type).to eq(MIME::Types.type_for('file.zip').first.content_type)
end
it "should get the archive.tar.bz2" do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
repo_name = project.repository.name.gsub("\.git", "")
- response.status.should == 200
- response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.bz2\"/
- response.content_type.should == MIME::Types.type_for('file.tar.bz2').first.content_type
+ expect(response.status).to eq(200)
+ expect(response.headers['Content-Disposition']).to match(/filename\=\"#{repo_name}\-[^\.]+\.tar.bz2\"/)
+ expect(response.content_type).to eq(MIME::Types.type_for('file.tar.bz2').first.content_type)
end
it "should return 404 for invalid sha" do
get api("/projects/#{project.id}/repository/archive/?sha=xxx", user)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
describe 'GET /projects/:id/repository/compare' do
it "should compare branches" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'feature'
- response.status.should == 200
- json_response['commits'].should be_present
- json_response['diffs'].should be_present
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_present
+ expect(json_response['diffs']).to be_present
end
it "should compare tags" do
get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.0', to: 'v1.1.0'
- response.status.should == 200
- json_response['commits'].should be_present
- json_response['diffs'].should be_present
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_present
+ expect(json_response['diffs']).to be_present
end
it "should compare commits" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.id, to: sample_commit.parent_id
- response.status.should == 200
- json_response['commits'].should be_empty
- json_response['diffs'].should be_empty
- json_response['compare_same_ref'].should be_false
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_empty
+ expect(json_response['diffs']).to be_empty
+ expect(json_response['compare_same_ref']).to be_falsey
end
it "should compare commits in reverse order" do
get api("/projects/#{project.id}/repository/compare", user), from: sample_commit.parent_id, to: sample_commit.id
- response.status.should == 200
- json_response['commits'].should be_present
- json_response['diffs'].should be_present
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_present
+ expect(json_response['diffs']).to be_present
end
it "should compare same refs" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master'
- response.status.should == 200
- json_response['commits'].should be_empty
- json_response['diffs'].should be_empty
- json_response['compare_same_ref'].should be_true
+ expect(response.status).to eq(200)
+ expect(json_response['commits']).to be_empty
+ expect(json_response['diffs']).to be_empty
+ expect(json_response['compare_same_ref']).to be_truthy
end
end
describe 'GET /projects/:id/repository/contributors' do
it 'should return valid data' do
get api("/projects/#{project.id}/repository/contributors", user)
- response.status.should == 200
- json_response.should be_an Array
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
contributor = json_response.first
- contributor['email'].should == 'dmitriy.zaporozhets@gmail.com'
- contributor['name'].should == 'Dmitriy Zaporozhets'
- contributor['commits'].should == 13
- contributor['additions'].should == 0
- contributor['deletions'].should == 0
+ expect(contributor['email']).to eq('dmitriy.zaporozhets@gmail.com')
+ expect(contributor['name']).to eq('Dmitriy Zaporozhets')
+ expect(contributor['commits']).to eq(13)
+ expect(contributor['additions']).to eq(0)
+ expect(contributor['deletions']).to eq(0)
end
end
end
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index d8282d0696b..51c543578df 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -9,13 +9,13 @@ describe API::API, api: true do
it "should update gitlab-ci settings" do
put api("/projects/#{project.id}/services/gitlab-ci", user), token: 'secret-token', project_url: "http://ci.example.com/projects/1"
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return if required fields missing" do
put api("/projects/#{project.id}/services/gitlab-ci", user), project_url: "http://ci.example.com/projects/1", active: true
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -23,8 +23,8 @@ describe API::API, api: true do
it "should update gitlab-ci settings" do
delete api("/projects/#{project.id}/services/gitlab-ci", user)
- response.status.should == 200
- project.gitlab_ci_service.should be_nil
+ expect(response.status).to eq(200)
+ expect(project.gitlab_ci_service).to be_nil
end
end
@@ -33,15 +33,15 @@ describe API::API, api: true do
put api("/projects/#{project.id}/services/hipchat", user),
token: 'secret-token', room: 'test'
- response.status.should == 200
- project.hipchat_service.should_not be_nil
+ expect(response.status).to eq(200)
+ expect(project.hipchat_service).not_to be_nil
end
it 'should return if required fields missing' do
put api("/projects/#{project.id}/services/gitlab-ci", user),
token: 'secret-token', active: true
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -49,8 +49,8 @@ describe API::API, api: true do
it 'should delete hipchat settings' do
delete api("/projects/#{project.id}/services/hipchat", user)
- response.status.should == 200
- project.hipchat_service.should be_nil
+ expect(response.status).to eq(200)
+ expect(project.hipchat_service).to be_nil
end
end
end
diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb
index 57b2e6cbd6a..fbd57b34a58 100644
--- a/spec/requests/api/session_spec.rb
+++ b/spec/requests/api/session_spec.rb
@@ -9,13 +9,13 @@ describe API::API, api: true do
context "when valid password" do
it "should return private token" do
post api("/session"), email: user.email, password: '12345678'
- response.status.should == 201
+ expect(response.status).to eq(201)
- json_response['email'].should == user.email
- json_response['private_token'].should == user.private_token
- json_response['is_admin'].should == user.is_admin?
- json_response['can_create_project'].should == user.can_create_project?
- json_response['can_create_group'].should == user.can_create_group?
+ expect(json_response['email']).to eq(user.email)
+ expect(json_response['private_token']).to eq(user.private_token)
+ expect(json_response['is_admin']).to eq(user.is_admin?)
+ expect(json_response['can_create_project']).to eq(user.can_create_project?)
+ expect(json_response['can_create_group']).to eq(user.can_create_group?)
end
end
@@ -48,30 +48,30 @@ describe API::API, api: true do
context "when invalid password" do
it "should return authentication error" do
post api("/session"), email: user.email, password: '123'
- response.status.should == 401
+ expect(response.status).to eq(401)
- json_response['email'].should be_nil
- json_response['private_token'].should be_nil
+ expect(json_response['email']).to be_nil
+ expect(json_response['private_token']).to be_nil
end
end
context "when empty password" do
it "should return authentication error" do
post api("/session"), email: user.email
- response.status.should == 401
+ expect(response.status).to eq(401)
- json_response['email'].should be_nil
- json_response['private_token'].should be_nil
+ expect(json_response['email']).to be_nil
+ expect(json_response['private_token']).to be_nil
end
end
context "when empty name" do
it "should return authentication error" do
post api("/session"), password: user.password
- response.status.should == 401
+ expect(response.status).to eq(401)
- json_response['email'].should be_nil
- json_response['private_token'].should be_nil
+ expect(json_response['email']).to be_nil
+ expect(json_response['private_token']).to be_nil
end
end
end
diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb
index 5784ae8c23a..a9d86bbce6c 100644
--- a/spec/requests/api/system_hooks_spec.rb
+++ b/spec/requests/api/system_hooks_spec.rb
@@ -13,23 +13,23 @@ describe API::API, api: true do
context "when no user" do
it "should return authentication error" do
get api("/hooks")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when not an admin" do
it "should return forbidden error" do
get api("/hooks", user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
end
context "when authenticated as admin" do
it "should return an array of hooks" do
get api("/hooks", admin)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['url'].should == hook.url
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['url']).to eq(hook.url)
end
end
end
@@ -43,7 +43,7 @@ describe API::API, api: true do
it "should respond with 400 if url not given" do
post api("/hooks", admin)
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should not create new hook without url" do
@@ -56,13 +56,13 @@ describe API::API, api: true do
describe "GET /hooks/:id" do
it "should return hook by id" do
get api("/hooks/#{hook.id}", admin)
- response.status.should == 200
- json_response['event_name'].should == 'project_create'
+ expect(response.status).to eq(200)
+ expect(json_response['event_name']).to eq('project_create')
end
it "should return 404 on failure" do
get api("/hooks/404", admin)
- response.status.should == 404
+ expect(response.status).to eq(404)
end
end
@@ -75,7 +75,7 @@ describe API::API, api: true do
it "should return success if hook id not found" do
delete api("/hooks/12345", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
end
end
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 12dfcacec23..081400cdedd 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -11,30 +11,30 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
get api("/users")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context "when authenticated" do
it "should return an array of users" do
get api("/users", user)
- response.status.should == 200
- json_response.should be_an Array
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
username = user.username
- json_response.detect {
+ expect(json_response.detect {
|user| user['username'] == username
- }['username'].should == username
+ }['username']).to eq(username)
end
end
context "when admin" do
it "should return an array of users" do
get api("/users", admin)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first.keys.should include 'email'
- json_response.first.keys.should include 'identities'
- json_response.first.keys.should include 'can_create_project'
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first.keys).to include 'email'
+ expect(json_response.first.keys).to include 'identities'
+ expect(json_response.first.keys).to include 'can_create_project'
end
end
end
@@ -42,19 +42,19 @@ describe API::API, api: true do
describe "GET /users/:id" do
it "should return a user by id" do
get api("/users/#{user.id}", user)
- response.status.should == 200
- json_response['username'].should == user.username
+ expect(response.status).to eq(200)
+ expect(json_response['username']).to eq(user.username)
end
it "should return a 401 if unauthenticated" do
get api("/users/9998")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
it "should return a 404 error if user id not found" do
get api("/users/9999", user)
- response.status.should == 404
- json_response['message'].should == '404 Not found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Not found')
end
end
@@ -69,36 +69,36 @@ describe API::API, api: true do
it "should create user with correct attributes" do
post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true)
- response.status.should == 201
+ expect(response.status).to eq(201)
user_id = json_response['id']
new_user = User.find(user_id)
- new_user.should_not == nil
- new_user.admin.should == true
- new_user.can_create_group.should == true
+ expect(new_user).not_to eq(nil)
+ expect(new_user.admin).to eq(true)
+ expect(new_user.can_create_group).to eq(true)
end
it "should create non-admin user" do
post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false)
- response.status.should == 201
+ expect(response.status).to eq(201)
user_id = json_response['id']
new_user = User.find(user_id)
- new_user.should_not == nil
- new_user.admin.should == false
- new_user.can_create_group.should == false
+ expect(new_user).not_to eq(nil)
+ expect(new_user.admin).to eq(false)
+ expect(new_user.can_create_group).to eq(false)
end
it "should create non-admin users by default" do
post api('/users', admin), attributes_for(:user)
- response.status.should == 201
+ expect(response.status).to eq(201)
user_id = json_response['id']
new_user = User.find(user_id)
- new_user.should_not == nil
- new_user.admin.should == false
+ expect(new_user).not_to eq(nil)
+ expect(new_user.admin).to eq(false)
end
it "should return 201 Created on success" do
post api("/users", admin), attributes_for(:user, projects_limit: 3)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it "should not create user with invalid email" do
@@ -106,22 +106,22 @@ describe API::API, api: true do
email: 'invalid email',
password: 'password',
name: 'test'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 400 error if name not given' do
post api('/users', admin), email: 'test@example.com', password: 'pass1234'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 400 error if password not given' do
post api('/users', admin), email: 'test@example.com', name: 'test'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it "should return 400 error if email not given" do
post api('/users', admin), password: 'pass1234', name: 'test'
- response.status.should == 400
+ expect(response.status).to eq(400)
end
it 'should return 400 error if user does not validate' do
@@ -132,20 +132,20 @@ describe API::API, api: true do
name: 'test',
bio: 'g' * 256,
projects_limit: -1
- response.status.should == 400
- json_response['message']['password'].
- should == ['is too short (minimum is 8 characters)']
- json_response['message']['bio'].
- should == ['is too long (maximum is 255 characters)']
- json_response['message']['projects_limit'].
- should == ['must be greater than or equal to 0']
- json_response['message']['username'].
- should == [Gitlab::Regex.send(:default_regex_message)]
+ expect(response.status).to eq(400)
+ expect(json_response['message']['password']).
+ to eq(['is too short (minimum is 8 characters)'])
+ expect(json_response['message']['bio']).
+ to eq(['is too long (maximum is 255 characters)'])
+ expect(json_response['message']['projects_limit']).
+ to eq(['must be greater than or equal to 0'])
+ expect(json_response['message']['username']).
+ to eq([Gitlab::Regex.send(:default_regex_message)])
end
it "shouldn't available for non admin users" do
post api("/users", user), attributes_for(:user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
context 'with existing user' do
@@ -165,8 +165,8 @@ describe API::API, api: true do
password: 'password',
username: 'foo'
}.to change { User.count }.by(0)
- response.status.should == 409
- json_response['message'].should == 'Email has already been taken'
+ expect(response.status).to eq(409)
+ expect(json_response['message']).to eq('Email has already been taken')
end
it 'should return 409 conflict error if same username exists' do
@@ -177,8 +177,8 @@ describe API::API, api: true do
password: 'password',
username: 'test'
end.to change { User.count }.by(0)
- response.status.should == 409
- json_response['message'].should == 'Username has already been taken'
+ expect(response.status).to eq(409)
+ expect(json_response['message']).to eq('Username has already been taken')
end
end
end
@@ -187,8 +187,8 @@ describe API::API, api: true do
it "should redirect to sign in page" do
get "/users/sign_up"
- response.status.should == 302
- response.should redirect_to(new_user_session_path)
+ expect(response.status).to eq(302)
+ expect(response).to redirect_to(new_user_session_path)
end
end
@@ -199,55 +199,55 @@ describe API::API, api: true do
it "should update user with new bio" do
put api("/users/#{user.id}", admin), {bio: 'new test bio'}
- response.status.should == 200
- json_response['bio'].should == 'new test bio'
- user.reload.bio.should == 'new test bio'
+ expect(response.status).to eq(200)
+ expect(json_response['bio']).to eq('new test bio')
+ expect(user.reload.bio).to eq('new test bio')
end
it 'should update user with his own email' do
put api("/users/#{user.id}", admin), email: user.email
- response.status.should == 200
- json_response['email'].should == user.email
- user.reload.email.should == user.email
+ expect(response.status).to eq(200)
+ expect(json_response['email']).to eq(user.email)
+ expect(user.reload.email).to eq(user.email)
end
it 'should update user with his own username' do
put api("/users/#{user.id}", admin), username: user.username
- response.status.should == 200
- json_response['username'].should == user.username
- user.reload.username.should == user.username
+ expect(response.status).to eq(200)
+ expect(json_response['username']).to eq(user.username)
+ expect(user.reload.username).to eq(user.username)
end
it "should update admin status" do
put api("/users/#{user.id}", admin), {admin: true}
- response.status.should == 200
- json_response['is_admin'].should == true
- user.reload.admin.should == true
+ expect(response.status).to eq(200)
+ expect(json_response['is_admin']).to eq(true)
+ expect(user.reload.admin).to eq(true)
end
it "should not update admin status" do
put api("/users/#{admin_user.id}", admin), {can_create_group: false}
- response.status.should == 200
- json_response['is_admin'].should == true
- admin_user.reload.admin.should == true
- admin_user.can_create_group.should == false
+ expect(response.status).to eq(200)
+ expect(json_response['is_admin']).to eq(true)
+ expect(admin_user.reload.admin).to eq(true)
+ expect(admin_user.can_create_group).to eq(false)
end
it "should not allow invalid update" do
put api("/users/#{user.id}", admin), {email: 'invalid email'}
- response.status.should == 400
- user.reload.email.should_not == 'invalid email'
+ expect(response.status).to eq(400)
+ expect(user.reload.email).not_to eq('invalid email')
end
it "shouldn't available for non admin users" do
put api("/users/#{user.id}", user), attributes_for(:user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it "should return 404 for non-existing user" do
put api("/users/999999", admin), {bio: 'update should fail'}
- response.status.should == 404
- json_response['message'].should == '404 Not found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Not found')
end
it 'should return 400 error if user does not validate' do
@@ -258,15 +258,15 @@ describe API::API, api: true do
name: 'test',
bio: 'g' * 256,
projects_limit: -1
- response.status.should == 400
- json_response['message']['password'].
- should == ['is too short (minimum is 8 characters)']
- json_response['message']['bio'].
- should == ['is too long (maximum is 255 characters)']
- json_response['message']['projects_limit'].
- should == ['must be greater than or equal to 0']
- json_response['message']['username'].
- should == [Gitlab::Regex.send(:default_regex_message)]
+ expect(response.status).to eq(400)
+ expect(json_response['message']['password']).
+ to eq(['is too short (minimum is 8 characters)'])
+ expect(json_response['message']['bio']).
+ to eq(['is too long (maximum is 255 characters)'])
+ expect(json_response['message']['projects_limit']).
+ to eq(['must be greater than or equal to 0'])
+ expect(json_response['message']['username']).
+ to eq([Gitlab::Regex.send(:default_regex_message)])
end
context "with existing user" do
@@ -278,15 +278,15 @@ describe API::API, api: true do
it 'should return 409 conflict error if email address exists' do
put api("/users/#{@user.id}", admin), email: 'test@example.com'
- response.status.should == 409
- @user.reload.email.should == @user.email
+ expect(response.status).to eq(409)
+ expect(@user.reload.email).to eq(@user.email)
end
it 'should return 409 conflict error if username taken' do
@user_id = User.all.last.id
put api("/users/#{@user.id}", admin), username: 'test'
- response.status.should == 409
- @user.reload.username.should == @user.username
+ expect(response.status).to eq(409)
+ expect(@user.reload.username).to eq(@user.username)
end
end
end
@@ -296,14 +296,14 @@ describe API::API, api: true do
it "should not create invalid ssh key" do
post api("/users/#{user.id}/keys", admin), { title: "invalid key" }
- response.status.should == 400
- json_response['message'].should == '400 (Bad request) "key" not given'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('400 (Bad request) "key" not given')
end
it 'should not create key without title' do
post api("/users/#{user.id}/keys", admin), key: 'some key'
- response.status.should == 400
- json_response['message'].should == '400 (Bad request) "title" not given'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('400 (Bad request) "title" not given')
end
it "should create ssh key" do
@@ -320,24 +320,24 @@ describe API::API, api: true do
context 'when unauthenticated' do
it 'should return authentication error' do
get api("/users/#{user.id}/keys")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
context 'when authenticated' do
it 'should return 404 for non-existing user' do
get api('/users/999999/keys', admin)
- response.status.should == 404
- json_response['message'].should == '404 User Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 User Not Found')
end
it 'should return array of ssh keys' do
user.keys << key
user.save
get api("/users/#{user.id}/keys", admin)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first['title'].should == key.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first['title']).to eq(key.title)
end
end
end
@@ -348,7 +348,7 @@ describe API::API, api: true do
context 'when unauthenticated' do
it 'should return authentication error' do
delete api("/users/#{user.id}/keys/42")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -359,21 +359,21 @@ describe API::API, api: true do
expect {
delete api("/users/#{user.id}/keys/#{key.id}", admin)
}.to change { user.keys.count }.by(-1)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it 'should return 404 error if user not found' do
user.keys << key
user.save
delete api("/users/999999/keys/#{key.id}", admin)
- response.status.should == 404
- json_response['message'].should == '404 User Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 User Not Found')
end
it 'should return 404 error if key not foud' do
delete api("/users/#{user.id}/keys/42", admin)
- response.status.should == 404
- json_response['message'].should == '404 Key Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Key Not Found')
end
end
end
@@ -383,42 +383,42 @@ describe API::API, api: true do
it "should delete user" do
delete api("/users/#{user.id}", admin)
- response.status.should == 200
+ expect(response.status).to eq(200)
expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound
- json_response['email'].should == user.email
+ expect(json_response['email']).to eq(user.email)
end
it "should not delete for unauthenticated user" do
delete api("/users/#{user.id}")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
it "shouldn't available for non admin users" do
delete api("/users/#{user.id}", user)
- response.status.should == 403
+ expect(response.status).to eq(403)
end
it "should return 404 for non-existing user" do
delete api("/users/999999", admin)
- response.status.should == 404
- json_response['message'].should == '404 User Not Found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 User Not Found')
end
end
describe "GET /user" do
it "should return current user" do
get api("/user", user)
- response.status.should == 200
- json_response['email'].should == user.email
- json_response['is_admin'].should == user.is_admin?
- json_response['can_create_project'].should == user.can_create_project?
- json_response['can_create_group'].should == user.can_create_group?
- json_response['projects_limit'].should == user.projects_limit
+ expect(response.status).to eq(200)
+ expect(json_response['email']).to eq(user.email)
+ expect(json_response['is_admin']).to eq(user.is_admin?)
+ expect(json_response['can_create_project']).to eq(user.can_create_project?)
+ expect(json_response['can_create_group']).to eq(user.can_create_group?)
+ expect(json_response['projects_limit']).to eq(user.projects_limit)
end
it "should return 401 error if user is unauthenticated" do
get api("/user")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -426,7 +426,7 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
get api("/user/keys")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
@@ -435,9 +435,9 @@ describe API::API, api: true do
user.keys << key
user.save
get api("/user/keys", user)
- response.status.should == 200
- json_response.should be_an Array
- json_response.first["title"].should == key.title
+ expect(response.status).to eq(200)
+ expect(json_response).to be_an Array
+ expect(json_response.first["title"]).to eq(key.title)
end
end
end
@@ -447,14 +447,14 @@ describe API::API, api: true do
user.keys << key
user.save
get api("/user/keys/#{key.id}", user)
- response.status.should == 200
- json_response["title"].should == key.title
+ expect(response.status).to eq(200)
+ expect(json_response["title"]).to eq(key.title)
end
it "should return 404 Not Found within invalid ID" do
get api("/user/keys/42", user)
- response.status.should == 404
- json_response['message'].should == '404 Not found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Not found')
end
it "should return 404 error if admin accesses user's ssh key" do
@@ -462,8 +462,8 @@ describe API::API, api: true do
user.save
admin
get api("/user/keys/#{key.id}", admin)
- response.status.should == 404
- json_response['message'].should == '404 Not found'
+ expect(response.status).to eq(404)
+ expect(json_response['message']).to eq('404 Not found')
end
end
@@ -473,29 +473,29 @@ describe API::API, api: true do
expect {
post api("/user/keys", user), key_attrs
}.to change{ user.keys.count }.by(1)
- response.status.should == 201
+ expect(response.status).to eq(201)
end
it "should return a 401 error if unauthorized" do
post api("/user/keys"), title: 'some title', key: 'some key'
- response.status.should == 401
+ expect(response.status).to eq(401)
end
it "should not create ssh key without key" do
post api("/user/keys", user), title: 'title'
- response.status.should == 400
- json_response['message'].should == '400 (Bad request) "key" not given'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('400 (Bad request) "key" not given')
end
it 'should not create ssh key without title' do
post api('/user/keys', user), key: 'some key'
- response.status.should == 400
- json_response['message'].should == '400 (Bad request) "title" not given'
+ expect(response.status).to eq(400)
+ expect(json_response['message']).to eq('400 (Bad request) "title" not given')
end
it "should not create ssh key without title" do
post api("/user/keys", user), key: "somekey"
- response.status.should == 400
+ expect(response.status).to eq(400)
end
end
@@ -506,19 +506,19 @@ describe API::API, api: true do
expect {
delete api("/user/keys/#{key.id}", user)
}.to change{user.keys.count}.by(-1)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return success if key ID not found" do
delete api("/user/keys/42", user)
- response.status.should == 200
+ expect(response.status).to eq(200)
end
it "should return 401 error if unauthorized" do
user.keys << key
user.save
delete api("/user/keys/#{key.id}")
- response.status.should == 401
+ expect(response.status).to eq(401)
end
end
end
diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb
index 7fe18ff47c3..92542df52fd 100644
--- a/spec/routing/admin_routing_spec.rb
+++ b/spec/routing/admin_routing_spec.rb
@@ -12,47 +12,47 @@ require 'spec_helper'
# DELETE /admin/users/:id(.:format) admin/users#destroy
describe Admin::UsersController, "routing" do
it "to #team_update" do
- put("/admin/users/1/team_update").should route_to('admin/users#team_update', id: '1')
+ expect(put("/admin/users/1/team_update")).to route_to('admin/users#team_update', id: '1')
end
it "to #block" do
- put("/admin/users/1/block").should route_to('admin/users#block', id: '1')
+ expect(put("/admin/users/1/block")).to route_to('admin/users#block', id: '1')
end
it "to #unblock" do
- put("/admin/users/1/unblock").should route_to('admin/users#unblock', id: '1')
+ expect(put("/admin/users/1/unblock")).to route_to('admin/users#unblock', id: '1')
end
it "to #index" do
- get("/admin/users").should route_to('admin/users#index')
+ expect(get("/admin/users")).to route_to('admin/users#index')
end
it "to #show" do
- get("/admin/users/1").should route_to('admin/users#show', id: '1')
+ expect(get("/admin/users/1")).to route_to('admin/users#show', id: '1')
end
it "to #create" do
- post("/admin/users").should route_to('admin/users#create')
+ expect(post("/admin/users")).to route_to('admin/users#create')
end
it "to #new" do
- get("/admin/users/new").should route_to('admin/users#new')
+ expect(get("/admin/users/new")).to route_to('admin/users#new')
end
it "to #edit" do
- get("/admin/users/1/edit").should route_to('admin/users#edit', id: '1')
+ expect(get("/admin/users/1/edit")).to route_to('admin/users#edit', id: '1')
end
it "to #show" do
- get("/admin/users/1").should route_to('admin/users#show', id: '1')
+ expect(get("/admin/users/1")).to route_to('admin/users#show', id: '1')
end
it "to #update" do
- put("/admin/users/1").should route_to('admin/users#update', id: '1')
+ expect(put("/admin/users/1")).to route_to('admin/users#update', id: '1')
end
it "to #destroy" do
- delete("/admin/users/1").should route_to('admin/users#destroy', id: '1')
+ expect(delete("/admin/users/1")).to route_to('admin/users#destroy', id: '1')
end
end
@@ -67,11 +67,11 @@ end
# DELETE /admin/projects/:id(.:format) admin/projects#destroy {id: /[^\/]+/}
describe Admin::ProjectsController, "routing" do
it "to #index" do
- get("/admin/projects").should route_to('admin/projects#index')
+ expect(get("/admin/projects")).to route_to('admin/projects#index')
end
it "to #show" do
- get("/admin/projects/gitlab").should route_to('admin/projects#show', id: 'gitlab')
+ expect(get("/admin/projects/gitlab")).to route_to('admin/projects#show', id: 'gitlab')
end
end
@@ -81,19 +81,19 @@ end
# admin_hook DELETE /admin/hooks/:id(.:format) admin/hooks#destroy
describe Admin::HooksController, "routing" do
it "to #test" do
- get("/admin/hooks/1/test").should route_to('admin/hooks#test', hook_id: '1')
+ expect(get("/admin/hooks/1/test")).to route_to('admin/hooks#test', hook_id: '1')
end
it "to #index" do
- get("/admin/hooks").should route_to('admin/hooks#index')
+ expect(get("/admin/hooks")).to route_to('admin/hooks#index')
end
it "to #create" do
- post("/admin/hooks").should route_to('admin/hooks#create')
+ expect(post("/admin/hooks")).to route_to('admin/hooks#create')
end
it "to #destroy" do
- delete("/admin/hooks/1").should route_to('admin/hooks#destroy', id: '1')
+ expect(delete("/admin/hooks/1")).to route_to('admin/hooks#destroy', id: '1')
end
end
@@ -101,21 +101,21 @@ end
# admin_logs GET /admin/logs(.:format) admin/logs#show
describe Admin::LogsController, "routing" do
it "to #show" do
- get("/admin/logs").should route_to('admin/logs#show')
+ expect(get("/admin/logs")).to route_to('admin/logs#show')
end
end
# admin_background_jobs GET /admin/background_jobs(.:format) admin/background_jobs#show
describe Admin::BackgroundJobsController, "routing" do
it "to #show" do
- get("/admin/background_jobs").should route_to('admin/background_jobs#show')
+ expect(get("/admin/background_jobs")).to route_to('admin/background_jobs#show')
end
end
# admin_root /admin(.:format) admin/dashboard#index
describe Admin::DashboardController, "routing" do
it "to #index" do
- get("/admin").should route_to('admin/dashboard#index')
+ expect(get("/admin")).to route_to('admin/dashboard#index')
end
end
diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb
index 112b825e023..24592942a96 100644
--- a/spec/routing/notifications_routing_spec.rb
+++ b/spec/routing/notifications_routing_spec.rb
@@ -3,11 +3,11 @@ require "spec_helper"
describe Profiles::NotificationsController do
describe "routing" do
it "routes to #show" do
- get("/profile/notifications").should route_to("profiles/notifications#show")
+ expect(get("/profile/notifications")).to route_to("profiles/notifications#show")
end
it "routes to #update" do
- put("/profile/notifications").should route_to("profiles/notifications#update")
+ expect(put("/profile/notifications")).to route_to("profiles/notifications#update")
end
end
end
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index b8f9d2bf20a..6b587345597 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -25,31 +25,31 @@ shared_examples 'RESTful project resources' do
let(:actions) { [:index, :create, :new, :edit, :show, :update, :destroy] }
it 'to #index' do
- get("/gitlab/gitlabhq/#{controller}").should route_to("projects/#{controller}#index", project_id: 'gitlab/gitlabhq') if actions.include?(:index)
+ expect(get("/gitlab/gitlabhq/#{controller}")).to route_to("projects/#{controller}#index", project_id: 'gitlab/gitlabhq') if actions.include?(:index)
end
it 'to #create' do
- post("/gitlab/gitlabhq/#{controller}").should route_to("projects/#{controller}#create", project_id: 'gitlab/gitlabhq') if actions.include?(:create)
+ expect(post("/gitlab/gitlabhq/#{controller}")).to route_to("projects/#{controller}#create", project_id: 'gitlab/gitlabhq') if actions.include?(:create)
end
it 'to #new' do
- get("/gitlab/gitlabhq/#{controller}/new").should route_to("projects/#{controller}#new", project_id: 'gitlab/gitlabhq') if actions.include?(:new)
+ expect(get("/gitlab/gitlabhq/#{controller}/new")).to route_to("projects/#{controller}#new", project_id: 'gitlab/gitlabhq') if actions.include?(:new)
end
it 'to #edit' do
- get("/gitlab/gitlabhq/#{controller}/1/edit").should route_to("projects/#{controller}#edit", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:edit)
+ expect(get("/gitlab/gitlabhq/#{controller}/1/edit")).to route_to("projects/#{controller}#edit", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:edit)
end
it 'to #show' do
- get("/gitlab/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#show", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:show)
+ expect(get("/gitlab/gitlabhq/#{controller}/1")).to route_to("projects/#{controller}#show", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:show)
end
it 'to #update' do
- put("/gitlab/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#update", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:update)
+ expect(put("/gitlab/gitlabhq/#{controller}/1")).to route_to("projects/#{controller}#update", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:update)
end
it 'to #destroy' do
- delete("/gitlab/gitlabhq/#{controller}/1").should route_to("projects/#{controller}#destroy", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:destroy)
+ expect(delete("/gitlab/gitlabhq/#{controller}/1")).to route_to("projects/#{controller}#destroy", project_id: 'gitlab/gitlabhq', id: '1') if actions.include?(:destroy)
end
end
@@ -63,35 +63,35 @@ end
# markdown_preview_project POST /:id/markdown_preview(.:format) projects#markdown_preview
describe ProjectsController, 'routing' do
it 'to #create' do
- post('/projects').should route_to('projects#create')
+ expect(post('/projects')).to route_to('projects#create')
end
it 'to #new' do
- get('/projects/new').should route_to('projects#new')
+ expect(get('/projects/new')).to route_to('projects#new')
end
it 'to #edit' do
- get('/gitlab/gitlabhq/edit').should route_to('projects#edit', id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/edit')).to route_to('projects#edit', id: 'gitlab/gitlabhq')
end
it 'to #autocomplete_sources' do
- get('/gitlab/gitlabhq/autocomplete_sources').should route_to('projects#autocomplete_sources', id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/autocomplete_sources')).to route_to('projects#autocomplete_sources', id: 'gitlab/gitlabhq')
end
it 'to #show' do
- get('/gitlab/gitlabhq').should route_to('projects#show', id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq')).to route_to('projects#show', id: 'gitlab/gitlabhq')
end
it 'to #update' do
- put('/gitlab/gitlabhq').should route_to('projects#update', id: 'gitlab/gitlabhq')
+ expect(put('/gitlab/gitlabhq')).to route_to('projects#update', id: 'gitlab/gitlabhq')
end
it 'to #destroy' do
- delete('/gitlab/gitlabhq').should route_to('projects#destroy', id: 'gitlab/gitlabhq')
+ expect(delete('/gitlab/gitlabhq')).to route_to('projects#destroy', id: 'gitlab/gitlabhq')
end
it 'to #markdown_preview' do
- post('/gitlab/gitlabhq/markdown_preview').should(
+ expect(post('/gitlab/gitlabhq/markdown_preview')).to(
route_to('projects#markdown_preview', id: 'gitlab/gitlabhq')
)
end
@@ -105,11 +105,11 @@ end
# DELETE /:project_id/wikis/:id(.:format) projects/wikis#destroy
describe Projects::WikisController, 'routing' do
it 'to #pages' do
- get('/gitlab/gitlabhq/wikis/pages').should route_to('projects/wikis#pages', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/wikis/pages')).to route_to('projects/wikis#pages', project_id: 'gitlab/gitlabhq')
end
it 'to #history' do
- get('/gitlab/gitlabhq/wikis/1/history').should route_to('projects/wikis#history', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/wikis/1/history')).to route_to('projects/wikis#history', project_id: 'gitlab/gitlabhq', id: '1')
end
it_behaves_like 'RESTful project resources' do
@@ -124,43 +124,43 @@ end
# edit_project_repository GET /:project_id/repository/edit(.:format) projects/repositories#edit
describe Projects::RepositoriesController, 'routing' do
it 'to #archive' do
- get('/gitlab/gitlabhq/repository/archive').should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/repository/archive')).to route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq')
end
it 'to #archive format:zip' do
- get('/gitlab/gitlabhq/repository/archive.zip').should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'zip')
+ expect(get('/gitlab/gitlabhq/repository/archive.zip')).to route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'zip')
end
it 'to #archive format:tar.bz2' do
- get('/gitlab/gitlabhq/repository/archive.tar.bz2').should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'tar.bz2')
+ expect(get('/gitlab/gitlabhq/repository/archive.tar.bz2')).to route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'tar.bz2')
end
it 'to #show' do
- get('/gitlab/gitlabhq/repository').should route_to('projects/repositories#show', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/repository')).to route_to('projects/repositories#show', project_id: 'gitlab/gitlabhq')
end
end
describe Projects::BranchesController, 'routing' do
it 'to #branches' do
- get('/gitlab/gitlabhq/branches').should route_to('projects/branches#index', project_id: 'gitlab/gitlabhq')
- delete('/gitlab/gitlabhq/branches/feature%2345').should route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45')
- delete('/gitlab/gitlabhq/branches/feature%2B45').should route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45')
- delete('/gitlab/gitlabhq/branches/feature@45').should route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45')
- delete('/gitlab/gitlabhq/branches/feature%2345/foo/bar/baz').should route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45/foo/bar/baz')
- delete('/gitlab/gitlabhq/branches/feature%2B45/foo/bar/baz').should route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45/foo/bar/baz')
- delete('/gitlab/gitlabhq/branches/feature@45/foo/bar/baz').should route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45/foo/bar/baz')
+ expect(get('/gitlab/gitlabhq/branches')).to route_to('projects/branches#index', project_id: 'gitlab/gitlabhq')
+ expect(delete('/gitlab/gitlabhq/branches/feature%2345')).to route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45')
+ expect(delete('/gitlab/gitlabhq/branches/feature%2B45')).to route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45')
+ expect(delete('/gitlab/gitlabhq/branches/feature@45')).to route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45')
+ expect(delete('/gitlab/gitlabhq/branches/feature%2345/foo/bar/baz')).to route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45/foo/bar/baz')
+ expect(delete('/gitlab/gitlabhq/branches/feature%2B45/foo/bar/baz')).to route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45/foo/bar/baz')
+ expect(delete('/gitlab/gitlabhq/branches/feature@45/foo/bar/baz')).to route_to('projects/branches#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45/foo/bar/baz')
end
end
describe Projects::TagsController, 'routing' do
it 'to #tags' do
- get('/gitlab/gitlabhq/tags').should route_to('projects/tags#index', project_id: 'gitlab/gitlabhq')
- delete('/gitlab/gitlabhq/tags/feature%2345').should route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45')
- delete('/gitlab/gitlabhq/tags/feature%2B45').should route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45')
- delete('/gitlab/gitlabhq/tags/feature@45').should route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45')
- delete('/gitlab/gitlabhq/tags/feature%2345/foo/bar/baz').should route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45/foo/bar/baz')
- delete('/gitlab/gitlabhq/tags/feature%2B45/foo/bar/baz').should route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45/foo/bar/baz')
- delete('/gitlab/gitlabhq/tags/feature@45/foo/bar/baz').should route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45/foo/bar/baz')
+ expect(get('/gitlab/gitlabhq/tags')).to route_to('projects/tags#index', project_id: 'gitlab/gitlabhq')
+ expect(delete('/gitlab/gitlabhq/tags/feature%2345')).to route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45')
+ expect(delete('/gitlab/gitlabhq/tags/feature%2B45')).to route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45')
+ expect(delete('/gitlab/gitlabhq/tags/feature@45')).to route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45')
+ expect(delete('/gitlab/gitlabhq/tags/feature%2345/foo/bar/baz')).to route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature#45/foo/bar/baz')
+ expect(delete('/gitlab/gitlabhq/tags/feature%2B45/foo/bar/baz')).to route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature+45/foo/bar/baz')
+ expect(delete('/gitlab/gitlabhq/tags/feature@45/foo/bar/baz')).to route_to('projects/tags#destroy', project_id: 'gitlab/gitlabhq', id: 'feature@45/foo/bar/baz')
end
end
@@ -193,19 +193,19 @@ end
# logs_file_project_ref GET /:project_id/refs/:id/logs_tree/:path(.:format) refs#logs_tree
describe Projects::RefsController, 'routing' do
it 'to #switch' do
- get('/gitlab/gitlabhq/refs/switch').should route_to('projects/refs#switch', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/refs/switch')).to route_to('projects/refs#switch', project_id: 'gitlab/gitlabhq')
end
it 'to #logs_tree' do
- get('/gitlab/gitlabhq/refs/stable/logs_tree').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable')
- get('/gitlab/gitlabhq/refs/feature%2345/logs_tree').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature#45')
- get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature+45')
- get('/gitlab/gitlabhq/refs/feature@45/logs_tree').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature@45')
- get('/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'foo/bar/baz')
- get('/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature#45', path: 'foo/bar/baz')
- get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature+45', path: 'foo/bar/baz')
- get('/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature@45', path: 'foo/bar/baz')
- get('/gitlab/gitlabhq/refs/stable/logs_tree/files.scss').should route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'files.scss')
+ expect(get('/gitlab/gitlabhq/refs/stable/logs_tree')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable')
+ expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature#45')
+ expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature+45')
+ expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature@45')
+ expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'foo/bar/baz')
+ expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature#45', path: 'foo/bar/baz')
+ expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature+45', path: 'foo/bar/baz')
+ expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'feature@45', path: 'foo/bar/baz')
+ expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', project_id: 'gitlab/gitlabhq', id: 'stable', path: 'files.scss')
end
end
@@ -223,31 +223,31 @@ end
# DELETE /:project_id/merge_requests/:id(.:format) projects/merge_requests#destroy
describe Projects::MergeRequestsController, 'routing' do
it 'to #diffs' do
- get('/gitlab/gitlabhq/merge_requests/1/diffs').should route_to('projects/merge_requests#diffs', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/merge_requests/1/diffs')).to route_to('projects/merge_requests#diffs', project_id: 'gitlab/gitlabhq', id: '1')
end
it 'to #automerge' do
- post('/gitlab/gitlabhq/merge_requests/1/automerge').should route_to(
+ expect(post('/gitlab/gitlabhq/merge_requests/1/automerge')).to route_to(
'projects/merge_requests#automerge',
project_id: 'gitlab/gitlabhq', id: '1'
)
end
it 'to #automerge_check' do
- get('/gitlab/gitlabhq/merge_requests/1/automerge_check').should route_to('projects/merge_requests#automerge_check', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/merge_requests/1/automerge_check')).to route_to('projects/merge_requests#automerge_check', project_id: 'gitlab/gitlabhq', id: '1')
end
it 'to #branch_from' do
- get('/gitlab/gitlabhq/merge_requests/branch_from').should route_to('projects/merge_requests#branch_from', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/merge_requests/branch_from')).to route_to('projects/merge_requests#branch_from', project_id: 'gitlab/gitlabhq')
end
it 'to #branch_to' do
- get('/gitlab/gitlabhq/merge_requests/branch_to').should route_to('projects/merge_requests#branch_to', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/merge_requests/branch_to')).to route_to('projects/merge_requests#branch_to', project_id: 'gitlab/gitlabhq')
end
it 'to #show' do
- get('/gitlab/gitlabhq/merge_requests/1.diff').should route_to('projects/merge_requests#show', project_id: 'gitlab/gitlabhq', id: '1', format: 'diff')
- get('/gitlab/gitlabhq/merge_requests/1.patch').should route_to('projects/merge_requests#show', project_id: 'gitlab/gitlabhq', id: '1', format: 'patch')
+ expect(get('/gitlab/gitlabhq/merge_requests/1.diff')).to route_to('projects/merge_requests#show', project_id: 'gitlab/gitlabhq', id: '1', format: 'diff')
+ expect(get('/gitlab/gitlabhq/merge_requests/1.patch')).to route_to('projects/merge_requests#show', project_id: 'gitlab/gitlabhq', id: '1', format: 'patch')
end
it_behaves_like 'RESTful project resources' do
@@ -266,35 +266,35 @@ end
# DELETE /:project_id/snippets/:id(.:format) snippets#destroy
describe SnippetsController, 'routing' do
it 'to #raw' do
- get('/gitlab/gitlabhq/snippets/1/raw').should route_to('projects/snippets#raw', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', project_id: 'gitlab/gitlabhq', id: '1')
end
it 'to #index' do
- get('/gitlab/gitlabhq/snippets').should route_to('projects/snippets#index', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#index', project_id: 'gitlab/gitlabhq')
end
it 'to #create' do
- post('/gitlab/gitlabhq/snippets').should route_to('projects/snippets#create', project_id: 'gitlab/gitlabhq')
+ expect(post('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#create', project_id: 'gitlab/gitlabhq')
end
it 'to #new' do
- get('/gitlab/gitlabhq/snippets/new').should route_to('projects/snippets#new', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/snippets/new')).to route_to('projects/snippets#new', project_id: 'gitlab/gitlabhq')
end
it 'to #edit' do
- get('/gitlab/gitlabhq/snippets/1/edit').should route_to('projects/snippets#edit', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/snippets/1/edit')).to route_to('projects/snippets#edit', project_id: 'gitlab/gitlabhq', id: '1')
end
it 'to #show' do
- get('/gitlab/gitlabhq/snippets/1').should route_to('projects/snippets#show', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', project_id: 'gitlab/gitlabhq', id: '1')
end
it 'to #update' do
- put('/gitlab/gitlabhq/snippets/1').should route_to('projects/snippets#update', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(put('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#update', project_id: 'gitlab/gitlabhq', id: '1')
end
it 'to #destroy' do
- delete('/gitlab/gitlabhq/snippets/1').should route_to('projects/snippets#destroy', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', project_id: 'gitlab/gitlabhq', id: '1')
end
end
@@ -304,7 +304,7 @@ end
# project_hook DELETE /:project_id/hooks/:id(.:format) hooks#destroy
describe Projects::HooksController, 'routing' do
it 'to #test' do
- get('/gitlab/gitlabhq/hooks/1/test').should route_to('projects/hooks#test', project_id: 'gitlab/gitlabhq', id: '1')
+ expect(get('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', project_id: 'gitlab/gitlabhq', id: '1')
end
it_behaves_like 'RESTful project resources' do
@@ -316,10 +316,10 @@ end
# project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /[[:alnum:]]{6,40}/, project_id: /[^\/]+/}
describe Projects::CommitController, 'routing' do
it 'to #show' do
- get('/gitlab/gitlabhq/commit/4246fb').should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb')
- get('/gitlab/gitlabhq/commit/4246fb.diff').should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb', format: 'diff')
- get('/gitlab/gitlabhq/commit/4246fb.patch').should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb', format: 'patch')
- get('/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5').should route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5')
+ expect(get('/gitlab/gitlabhq/commit/4246fb')).to route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb')
+ expect(get('/gitlab/gitlabhq/commit/4246fb.diff')).to route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb', format: 'diff')
+ expect(get('/gitlab/gitlabhq/commit/4246fb.patch')).to route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fb', format: 'patch')
+ expect(get('/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5')).to route_to('projects/commit#show', project_id: 'gitlab/gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5')
end
end
@@ -334,7 +334,7 @@ describe Projects::CommitsController, 'routing' do
end
it 'to #show' do
- get('/gitlab/gitlabhq/commits/master.atom').should route_to('projects/commits#show', project_id: 'gitlab/gitlabhq', id: 'master', format: 'atom')
+ expect(get('/gitlab/gitlabhq/commits/master.atom')).to route_to('projects/commits#show', project_id: 'gitlab/gitlabhq', id: 'master', format: 'atom')
end
end
@@ -369,7 +369,7 @@ end
# project_labels GET /:project_id/labels(.:format) labels#index
describe Projects::LabelsController, 'routing' do
it 'to #index' do
- get('/gitlab/gitlabhq/labels').should route_to('projects/labels#index', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/labels')).to route_to('projects/labels#index', project_id: 'gitlab/gitlabhq')
end
end
@@ -385,7 +385,7 @@ end
# DELETE /:project_id/issues/:id(.:format) issues#destroy
describe Projects::IssuesController, 'routing' do
it 'to #bulk_update' do
- post('/gitlab/gitlabhq/issues/bulk_update').should route_to('projects/issues#bulk_update', project_id: 'gitlab/gitlabhq')
+ expect(post('/gitlab/gitlabhq/issues/bulk_update')).to route_to('projects/issues#bulk_update', project_id: 'gitlab/gitlabhq')
end
it_behaves_like 'RESTful project resources' do
@@ -407,39 +407,39 @@ end
# project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/}
describe Projects::BlameController, 'routing' do
it 'to #show' do
- get('/gitlab/gitlabhq/blame/master/app/models/project.rb').should route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb')
- get('/gitlab/gitlabhq/blame/master/files.scss').should route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss')
+ expect(get('/gitlab/gitlabhq/blame/master/app/models/project.rb')).to route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb')
+ expect(get('/gitlab/gitlabhq/blame/master/files.scss')).to route_to('projects/blame#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss')
end
end
# project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/}
describe Projects::BlobController, 'routing' do
it 'to #show' do
- get('/gitlab/gitlabhq/blob/master/app/models/project.rb').should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb')
- get('/gitlab/gitlabhq/blob/master/app/models/compare.rb').should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/compare.rb')
- get('/gitlab/gitlabhq/blob/master/app/models/diff.js').should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/diff.js')
- get('/gitlab/gitlabhq/blob/master/files.scss').should route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss')
+ expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb')
+ expect(get('/gitlab/gitlabhq/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/compare.rb')
+ expect(get('/gitlab/gitlabhq/blob/master/app/models/diff.js')).to route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/diff.js')
+ expect(get('/gitlab/gitlabhq/blob/master/files.scss')).to route_to('projects/blob#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss')
end
end
# project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/}
describe Projects::TreeController, 'routing' do
it 'to #show' do
- get('/gitlab/gitlabhq/tree/master/app/models/project.rb').should route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb')
- get('/gitlab/gitlabhq/tree/master/files.scss').should route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss')
+ expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/app/models/project.rb')
+ expect(get('/gitlab/gitlabhq/tree/master/files.scss')).to route_to('projects/tree#show', project_id: 'gitlab/gitlabhq', id: 'master/files.scss')
end
end
describe Projects::BlobController, 'routing' do
it 'to #edit' do
- get('/gitlab/gitlabhq/edit/master/app/models/project.rb').should(
+ expect(get('/gitlab/gitlabhq/edit/master/app/models/project.rb')).to(
route_to('projects/blob#edit',
project_id: 'gitlab/gitlabhq',
id: 'master/app/models/project.rb'))
end
it 'to #preview' do
- post('/gitlab/gitlabhq/preview/master/app/models/project.rb').should(
+ expect(post('/gitlab/gitlabhq/preview/master/app/models/project.rb')).to(
route_to('projects/blob#preview',
project_id: 'gitlab/gitlabhq',
id: 'master/app/models/project.rb'))
@@ -451,46 +451,46 @@ end
# project_compare /:project_id/compare/:from...:to(.:format) compare#show {from: /.+/, to: /.+/, id: /[^\/]+/, project_id: /[^\/]+/}
describe Projects::CompareController, 'routing' do
it 'to #index' do
- get('/gitlab/gitlabhq/compare').should route_to('projects/compare#index', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/compare')).to route_to('projects/compare#index', project_id: 'gitlab/gitlabhq')
end
it 'to #compare' do
- post('/gitlab/gitlabhq/compare').should route_to('projects/compare#create', project_id: 'gitlab/gitlabhq')
+ expect(post('/gitlab/gitlabhq/compare')).to route_to('projects/compare#create', project_id: 'gitlab/gitlabhq')
end
it 'to #show' do
- get('/gitlab/gitlabhq/compare/master...stable').should route_to('projects/compare#show', project_id: 'gitlab/gitlabhq', from: 'master', to: 'stable')
- get('/gitlab/gitlabhq/compare/issue/1234...stable').should route_to('projects/compare#show', project_id: 'gitlab/gitlabhq', from: 'issue/1234', to: 'stable')
+ expect(get('/gitlab/gitlabhq/compare/master...stable')).to route_to('projects/compare#show', project_id: 'gitlab/gitlabhq', from: 'master', to: 'stable')
+ expect(get('/gitlab/gitlabhq/compare/issue/1234...stable')).to route_to('projects/compare#show', project_id: 'gitlab/gitlabhq', from: 'issue/1234', to: 'stable')
end
end
describe Projects::NetworkController, 'routing' do
it 'to #show' do
- get('/gitlab/gitlabhq/network/master').should route_to('projects/network#show', project_id: 'gitlab/gitlabhq', id: 'master')
- get('/gitlab/gitlabhq/network/master.json').should route_to('projects/network#show', project_id: 'gitlab/gitlabhq', id: 'master', format: 'json')
+ expect(get('/gitlab/gitlabhq/network/master')).to route_to('projects/network#show', project_id: 'gitlab/gitlabhq', id: 'master')
+ expect(get('/gitlab/gitlabhq/network/master.json')).to route_to('projects/network#show', project_id: 'gitlab/gitlabhq', id: 'master', format: 'json')
end
end
describe Projects::GraphsController, 'routing' do
it 'to #show' do
- get('/gitlab/gitlabhq/graphs/master').should route_to('projects/graphs#show', project_id: 'gitlab/gitlabhq', id: 'master')
+ expect(get('/gitlab/gitlabhq/graphs/master')).to route_to('projects/graphs#show', project_id: 'gitlab/gitlabhq', id: 'master')
end
end
describe Projects::ForksController, 'routing' do
it 'to #new' do
- get('/gitlab/gitlabhq/fork/new').should route_to('projects/forks#new', project_id: 'gitlab/gitlabhq')
+ expect(get('/gitlab/gitlabhq/fork/new')).to route_to('projects/forks#new', project_id: 'gitlab/gitlabhq')
end
it 'to #create' do
- post('/gitlab/gitlabhq/fork').should route_to('projects/forks#create', project_id: 'gitlab/gitlabhq')
+ expect(post('/gitlab/gitlabhq/fork')).to route_to('projects/forks#create', project_id: 'gitlab/gitlabhq')
end
end
# project_avatar DELETE /project/avatar(.:format) projects/avatars#destroy
describe Projects::AvatarsController, 'routing' do
it 'to #destroy' do
- delete('/gitlab/gitlabhq/avatar').should route_to(
+ expect(delete('/gitlab/gitlabhq/avatar')).to route_to(
'projects/avatars#destroy', project_id: 'gitlab/gitlabhq')
end
end
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb
index 1e92cf62dd5..d4915b51952 100644
--- a/spec/routing/routing_spec.rb
+++ b/spec/routing/routing_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
# search GET /search(.:format) search#show
describe SearchController, "routing" do
it "to #show" do
- get("/search").should route_to('search#show')
+ expect(get("/search")).to route_to('search#show')
end
end
@@ -11,11 +11,11 @@ end
# /:path Grack
describe "Mounted Apps", "routing" do
it "to API" do
- get("/api/issues").should be_routable
+ expect(get("/api/issues")).to be_routable
end
it "to Grack" do
- get("/gitlab/gitlabhq.git").should be_routable
+ expect(get("/gitlab/gitlabhq.git")).to be_routable
end
end
@@ -28,39 +28,39 @@ end
# DELETE /snippets/:id(.:format) snippets#destroy
describe SnippetsController, "routing" do
it "to #user_index" do
- get("/s/User").should route_to('snippets#user_index', username: 'User')
+ expect(get("/s/User")).to route_to('snippets#user_index', username: 'User')
end
it "to #raw" do
- get("/snippets/1/raw").should route_to('snippets#raw', id: '1')
+ expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1')
end
it "to #index" do
- get("/snippets").should route_to('snippets#index')
+ expect(get("/snippets")).to route_to('snippets#index')
end
it "to #create" do
- post("/snippets").should route_to('snippets#create')
+ expect(post("/snippets")).to route_to('snippets#create')
end
it "to #new" do
- get("/snippets/new").should route_to('snippets#new')
+ expect(get("/snippets/new")).to route_to('snippets#new')
end
it "to #edit" do
- get("/snippets/1/edit").should route_to('snippets#edit', id: '1')
+ expect(get("/snippets/1/edit")).to route_to('snippets#edit', id: '1')
end
it "to #show" do
- get("/snippets/1").should route_to('snippets#show', id: '1')
+ expect(get("/snippets/1")).to route_to('snippets#show', id: '1')
end
it "to #update" do
- put("/snippets/1").should route_to('snippets#update', id: '1')
+ expect(put("/snippets/1")).to route_to('snippets#update', id: '1')
end
it "to #destroy" do
- delete("/snippets/1").should route_to('snippets#destroy', id: '1')
+ expect(delete("/snippets/1")).to route_to('snippets#destroy', id: '1')
end
end
@@ -75,39 +75,39 @@ end
# help_raketasks GET /help/raketasks(.:format) help#raketasks
describe HelpController, "routing" do
it "to #index" do
- get("/help").should route_to('help#index')
+ expect(get("/help")).to route_to('help#index')
end
it "to #permissions" do
- get("/help/permissions/permissions").should route_to('help#show', category: "permissions", file: "permissions")
+ expect(get("/help/permissions/permissions")).to route_to('help#show', category: "permissions", file: "permissions")
end
it "to #workflow" do
- get("/help/workflow/README").should route_to('help#show', category: "workflow", file: "README")
+ expect(get("/help/workflow/README")).to route_to('help#show', category: "workflow", file: "README")
end
it "to #api" do
- get("/help/api/README").should route_to('help#show', category: "api", file: "README")
+ expect(get("/help/api/README")).to route_to('help#show', category: "api", file: "README")
end
it "to #web_hooks" do
- get("/help/web_hooks/web_hooks").should route_to('help#show', category: "web_hooks", file: "web_hooks")
+ expect(get("/help/web_hooks/web_hooks")).to route_to('help#show', category: "web_hooks", file: "web_hooks")
end
it "to #system_hooks" do
- get("/help/system_hooks/system_hooks").should route_to('help#show', category: "system_hooks", file: "system_hooks")
+ expect(get("/help/system_hooks/system_hooks")).to route_to('help#show', category: "system_hooks", file: "system_hooks")
end
it "to #markdown" do
- get("/help/markdown/markdown").should route_to('help#show',category: "markdown", file: "markdown")
+ expect(get("/help/markdown/markdown")).to route_to('help#show',category: "markdown", file: "markdown")
end
it "to #ssh" do
- get("/help/ssh/README").should route_to('help#show', category: "ssh", file: "README")
+ expect(get("/help/ssh/README")).to route_to('help#show', category: "ssh", file: "README")
end
it "to #raketasks" do
- get("/help/raketasks/README").should route_to('help#show', category: "raketasks", file: "README")
+ expect(get("/help/raketasks/README")).to route_to('help#show', category: "raketasks", file: "README")
end
end
@@ -121,23 +121,23 @@ end
# profile_update PUT /profile/update(.:format) profile#update
describe ProfilesController, "routing" do
it "to #account" do
- get("/profile/account").should route_to('profiles/accounts#show')
+ expect(get("/profile/account")).to route_to('profiles/accounts#show')
end
it "to #history" do
- get("/profile/history").should route_to('profiles#history')
+ expect(get("/profile/history")).to route_to('profiles#history')
end
it "to #reset_private_token" do
- put("/profile/reset_private_token").should route_to('profiles#reset_private_token')
+ expect(put("/profile/reset_private_token")).to route_to('profiles#reset_private_token')
end
it "to #show" do
- get("/profile").should route_to('profiles#show')
+ expect(get("/profile")).to route_to('profiles#show')
end
it "to #design" do
- get("/profile/design").should route_to('profiles#design')
+ expect(get("/profile/design")).to route_to('profiles#design')
end
end
@@ -150,36 +150,36 @@ end
# DELETE /keys/:id(.:format) keys#destroy
describe Profiles::KeysController, "routing" do
it "to #index" do
- get("/profile/keys").should route_to('profiles/keys#index')
+ expect(get("/profile/keys")).to route_to('profiles/keys#index')
end
it "to #create" do
- post("/profile/keys").should route_to('profiles/keys#create')
+ expect(post("/profile/keys")).to route_to('profiles/keys#create')
end
it "to #new" do
- get("/profile/keys/new").should route_to('profiles/keys#new')
+ expect(get("/profile/keys/new")).to route_to('profiles/keys#new')
end
it "to #edit" do
- get("/profile/keys/1/edit").should route_to('profiles/keys#edit', id: '1')
+ expect(get("/profile/keys/1/edit")).to route_to('profiles/keys#edit', id: '1')
end
it "to #show" do
- get("/profile/keys/1").should route_to('profiles/keys#show', id: '1')
+ expect(get("/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
end
it "to #update" do
- put("/profile/keys/1").should route_to('profiles/keys#update', id: '1')
+ expect(put("/profile/keys/1")).to route_to('profiles/keys#update', id: '1')
end
it "to #destroy" do
- delete("/profile/keys/1").should route_to('profiles/keys#destroy', id: '1')
+ expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
end
# get all the ssh-keys of a user
it "to #get_keys" do
- get("/foo.keys").should route_to('profiles/keys#get_keys', username: 'foo')
+ expect(get("/foo.keys")).to route_to('profiles/keys#get_keys', username: 'foo')
end
end
@@ -188,22 +188,22 @@ end
# DELETE /keys/:id(.:format) keys#destroy
describe Profiles::EmailsController, "routing" do
it "to #index" do
- get("/profile/emails").should route_to('profiles/emails#index')
+ expect(get("/profile/emails")).to route_to('profiles/emails#index')
end
it "to #create" do
- post("/profile/emails").should route_to('profiles/emails#create')
+ expect(post("/profile/emails")).to route_to('profiles/emails#create')
end
it "to #destroy" do
- delete("/profile/emails/1").should route_to('profiles/emails#destroy', id: '1')
+ expect(delete("/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
end
end
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
describe Profiles::AvatarsController, "routing" do
it "to #destroy" do
- delete("/profile/avatar").should route_to('profiles/avatars#destroy')
+ expect(delete("/profile/avatar")).to route_to('profiles/avatars#destroy')
end
end
@@ -213,16 +213,16 @@ end
# root / dashboard#show
describe DashboardController, "routing" do
it "to #index" do
- get("/dashboard").should route_to('dashboard#show')
- get("/").should route_to('dashboard#show')
+ expect(get("/dashboard")).to route_to('dashboard#show')
+ expect(get("/")).to route_to('dashboard#show')
end
it "to #issues" do
- get("/dashboard/issues").should route_to('dashboard#issues')
+ expect(get("/dashboard/issues")).to route_to('dashboard#issues')
end
it "to #merge_requests" do
- get("/dashboard/merge_requests").should route_to('dashboard#merge_requests')
+ expect(get("/dashboard/merge_requests")).to route_to('dashboard#merge_requests')
end
end
@@ -241,11 +241,11 @@ end
describe "Groups", "routing" do
it "to #show" do
- get("/groups/1").should route_to('groups#show', id: '1')
+ expect(get("/groups/1")).to route_to('groups#show', id: '1')
end
it "also display group#show on the short path" do
- get('/1').should route_to('namespaces#show', id: '1')
+ expect(get('/1')).to route_to('namespaces#show', id: '1')
end
end
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb
index 713aa3e7e74..007a9eed192 100644
--- a/spec/services/event_create_service_spec.rb
+++ b/spec/services/event_create_service_spec.rb
@@ -7,7 +7,7 @@ describe EventCreateService do
describe :open_issue do
let(:issue) { create(:issue) }
- it { service.open_issue(issue, issue.author).should be_true }
+ it { expect(service.open_issue(issue, issue.author)).to be_truthy }
it "should create new event" do
expect { service.open_issue(issue, issue.author) }.to change { Event.count }
@@ -17,7 +17,7 @@ describe EventCreateService do
describe :close_issue do
let(:issue) { create(:issue) }
- it { service.close_issue(issue, issue.author).should be_true }
+ it { expect(service.close_issue(issue, issue.author)).to be_truthy }
it "should create new event" do
expect { service.close_issue(issue, issue.author) }.to change { Event.count }
@@ -27,7 +27,7 @@ describe EventCreateService do
describe :reopen_issue do
let(:issue) { create(:issue) }
- it { service.reopen_issue(issue, issue.author).should be_true }
+ it { expect(service.reopen_issue(issue, issue.author)).to be_truthy }
it "should create new event" do
expect { service.reopen_issue(issue, issue.author) }.to change { Event.count }
@@ -39,7 +39,7 @@ describe EventCreateService do
describe :open_mr do
let(:merge_request) { create(:merge_request) }
- it { service.open_mr(merge_request, merge_request.author).should be_true }
+ it { expect(service.open_mr(merge_request, merge_request.author)).to be_truthy }
it "should create new event" do
expect { service.open_mr(merge_request, merge_request.author) }.to change { Event.count }
@@ -49,7 +49,7 @@ describe EventCreateService do
describe :close_mr do
let(:merge_request) { create(:merge_request) }
- it { service.close_mr(merge_request, merge_request.author).should be_true }
+ it { expect(service.close_mr(merge_request, merge_request.author)).to be_truthy }
it "should create new event" do
expect { service.close_mr(merge_request, merge_request.author) }.to change { Event.count }
@@ -59,7 +59,7 @@ describe EventCreateService do
describe :merge_mr do
let(:merge_request) { create(:merge_request) }
- it { service.merge_mr(merge_request, merge_request.author).should be_true }
+ it { expect(service.merge_mr(merge_request, merge_request.author)).to be_truthy }
it "should create new event" do
expect { service.merge_mr(merge_request, merge_request.author) }.to change { Event.count }
@@ -69,7 +69,7 @@ describe EventCreateService do
describe :reopen_mr do
let(:merge_request) { create(:merge_request) }
- it { service.reopen_mr(merge_request, merge_request.author).should be_true }
+ it { expect(service.reopen_mr(merge_request, merge_request.author)).to be_truthy }
it "should create new event" do
expect { service.reopen_mr(merge_request, merge_request.author) }.to change { Event.count }
@@ -83,7 +83,7 @@ describe EventCreateService do
describe :open_milestone do
let(:milestone) { create(:milestone) }
- it { service.open_milestone(milestone, user).should be_true }
+ it { expect(service.open_milestone(milestone, user)).to be_truthy }
it "should create new event" do
expect { service.open_milestone(milestone, user) }.to change { Event.count }
@@ -93,7 +93,7 @@ describe EventCreateService do
describe :close_mr do
let(:milestone) { create(:milestone) }
- it { service.close_milestone(milestone, user).should be_true }
+ it { expect(service.close_milestone(milestone, user)).to be_truthy }
it "should create new event" do
expect { service.close_milestone(milestone, user) }.to change { Event.count }
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 3a75d65b5bc..9d0e41e4e8a 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -20,7 +20,7 @@ describe GitPushService do
service.execute(project, user, @blankrev, @newrev, @ref)
end
- it { should be_true }
+ it { is_expected.to be_truthy }
end
context 'existing branch' do
@@ -28,7 +28,7 @@ describe GitPushService do
service.execute(project, user, @oldrev, @newrev, @ref)
end
- it { should be_true }
+ it { is_expected.to be_truthy }
end
context 'rm branch' do
@@ -36,7 +36,7 @@ describe GitPushService do
service.execute(project, user, @oldrev, @blankrev, @ref)
end
- it { should be_true }
+ it { is_expected.to be_truthy }
end
end
@@ -49,41 +49,43 @@ describe GitPushService do
subject { @push_data }
- it { should include(before: @oldrev) }
- it { should include(after: @newrev) }
- it { should include(ref: @ref) }
- it { should include(user_id: user.id) }
- it { should include(user_name: user.name) }
- it { should include(project_id: project.id) }
+ it { is_expected.to include(before: @oldrev) }
+ it { is_expected.to include(after: @newrev) }
+ it { is_expected.to include(ref: @ref) }
+ it { is_expected.to include(user_id: user.id) }
+ it { is_expected.to include(user_name: user.name) }
+ it { is_expected.to include(project_id: project.id) }
context "with repository data" do
subject { @push_data[:repository] }
- it { should include(name: project.name) }
- it { should include(url: project.url_to_repo) }
- it { should include(description: project.description) }
- it { should include(homepage: project.web_url) }
+ it { is_expected.to include(name: project.name) }
+ it { is_expected.to include(url: project.url_to_repo) }
+ it { is_expected.to include(description: project.description) }
+ it { is_expected.to include(homepage: project.web_url) }
end
context "with commits" do
subject { @push_data[:commits] }
- it { should be_an(Array) }
- it { should have(1).element }
+ it { is_expected.to be_an(Array) }
+ it 'has 1 element' do
+ expect(subject.size).to eq(1)
+ end
context "the commit" do
subject { @push_data[:commits].first }
- it { should include(id: @commit.id) }
- it { should include(message: @commit.safe_message) }
- it { should include(timestamp: @commit.date.xmlschema) }
- it { should include(url: "#{Gitlab.config.gitlab.url}/#{project.to_param}/commit/#{@commit.id}") }
+ it { is_expected.to include(id: @commit.id) }
+ it { is_expected.to include(message: @commit.safe_message) }
+ it { is_expected.to include(timestamp: @commit.date.xmlschema) }
+ it { is_expected.to include(url: "#{Gitlab.config.gitlab.url}/#{project.to_param}/commit/#{@commit.id}") }
context "with a author" do
subject { @push_data[:commits].first[:author] }
- it { should include(name: @commit.author_name) }
- it { should include(email: @commit.author_email) }
+ it { is_expected.to include(name: @commit.author_name) }
+ it { is_expected.to include(email: @commit.author_email) }
end
end
end
@@ -95,46 +97,46 @@ describe GitPushService do
@event = Event.last
end
- it { @event.should_not be_nil }
- it { @event.project.should == project }
- it { @event.action.should == Event::PUSHED }
- it { @event.data.should == service.push_data }
+ it { expect(@event).not_to be_nil }
+ it { expect(@event.project).to eq(project) }
+ it { expect(@event.action).to eq(Event::PUSHED) }
+ it { expect(@event.data).to eq(service.push_data) }
end
describe "Web Hooks" do
context "execute web hooks" do
it "when pushing a branch for the first time" do
- project.should_receive(:execute_hooks)
- project.default_branch.should == "master"
- project.protected_branches.should_receive(:create).with({ name: "master", developers_can_push: false })
+ expect(project).to receive(:execute_hooks)
+ expect(project.default_branch).to eq("master")
+ expect(project.protected_branches).to receive(:create).with({ name: "master", developers_can_push: false })
service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master')
end
it "when pushing a branch for the first time with default branch protection disabled" do
ApplicationSetting.any_instance.stub(default_branch_protection: 0)
- project.should_receive(:execute_hooks)
- project.default_branch.should == "master"
- project.protected_branches.should_not_receive(:create)
+ expect(project).to receive(:execute_hooks)
+ expect(project.default_branch).to eq("master")
+ expect(project.protected_branches).not_to receive(:create)
service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master')
end
it "when pushing a branch for the first time with default branch protection set to 'developers can push'" do
ApplicationSetting.any_instance.stub(default_branch_protection: 1)
- project.should_receive(:execute_hooks)
- project.default_branch.should == "master"
- project.protected_branches.should_receive(:create).with({ name: "master", developers_can_push: true })
+ expect(project).to receive(:execute_hooks)
+ expect(project.default_branch).to eq("master")
+ expect(project.protected_branches).to receive(:create).with({ name: "master", developers_can_push: true })
service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master')
end
it "when pushing new commits to existing branch" do
- project.should_receive(:execute_hooks)
+ expect(project).to receive(:execute_hooks)
service.execute(project, user, 'oldrev', 'newrev', 'refs/heads/master')
end
it "when pushing tags" do
- project.should_not_receive(:execute_hooks)
+ expect(project).not_to receive(:execute_hooks)
service.execute(project, user, 'newrev', 'newrev', 'refs/tags/v1.0.0')
end
end
@@ -156,7 +158,7 @@ describe GitPushService do
end
it "creates a note if a pushed commit mentions an issue" do
- Note.should_receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
+ expect(Note).to receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
service.execute(project, user, @oldrev, @newrev, @ref)
end
@@ -164,32 +166,32 @@ describe GitPushService do
it "only creates a cross-reference note if one doesn't already exist" do
Note.create_cross_reference_note(issue, commit, user, project)
- Note.should_not_receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
+ expect(Note).not_to receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
service.execute(project, user, @oldrev, @newrev, @ref)
end
it "defaults to the pushing user if the commit's author is not known" do
commit.stub(author_name: 'unknown name', author_email: 'unknown@email.com')
- Note.should_receive(:create_cross_reference_note).with(issue, commit, user, project)
+ expect(Note).to receive(:create_cross_reference_note).with(issue, commit, user, project)
service.execute(project, user, @oldrev, @newrev, @ref)
end
it "finds references in the first push to a non-default branch" do
- project.repository.stub(:commits_between).with(@blankrev, @newrev).and_return([])
- project.repository.stub(:commits_between).with("master", @newrev).and_return([commit])
+ allow(project.repository).to receive(:commits_between).with(@blankrev, @newrev).and_return([])
+ allow(project.repository).to receive(:commits_between).with("master", @newrev).and_return([commit])
- Note.should_receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
+ expect(Note).to receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
service.execute(project, user, @blankrev, @newrev, 'refs/heads/other')
end
it "finds references in the first push to a default branch" do
- project.repository.stub(:commits_between).with(@blankrev, @newrev).and_return([])
- project.repository.stub(:commits).with(@newrev).and_return([commit])
+ allow(project.repository).to receive(:commits_between).with(@blankrev, @newrev).and_return([])
+ allow(project.repository).to receive(:commits).with(@newrev).and_return([commit])
- Note.should_receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
+ expect(Note).to receive(:create_cross_reference_note).with(issue, commit, commit_author, project)
service.execute(project, user, @blankrev, @newrev, 'refs/heads/master')
end
@@ -215,7 +217,7 @@ describe GitPushService do
it "closes issues with commit messages" do
service.execute(project, user, @oldrev, @newrev, @ref)
- Issue.find(issue.id).should be_closed
+ expect(Issue.find(issue.id)).to be_closed
end
it "doesn't create cross-reference notes for a closing reference" do
@@ -232,7 +234,7 @@ describe GitPushService do
service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf')
}.not_to change { Note.where(project_id: project.id, system: true).count }
- Issue.find(issue.id).should be_opened
+ expect(Issue.find(issue.id)).to be_opened
end
end
end
diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb
index e65a8204c54..fcf462edbfc 100644
--- a/spec/services/git_tag_push_service_spec.rb
+++ b/spec/services/git_tag_push_service_spec.rb
@@ -19,27 +19,27 @@ describe GitTagPushService do
subject { @push_data }
- it { should include(ref: @ref) }
- it { should include(before: @oldrev) }
- it { should include(after: @newrev) }
- it { should include(user_id: user.id) }
- it { should include(user_name: user.name) }
- it { should include(project_id: project.id) }
+ it { is_expected.to include(ref: @ref) }
+ it { is_expected.to include(before: @oldrev) }
+ it { is_expected.to include(after: @newrev) }
+ it { is_expected.to include(user_id: user.id) }
+ it { is_expected.to include(user_name: user.name) }
+ it { is_expected.to include(project_id: project.id) }
context 'With repository data' do
subject { @push_data[:repository] }
- it { should include(name: project.name) }
- it { should include(url: project.url_to_repo) }
- it { should include(description: project.description) }
- it { should include(homepage: project.web_url) }
+ it { is_expected.to include(name: project.name) }
+ it { is_expected.to include(url: project.url_to_repo) }
+ it { is_expected.to include(description: project.description) }
+ it { is_expected.to include(homepage: project.web_url) }
end
end
describe "Web Hooks" do
context "execute web hooks" do
it "when pushing tags" do
- project.should_receive(:execute_hooks)
+ expect(project).to receive(:execute_hooks)
service.execute(project, user, 'oldrev', 'newrev', 'refs/tags/v1.0.0')
end
end
diff --git a/spec/services/issues/bulk_update_context_spec.rb b/spec/services/issues/bulk_update_context_spec.rb
index f4c9148f1a3..eb867f78c5c 100644
--- a/spec/services/issues/bulk_update_context_spec.rb
+++ b/spec/services/issues/bulk_update_context_spec.rb
@@ -30,11 +30,11 @@ describe Issues::BulkUpdateService do
it {
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
- result[:success].should be_true
- result[:count].should == @issues.count
+ expect(result[:success]).to be_truthy
+ expect(result[:count]).to eq(@issues.count)
- @project.issues.opened.should be_empty
- @project.issues.closed.should_not be_empty
+ expect(@project.issues.opened).to be_empty
+ expect(@project.issues.closed).not_to be_empty
}
end
@@ -55,11 +55,11 @@ describe Issues::BulkUpdateService do
it {
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
- result[:success].should be_true
- result[:count].should == @issues.count
+ expect(result[:success]).to be_truthy
+ expect(result[:count]).to eq(@issues.count)
- @project.issues.closed.should be_empty
- @project.issues.opened.should_not be_empty
+ expect(@project.issues.closed).to be_empty
+ expect(@project.issues.opened).not_to be_empty
}
end
@@ -78,10 +78,10 @@ describe Issues::BulkUpdateService do
it {
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
- result[:success].should be_true
- result[:count].should == 1
+ expect(result[:success]).to be_truthy
+ expect(result[:count]).to eq(1)
- @project.issues.first.assignee.should == @new_assignee
+ expect(@project.issues.first.assignee).to eq(@new_assignee)
}
end
@@ -100,10 +100,10 @@ describe Issues::BulkUpdateService do
it {
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
- result[:success].should be_true
- result[:count].should == 1
+ expect(result[:success]).to be_truthy
+ expect(result[:count]).to eq(1)
- @project.issues.first.milestone.should == @milestone
+ expect(@project.issues.first.milestone).to eq(@milestone)
}
end
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index d4f2cc1339b..d15dff1b52b 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -17,18 +17,18 @@ describe Issues::CloseService do
@issue = Issues::CloseService.new(project, user, {}).execute(issue)
end
- it { @issue.should be_valid }
- it { @issue.should be_closed }
+ it { expect(@issue).to be_valid }
+ it { expect(@issue).to be_closed }
it 'should send email to user2 about assign of new issue' do
email = ActionMailer::Base.deliveries.last
- email.to.first.should == user2.email
- email.subject.should include(issue.title)
+ expect(email.to.first).to eq(user2.email)
+ expect(email.subject).to include(issue.title)
end
it 'should create system note about issue reassign' do
note = @issue.notes.last
- note.note.should include "Status changed to closed"
+ expect(note.note).to include "Status changed to closed"
end
end
end
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb
index 90720be5ded..7f1ebcb3198 100644
--- a/spec/services/issues/create_service_spec.rb
+++ b/spec/services/issues/create_service_spec.rb
@@ -16,8 +16,8 @@ describe Issues::CreateService do
@issue = Issues::CreateService.new(project, user, opts).execute
end
- it { @issue.should be_valid }
- it { @issue.title.should == 'Awesome issue' }
+ it { expect(@issue).to be_valid }
+ it { expect(@issue.title).to eq('Awesome issue') }
end
end
end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 964b3a707e4..22b89bec96d 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -27,27 +27,27 @@ describe Issues::UpdateService do
@issue.reload
end
- it { @issue.should be_valid }
- it { @issue.title.should == 'New title' }
- it { @issue.assignee.should == user2 }
- it { @issue.should be_closed }
- it { @issue.labels.count.should == 1 }
- it { @issue.labels.first.title.should == 'Bug' }
+ it { expect(@issue).to be_valid }
+ it { expect(@issue.title).to eq('New title') }
+ it { expect(@issue.assignee).to eq(user2) }
+ it { expect(@issue).to be_closed }
+ it { expect(@issue.labels.count).to eq(1) }
+ it { expect(@issue.labels.first.title).to eq('Bug') }
it 'should send email to user2 about assign of new issue' do
email = ActionMailer::Base.deliveries.last
- email.to.first.should == user2.email
- email.subject.should include(issue.title)
+ expect(email.to.first).to eq(user2.email)
+ expect(email.subject).to include(issue.title)
end
it 'should create system note about issue reassign' do
note = @issue.notes.last
- note.note.should include "Reassigned to \@#{user2.username}"
+ expect(note.note).to include "Reassigned to \@#{user2.username}"
end
it 'should create system note about issue label edit' do
note = @issue.notes[1]
- note.note.should include "Added ~#{label.id} label"
+ expect(note.note).to include "Added ~#{label.id} label"
end
end
end
diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb
index 5060a67bebf..b3cbfd4b5b8 100644
--- a/spec/services/merge_requests/close_service_spec.rb
+++ b/spec/services/merge_requests/close_service_spec.rb
@@ -16,13 +16,13 @@ describe MergeRequests::CloseService do
let(:service) { MergeRequests::CloseService.new(project, user, {}) }
before do
- service.stub(:execute_hooks)
+ allow(service).to receive(:execute_hooks)
@merge_request = service.execute(merge_request)
end
- it { @merge_request.should be_valid }
- it { @merge_request.should be_closed }
+ it { expect(@merge_request).to be_valid }
+ it { expect(@merge_request).to be_closed }
it 'should execute hooks with close action' do
expect(service).to have_received(:execute_hooks).
@@ -31,13 +31,13 @@ describe MergeRequests::CloseService do
it 'should send email to user2 about assign of new merge_request' do
email = ActionMailer::Base.deliveries.last
- email.to.first.should == user2.email
- email.subject.should include(merge_request.title)
+ expect(email.to.first).to eq(user2.email)
+ expect(email.subject).to include(merge_request.title)
end
it 'should create system note about merge_request reassign' do
note = @merge_request.notes.last
- note.note.should include 'Status changed to closed'
+ expect(note.note).to include 'Status changed to closed'
end
end
end
diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb
index dbd21143690..d9bfdf64308 100644
--- a/spec/services/merge_requests/create_service_spec.rb
+++ b/spec/services/merge_requests/create_service_spec.rb
@@ -18,13 +18,13 @@ describe MergeRequests::CreateService do
before do
project.team << [user, :master]
- service.stub(:execute_hooks)
+ allow(service).to receive(:execute_hooks)
@merge_request = service.execute
end
- it { @merge_request.should be_valid }
- it { @merge_request.title.should == 'Awesome merge_request' }
+ it { expect(@merge_request).to be_valid }
+ it { expect(@merge_request.title).to eq('Awesome merge_request') }
it 'should execute hooks with default action' do
expect(service).to have_received(:execute_hooks).with(@merge_request)
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb
index 5f61fd3187b..0a25fb12f4e 100644
--- a/spec/services/merge_requests/merge_service_spec.rb
+++ b/spec/services/merge_requests/merge_service_spec.rb
@@ -16,13 +16,13 @@ describe MergeRequests::MergeService do
let(:service) { MergeRequests::MergeService.new(project, user, {}) }
before do
- service.stub(:execute_hooks)
+ allow(service).to receive(:execute_hooks)
service.execute(merge_request, 'Awesome message')
end
- it { merge_request.should be_valid }
- it { merge_request.should be_merged }
+ it { expect(merge_request).to be_valid }
+ it { expect(merge_request).to be_merged }
it 'should execute hooks with merge action' do
expect(service).to have_received(:execute_hooks).
@@ -31,13 +31,13 @@ describe MergeRequests::MergeService do
it 'should send email to user2 about merge of new merge_request' do
email = ActionMailer::Base.deliveries.last
- email.to.first.should == user2.email
- email.subject.should include(merge_request.title)
+ expect(email.to.first).to eq(user2.email)
+ expect(email.subject).to include(merge_request.title)
end
it 'should create system note about merge_request merge' do
note = merge_request.notes.last
- note.note.should include 'Status changed to merged'
+ expect(note.note).to include 'Status changed to merged'
end
end
end
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 35c7aac94df..2830da87814 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -35,10 +35,10 @@ describe MergeRequests::RefreshService do
reload_mrs
end
- it { @merge_request.notes.should_not be_empty }
- it { @merge_request.should be_open }
- it { @fork_merge_request.should be_open }
- it { @fork_merge_request.notes.should be_empty }
+ it { expect(@merge_request.notes).not_to be_empty }
+ it { expect(@merge_request).to be_open }
+ it { expect(@fork_merge_request).to be_open }
+ it { expect(@fork_merge_request.notes).to be_empty }
end
context 'push to origin repo target branch' do
@@ -47,10 +47,10 @@ describe MergeRequests::RefreshService do
reload_mrs
end
- it { @merge_request.notes.last.note.should include('changed to merged') }
- it { @merge_request.should be_merged }
- it { @fork_merge_request.should be_merged }
- it { @fork_merge_request.notes.last.note.should include('changed to merged') }
+ it { expect(@merge_request.notes.last.note).to include('changed to merged') }
+ it { expect(@merge_request).to be_merged }
+ it { expect(@fork_merge_request).to be_merged }
+ it { expect(@fork_merge_request.notes.last.note).to include('changed to merged') }
end
context 'push to fork repo source branch' do
@@ -59,10 +59,10 @@ describe MergeRequests::RefreshService do
reload_mrs
end
- it { @merge_request.notes.should be_empty }
- it { @merge_request.should be_open }
- it { @fork_merge_request.notes.last.note.should include('new commit') }
- it { @fork_merge_request.should be_open }
+ it { expect(@merge_request.notes).to be_empty }
+ it { expect(@merge_request).to be_open }
+ it { expect(@fork_merge_request.notes.last.note).to include('new commit') }
+ it { expect(@fork_merge_request).to be_open }
end
context 'push to fork repo target branch' do
@@ -71,10 +71,10 @@ describe MergeRequests::RefreshService do
reload_mrs
end
- it { @merge_request.notes.should be_empty }
- it { @merge_request.should be_open }
- it { @fork_merge_request.notes.should be_empty }
- it { @fork_merge_request.should be_open }
+ it { expect(@merge_request.notes).to be_empty }
+ it { expect(@merge_request).to be_open }
+ it { expect(@fork_merge_request.notes).to be_empty }
+ it { expect(@fork_merge_request).to be_open }
end
context 'push to origin repo target branch after fork project was removed' do
@@ -84,10 +84,10 @@ describe MergeRequests::RefreshService do
reload_mrs
end
- it { @merge_request.notes.last.note.should include('changed to merged') }
- it { @merge_request.should be_merged }
- it { @fork_merge_request.should be_open }
- it { @fork_merge_request.notes.should be_empty }
+ it { expect(@merge_request.notes.last.note).to include('changed to merged') }
+ it { expect(@merge_request).to be_merged }
+ it { expect(@fork_merge_request).to be_open }
+ it { expect(@fork_merge_request.notes).to be_empty }
end
def reload_mrs
diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb
index 2a7066124dc..9401bc3b558 100644
--- a/spec/services/merge_requests/reopen_service_spec.rb
+++ b/spec/services/merge_requests/reopen_service_spec.rb
@@ -16,14 +16,14 @@ describe MergeRequests::ReopenService do
let(:service) { MergeRequests::ReopenService.new(project, user, {}) }
before do
- service.stub(:execute_hooks)
+ allow(service).to receive(:execute_hooks)
merge_request.state = :closed
service.execute(merge_request)
end
- it { merge_request.should be_valid }
- it { merge_request.should be_reopened }
+ it { expect(merge_request).to be_valid }
+ it { expect(merge_request).to be_reopened }
it 'should execute hooks with reopen action' do
expect(service).to have_received(:execute_hooks).
@@ -32,13 +32,13 @@ describe MergeRequests::ReopenService do
it 'should send email to user2 about reopen of merge_request' do
email = ActionMailer::Base.deliveries.last
- email.to.first.should == user2.email
- email.subject.should include(merge_request.title)
+ expect(email.to.first).to eq(user2.email)
+ expect(email.subject).to include(merge_request.title)
end
it 'should create system note about merge_request reopen' do
note = merge_request.notes.last
- note.note.should include 'Status changed to reopened'
+ expect(note.note).to include 'Status changed to reopened'
end
end
end
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index b27acb47711..916b01e1c45 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -27,18 +27,18 @@ describe MergeRequests::UpdateService do
let(:service) { MergeRequests::UpdateService.new(project, user, opts) }
before do
- service.stub(:execute_hooks)
+ allow(service).to receive(:execute_hooks)
@merge_request = service.execute(merge_request)
@merge_request.reload
end
- it { @merge_request.should be_valid }
- it { @merge_request.title.should == 'New title' }
- it { @merge_request.assignee.should == user2 }
- it { @merge_request.should be_closed }
- it { @merge_request.labels.count.should == 1 }
- it { @merge_request.labels.first.title.should == 'Bug' }
+ it { expect(@merge_request).to be_valid }
+ it { expect(@merge_request.title).to eq('New title') }
+ it { expect(@merge_request.assignee).to eq(user2) }
+ it { expect(@merge_request).to be_closed }
+ it { expect(@merge_request.labels.count).to eq(1) }
+ it { expect(@merge_request.labels.first.title).to eq('Bug') }
it 'should execute hooks with update action' do
expect(service).to have_received(:execute_hooks).
@@ -47,18 +47,18 @@ describe MergeRequests::UpdateService do
it 'should send email to user2 about assign of new merge_request' do
email = ActionMailer::Base.deliveries.last
- email.to.first.should == user2.email
- email.subject.should include(merge_request.title)
+ expect(email.to.first).to eq(user2.email)
+ expect(email.subject).to include(merge_request.title)
end
it 'should create system note about merge_request reassign' do
note = @merge_request.notes.last
- note.note.should include "Reassigned to \@#{user2.username}"
+ expect(note.note).to include "Reassigned to \@#{user2.username}"
end
it 'should create system note about merge_request label edit' do
note = @merge_request.notes[1]
- note.note.should include "Added ~#{label.id} label"
+ expect(note.note).to include "Added ~#{label.id} label"
end
end
end
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index f59786efcf9..1a02299bf19 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -18,8 +18,8 @@ describe Notes::CreateService do
@note = Notes::CreateService.new(project, user, opts).execute
end
- it { @note.should be_valid }
- it { @note.note.should == 'Awesome comment' }
+ it { expect(@note).to be_valid }
+ it { expect(@note.note).to eq('Awesome comment') }
end
end
end
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 2ba1e3372b9..2074f8e7f78 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -7,10 +7,10 @@ describe NotificationService do
describe :new_key do
let!(:key) { create(:personal_key) }
- it { notification.new_key(key).should be_true }
+ it { expect(notification.new_key(key)).to be_truthy }
it 'should sent email to key owner' do
- Notify.should_receive(:new_ssh_key_email).with(key.id)
+ expect(Notify).to receive(:new_ssh_key_email).with(key.id)
notification.new_key(key)
end
end
@@ -20,10 +20,10 @@ describe NotificationService do
describe :new_email do
let!(:email) { create(:email) }
- it { notification.new_email(email).should be_true }
+ it { expect(notification.new_email(email)).to be_truthy }
it 'should send email to email owner' do
- Notify.should_receive(:new_email_email).with(email.id)
+ expect(Notify).to receive(:new_email_email).with(email.id)
notification.new_email(email)
end
end
@@ -54,7 +54,7 @@ describe NotificationService do
it 'filters out "mentioned in" notes' do
mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author, issue.project)
- Notify.should_not_receive(:note_issue_email)
+ expect(Notify).not_to receive(:note_issue_email)
notification.new_note(mentioned_note)
end
end
@@ -87,11 +87,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:note_issue_email).with(user_id, note.id)
+ expect(Notify).to receive(:note_issue_email).with(user_id, note.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:note_issue_email).with(user_id, note.id)
+ expect(Notify).not_to receive(:note_issue_email).with(user_id, note.id)
end
end
@@ -125,17 +125,17 @@ describe NotificationService do
it 'filters out "mentioned in" notes' do
mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author, issue.project)
- Notify.should_not_receive(:note_issue_email)
+ expect(Notify).not_to receive(:note_issue_email)
notification.new_note(mentioned_note)
end
end
def should_email(user_id)
- Notify.should_receive(:note_issue_email).with(user_id, note.id)
+ expect(Notify).to receive(:note_issue_email).with(user_id, note.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:note_issue_email).with(user_id, note.id)
+ expect(Notify).not_to receive(:note_issue_email).with(user_id, note.id)
end
end
@@ -176,11 +176,11 @@ describe NotificationService do
end
def should_email(user_id, n)
- Notify.should_receive(:note_commit_email).with(user_id, n.id)
+ expect(Notify).to receive(:note_commit_email).with(user_id, n.id)
end
def should_not_email(user_id, n)
- Notify.should_not_receive(:note_commit_email).with(user_id, n.id)
+ expect(Notify).not_to receive(:note_commit_email).with(user_id, n.id)
end
end
end
@@ -211,11 +211,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:new_issue_email).with(user_id, issue.id)
+ expect(Notify).to receive(:new_issue_email).with(user_id, issue.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:new_issue_email).with(user_id, issue.id)
+ expect(Notify).not_to receive(:new_issue_email).with(user_id, issue.id)
end
end
@@ -231,11 +231,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:reassigned_issue_email).with(user_id, issue.id, nil, @u_disabled.id)
+ expect(Notify).to receive(:reassigned_issue_email).with(user_id, issue.id, nil, @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id, @u_disabled.id)
+ expect(Notify).not_to receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id, @u_disabled.id)
end
end
@@ -252,11 +252,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id)
+ expect(Notify).to receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id)
+ expect(Notify).not_to receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id)
end
end
@@ -273,11 +273,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:issue_status_changed_email).with(user_id, issue.id, 'reopened', @u_disabled.id)
+ expect(Notify).to receive(:issue_status_changed_email).with(user_id, issue.id, 'reopened', @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:issue_status_changed_email).with(user_id, issue.id, 'reopened', @u_disabled.id)
+ expect(Notify).not_to receive(:issue_status_changed_email).with(user_id, issue.id, 'reopened', @u_disabled.id)
end
end
end
@@ -299,11 +299,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:new_merge_request_email).with(user_id, merge_request.id)
+ expect(Notify).to receive(:new_merge_request_email).with(user_id, merge_request.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:new_merge_request_email).with(user_id, merge_request.id)
+ expect(Notify).not_to receive(:new_merge_request_email).with(user_id, merge_request.id)
end
end
@@ -317,11 +317,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:reassigned_merge_request_email).with(user_id, merge_request.id, nil, merge_request.author_id)
+ expect(Notify).to receive(:reassigned_merge_request_email).with(user_id, merge_request.id, nil, merge_request.author_id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id, merge_request.author_id)
+ expect(Notify).not_to receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id, merge_request.author_id)
end
end
@@ -335,11 +335,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
+ expect(Notify).to receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
+ expect(Notify).not_to receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
end
@@ -353,11 +353,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
+ expect(Notify).to receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
+ expect(Notify).not_to receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id)
end
end
@@ -371,11 +371,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:merge_request_status_email).with(user_id, merge_request.id, 'reopened', @u_disabled.id)
+ expect(Notify).to receive(:merge_request_status_email).with(user_id, merge_request.id, 'reopened', @u_disabled.id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:merge_request_status_email).with(user_id, merge_request.id, 'reopened', @u_disabled.id)
+ expect(Notify).not_to receive(:merge_request_status_email).with(user_id, merge_request.id, 'reopened', @u_disabled.id)
end
end
end
@@ -396,11 +396,11 @@ describe NotificationService do
end
def should_email(user_id)
- Notify.should_receive(:project_was_moved_email).with(project.id, user_id)
+ expect(Notify).to receive(:project_was_moved_email).with(project.id, user_id)
end
def should_not_email(user_id)
- Notify.should_not_receive(:project_was_moved_email).with(project.id, user_id)
+ expect(Notify).not_to receive(:project_was_moved_email).with(project.id, user_id)
end
end
end
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index 9c97dad2ff0..8bb48346202 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -16,9 +16,9 @@ describe Projects::CreateService do
@project = create_project(@user, @opts)
end
- it { @project.should be_valid }
- it { @project.owner.should == @user }
- it { @project.namespace.should == @user.namespace }
+ it { expect(@project).to be_valid }
+ it { expect(@project.owner).to eq(@user) }
+ it { expect(@project.namespace).to eq(@user.namespace) }
end
context 'group namespace' do
@@ -30,9 +30,9 @@ describe Projects::CreateService do
@project = create_project(@user, @opts)
end
- it { @project.should be_valid }
- it { @project.owner.should == @group }
- it { @project.namespace.should == @group }
+ it { expect(@project).to be_valid }
+ it { expect(@project.owner).to eq(@group) }
+ it { expect(@project.namespace).to eq(@group) }
end
context 'wiki_enabled creates repository directory' do
@@ -42,7 +42,7 @@ describe Projects::CreateService do
@path = ProjectWiki.new(@project, @user).send(:path_to_repo)
end
- it { File.exists?(@path).should be_true }
+ it { expect(File.exists?(@path)).to be_truthy }
end
context 'wiki_enabled false does not create wiki repository directory' do
@@ -52,7 +52,7 @@ describe Projects::CreateService do
@path = ProjectWiki.new(@project, @user).send(:path_to_repo)
end
- it { File.exists?(@path).should be_false }
+ it { expect(File.exists?(@path)).to be_falsey }
end
end
end
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 5c80345c2b3..e55a2e3f8a0 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -16,18 +16,18 @@ describe Projects::ForkService do
describe "successfully creates project in the user namespace" do
let(:to_project) { fork_project(@from_project, @to_user) }
- it { to_project.owner.should == @to_user }
- it { to_project.namespace.should == @to_user.namespace }
- it { to_project.star_count.should be_zero }
- it { to_project.description.should == @from_project.description }
+ it { expect(to_project.owner).to eq(@to_user) }
+ it { expect(to_project.namespace).to eq(@to_user.namespace) }
+ it { expect(to_project.star_count).to be_zero }
+ it { expect(to_project.description).to eq(@from_project.description) }
end
end
context 'fork project failure' do
it "fails due to transaction failure" do
@to_project = fork_project(@from_project, @to_user, false)
- @to_project.errors.should_not be_empty
- @to_project.errors[:base].should include("Fork transaction failed.")
+ expect(@to_project.errors).not_to be_empty
+ expect(@to_project.errors[:base]).to include("Fork transaction failed.")
end
end
@@ -35,9 +35,9 @@ describe Projects::ForkService do
it "should fail due to validation, not transaction failure" do
@existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user)
- @existing_project.persisted?.should be_true
- @to_project.errors[:base].should include("Invalid fork destination")
- @to_project.errors[:base].should_not include("Fork transaction failed.")
+ expect(@existing_project.persisted?).to be_truthy
+ expect(@to_project.errors[:base]).to include("Invalid fork destination")
+ expect(@to_project.errors[:base]).not_to include("Fork transaction failed.")
end
end
end
@@ -58,19 +58,19 @@ describe Projects::ForkService do
context 'fork project for group' do
it 'group owner successfully forks project into the group' do
to_project = fork_project(@project, @group_owner, true, @opts)
- to_project.owner.should == @group
- to_project.namespace.should == @group
- to_project.name.should == @project.name
- to_project.path.should == @project.path
- to_project.description.should == @project.description
- to_project.star_count.should be_zero
+ expect(to_project.owner).to eq(@group)
+ expect(to_project.namespace).to eq(@group)
+ expect(to_project.name).to eq(@project.name)
+ expect(to_project.path).to eq(@project.path)
+ expect(to_project.description).to eq(@project.description)
+ expect(to_project.star_count).to be_zero
end
end
context 'fork project for group when user not owner' do
it 'group developer should fail to fork project into the group' do
to_project = fork_project(@project, @developer, true, @opts)
- to_project.errors[:namespace].should == ['insufficient access rights']
+ expect(to_project.errors[:namespace]).to eq(['insufficient access rights'])
end
end
@@ -79,10 +79,10 @@ describe Projects::ForkService do
existing_project = create(:project, name: @project.name,
namespace: @group)
to_project = fork_project(@project, @group_owner, true, @opts)
- existing_project.persisted?.should be_true
- to_project.errors[:base].should == ['Invalid fork destination']
- to_project.errors[:name].should == ['has already been taken']
- to_project.errors[:path].should == ['has already been taken']
+ expect(existing_project.persisted?).to be_truthy
+ expect(to_project.errors[:base]).to eq(['Invalid fork destination'])
+ expect(to_project.errors[:name]).to eq(['has already been taken'])
+ expect(to_project.errors[:path]).to eq(['has already been taken'])
end
end
end
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb
index 79d0526ff89..46fb5f5fae5 100644
--- a/spec/services/projects/transfer_service_spec.rb
+++ b/spec/services/projects/transfer_service_spec.rb
@@ -11,8 +11,8 @@ describe Projects::TransferService do
@result = transfer_project(project, user, namespace_id: group.id)
end
- it { @result.should be_true }
- it { project.namespace.should == group }
+ it { expect(@result).to be_truthy }
+ it { expect(project.namespace).to eq(group) }
end
context 'namespace -> no namespace' do
@@ -20,9 +20,9 @@ describe Projects::TransferService do
@result = transfer_project(project, user, namespace_id: nil)
end
- it { @result.should_not be_nil } # { result.should be_false } passes on nil
- it { @result.should be_false }
- it { project.namespace.should == user.namespace }
+ it { expect(@result).not_to be_nil } # { result.should be_false } passes on nil
+ it { expect(@result).to be_falsey }
+ it { expect(project.namespace).to eq(user.namespace) }
end
context 'namespace -> not allowed namespace' do
@@ -30,9 +30,9 @@ describe Projects::TransferService do
@result = transfer_project(project, user, namespace_id: group.id)
end
- it { @result.should_not be_nil } # { result.should be_false } passes on nil
- it { @result.should be_false }
- it { project.namespace.should == user.namespace }
+ it { expect(@result).not_to be_nil } # { result.should be_false } passes on nil
+ it { expect(@result).to be_falsey }
+ it { expect(project.namespace).to eq(user.namespace) }
end
def transfer_project(project, user, params)
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index 5a10174eb36..10dbc548e86 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -17,8 +17,8 @@ describe Projects::UpdateService do
update_project(@project, @user, @opts)
end
- it { @created_private.should be_true }
- it { @project.private?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.private?).to be_truthy }
end
context 'should be internal when updated to internal' do
@@ -29,8 +29,8 @@ describe Projects::UpdateService do
update_project(@project, @user, @opts)
end
- it { @created_private.should be_true }
- it { @project.internal?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.internal?).to be_truthy }
end
context 'should be public when updated to public' do
@@ -41,14 +41,14 @@ describe Projects::UpdateService do
update_project(@project, @user, @opts)
end
- it { @created_private.should be_true }
- it { @project.public?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.public?).to be_truthy }
end
context 'respect configured visibility restrictions setting' do
before(:each) do
@restrictions = double("restrictions")
- @restrictions.stub(:restricted_visibility_levels) { [ "public" ] }
+ allow(@restrictions).to receive(:restricted_visibility_levels) { [ "public" ] }
Settings.stub_chain(:gitlab).and_return(@restrictions)
end
@@ -60,8 +60,8 @@ describe Projects::UpdateService do
update_project(@project, @user, @opts)
end
- it { @created_private.should be_true }
- it { @project.private?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.private?).to be_truthy }
end
context 'should be internal when updated to internal' do
@@ -72,8 +72,8 @@ describe Projects::UpdateService do
update_project(@project, @user, @opts)
end
- it { @created_private.should be_true }
- it { @project.internal?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.internal?).to be_truthy }
end
context 'should be private when updated to public' do
@@ -84,8 +84,8 @@ describe Projects::UpdateService do
update_project(@project, @user, @opts)
end
- it { @created_private.should be_true }
- it { @project.private?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.private?).to be_truthy }
end
context 'should be public when updated to public by admin' do
@@ -96,8 +96,8 @@ describe Projects::UpdateService do
update_project(@project, @admin, @opts)
end
- it { @created_private.should be_true }
- it { @project.public?.should be_true }
+ it { expect(@created_private).to be_truthy }
+ it { expect(@project.public?).to be_truthy }
end
end
end
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index 3217c571e67..f57bfaea879 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -19,7 +19,7 @@ describe 'Search::GlobalService' do
it 'should return public projects only' do
context = Search::GlobalService.new(nil, search: "searchable")
results = context.execute
- results.objects('projects').should match_array [public_project]
+ expect(results.objects('projects')).to match_array [public_project]
end
end
@@ -27,19 +27,19 @@ describe 'Search::GlobalService' do
it 'should return public, internal and private projects' do
context = Search::GlobalService.new(user, search: "searchable")
results = context.execute
- results.objects('projects').should match_array [public_project, found_project, internal_project]
+ expect(results.objects('projects')).to match_array [public_project, found_project, internal_project]
end
it 'should return only public & internal projects' do
context = Search::GlobalService.new(internal_user, search: "searchable")
results = context.execute
- results.objects('projects').should match_array [internal_project, public_project]
+ expect(results.objects('projects')).to match_array [internal_project, public_project]
end
it 'namespace name should be searchable' do
context = Search::GlobalService.new(user, search: found_project.namespace.path)
results = context.execute
- results.objects('projects').should match_array [found_project]
+ expect(results.objects('projects')).to match_array [found_project]
end
end
end
diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb
index a45e9d0575c..199ac996608 100644
--- a/spec/services/system_hooks_service_spec.rb
+++ b/spec/services/system_hooks_service_spec.rb
@@ -9,35 +9,35 @@ describe SystemHooksService do
let (:group_member) { create(:group_member) }
context 'event data' do
- it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) }
- it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) }
- it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
- it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
- it { event_data(project_member, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
- it { event_data(project_member, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
- it { event_data(key, :create).should include(:username, :key, :id) }
- it { event_data(key, :destroy).should include(:username, :key, :id) }
+ it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :email, :user_id) }
+ it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :email, :user_id) }
+ it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
+ it { expect(event_data(project, :destroy)).to include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
+ it { expect(event_data(project_member, :create)).to include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
+ it { expect(event_data(project_member, :destroy)).to include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :access_level, :project_visibility) }
+ it { expect(event_data(key, :create)).to include(:username, :key, :id) }
+ it { expect(event_data(key, :destroy)).to include(:username, :key, :id) }
it do
- event_data(group, :create).should include(
+ expect(event_data(group, :create)).to include(
:event_name, :name, :created_at, :path, :group_id, :owner_name,
:owner_email
)
end
it do
- event_data(group, :destroy).should include(
+ expect(event_data(group, :destroy)).to include(
:event_name, :name, :created_at, :path, :group_id, :owner_name,
:owner_email
)
end
it do
- event_data(group_member, :create).should include(
+ expect(event_data(group_member, :create)).to include(
:event_name, :created_at, :group_name, :group_path, :group_id, :user_id,
:user_name, :user_email, :group_access
)
end
it do
- event_data(group_member, :destroy).should include(
+ expect(event_data(group_member, :destroy)).to include(
:event_name, :created_at, :group_name, :group_path, :group_id, :user_id,
:user_name, :user_email, :group_access
)
@@ -45,18 +45,18 @@ describe SystemHooksService do
end
context 'event names' do
- it { event_name(user, :create).should eq "user_create" }
- it { event_name(user, :destroy).should eq "user_destroy" }
- it { event_name(project, :create).should eq "project_create" }
- it { event_name(project, :destroy).should eq "project_destroy" }
- it { event_name(project_member, :create).should eq "user_add_to_team" }
- it { event_name(project_member, :destroy).should eq "user_remove_from_team" }
- it { event_name(key, :create).should eq 'key_create' }
- it { event_name(key, :destroy).should eq 'key_destroy' }
- it { event_name(group, :create).should eq 'group_create' }
- it { event_name(group, :destroy).should eq 'group_destroy' }
- it { event_name(group_member, :create).should eq 'user_add_to_group' }
- it { event_name(group_member, :destroy).should eq 'user_remove_from_group' }
+ it { expect(event_name(user, :create)).to eq "user_create" }
+ it { expect(event_name(user, :destroy)).to eq "user_destroy" }
+ it { expect(event_name(project, :create)).to eq "project_create" }
+ it { expect(event_name(project, :destroy)).to eq "project_destroy" }
+ it { expect(event_name(project_member, :create)).to eq "user_add_to_team" }
+ it { expect(event_name(project_member, :destroy)).to eq "user_remove_from_team" }
+ it { expect(event_name(key, :create)).to eq 'key_create' }
+ it { expect(event_name(key, :destroy)).to eq 'key_destroy' }
+ it { expect(event_name(group, :create)).to eq 'group_create' }
+ it { expect(event_name(group, :destroy)).to eq 'group_destroy' }
+ it { expect(event_name(group_member, :create)).to eq 'user_add_to_group' }
+ it { expect(event_name(group_member, :destroy)).to eq 'user_remove_from_group' }
end
def event_data(*args)
diff --git a/spec/services/test_hook_service_spec.rb b/spec/services/test_hook_service_spec.rb
index 76af5bf7b88..d2b505f55a2 100644
--- a/spec/services/test_hook_service_spec.rb
+++ b/spec/services/test_hook_service_spec.rb
@@ -8,7 +8,7 @@ describe TestHookService do
describe :execute do
it "should execute successfully" do
stub_request(:post, hook.url).to_return(status: 200)
- TestHookService.new.execute(hook, user).should be_true
+ expect(TestHookService.new.execute(hook, user)).to be_truthy
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 773de6628b1..eaec2198dc8 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -37,6 +37,8 @@ RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller
config.include TestEnv
+ config.infer_spec_type_from_file_location!
+ config.raise_errors_for_deprecations!
config.before(:suite) do
TestEnv.init
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb
index d2d532d9738..cca7652093a 100644
--- a/spec/support/db_cleaner.rb
+++ b/spec/support/db_cleaner.rb
@@ -36,4 +36,15 @@ RSpec.configure do |config|
config.after(:each) do
DatabaseCleaner.clean
end
+
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
+ # from the file location. You can explicitly opt-in to the feature using this
+ # config option.
+ # To explicitly tag specs without using automatic inference, set the `:type`
+ # metadata manually:
+ #
+ # describe ThingsController, :type => :controller do
+ # # Equivalent to being in spec/controllers
+ # end
+ config.infer_spec_type_from_file_location!
end
diff --git a/spec/support/mentionable_shared_examples.rb b/spec/support/mentionable_shared_examples.rb
index ebd74206699..305592fa5a6 100644
--- a/spec/support/mentionable_shared_examples.rb
+++ b/spec/support/mentionable_shared_examples.rb
@@ -39,7 +39,7 @@ def common_mentionable_setup
# unrecognized commits.
commitmap = { '1234567890a' => mentioned_commit }
extra_commits.each { |c| commitmap[c.short_id] = c }
- mproject.repository.stub(:commit) { |sha| commitmap[sha] }
+ allow(mproject.repository).to receive(:commit) { |sha| commitmap[sha] }
set_mentionable_text.call(ref_string)
end
end
@@ -48,19 +48,19 @@ shared_examples 'a mentionable' do
common_mentionable_setup
it 'generates a descriptive back-reference' do
- subject.gfm_reference.should == backref_text
+ expect(subject.gfm_reference).to eq(backref_text)
end
it "extracts references from its reference property" do
# De-duplicate and omit itself
refs = subject.references(mproject)
- refs.should have(6).items
- refs.should include(mentioned_issue)
- refs.should include(mentioned_mr)
- refs.should include(mentioned_commit)
- refs.should include(ext_issue)
- refs.should include(ext_mr)
- refs.should include(ext_commit)
+ expect(refs.size).to eq(6)
+ expect(refs).to include(mentioned_issue)
+ expect(refs).to include(mentioned_mr)
+ expect(refs).to include(mentioned_commit)
+ expect(refs).to include(ext_issue)
+ expect(refs).to include(ext_mr)
+ expect(refs).to include(ext_commit)
end
it 'creates cross-reference notes' do
@@ -68,7 +68,7 @@ shared_examples 'a mentionable' do
ext_issue, ext_mr, ext_commit]
mentioned_objects.each do |referenced|
- Note.should_receive(:create_cross_reference_note).with(referenced, subject.local_reference, mauthor, mproject)
+ expect(Note).to receive(:create_cross_reference_note).with(referenced, subject.local_reference, mauthor, mproject)
end
subject.create_cross_references!(mproject, mauthor)
@@ -77,8 +77,8 @@ shared_examples 'a mentionable' do
it 'detects existing cross-references' do
Note.create_cross_reference_note(mentioned_issue, subject.local_reference, mauthor, mproject)
- subject.has_mentioned?(mentioned_issue).should be_true
- subject.has_mentioned?(mentioned_mr).should be_false
+ expect(subject.has_mentioned?(mentioned_issue)).to be_truthy
+ expect(subject.has_mentioned?(mentioned_mr)).to be_falsey
end
end
@@ -95,12 +95,12 @@ shared_examples 'an editable mentionable' do
"#{ext_proj.path_with_namespace}##{other_ext_issue.iid}"
[mentioned_issue, mentioned_commit, ext_issue].each do |oldref|
- Note.should_not_receive(:create_cross_reference_note).with(oldref, subject.local_reference,
+ expect(Note).not_to receive(:create_cross_reference_note).with(oldref, subject.local_reference,
mauthor, mproject)
end
[other_issue, other_ext_issue].each do |newref|
- Note.should_receive(:create_cross_reference_note).with(
+ expect(Note).to receive(:create_cross_reference_note).with(
newref,
subject.local_reference,
mauthor,
diff --git a/spec/support/taskable_shared_examples.rb b/spec/support/taskable_shared_examples.rb
index 42252675683..490f453d468 100644
--- a/spec/support/taskable_shared_examples.rb
+++ b/spec/support/taskable_shared_examples.rb
@@ -34,9 +34,9 @@ EOT
end
it 'knows if it has tasks' do
- expect(subject.tasks?).to be_true
+ expect(subject.tasks?).to be_truthy
subject.description = 'Now I have no tasks'
- expect(subject.tasks?).to be_false
+ expect(subject.tasks?).to be_falsey
end
end
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 24fee7c0379..1c150cbfe25 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -19,8 +19,6 @@ module TestEnv
# See gitlab.yml.example test section for paths
#
def init(opts = {})
- RSpec::Mocks::setup(self)
-
# Disable mailer for spinach tests
disable_mailer if opts[:mailer] == false
@@ -49,7 +47,7 @@ module TestEnv
end
def enable_mailer
- NotificationService.any_instance.unstub(:mailer)
+ allow_any_instance_of(NotificationService).to receive(:mailer).and_call_original
end
def setup_gitlab_shell
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index 71a45eb2fa6..60942cc95fc 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -13,7 +13,7 @@ describe 'gitlab:app namespace rake task' do
describe 'backup_restore' do
before do
# avoid writing task output to spec progress
- $stdout.stub :write
+ allow($stdout).to receive :write
end
let :run_rake_task do
@@ -24,7 +24,7 @@ describe 'gitlab:app namespace rake task' do
context 'gitlab version' do
before do
Dir.stub glob: []
- Dir.stub :chdir
+ allow(Dir).to receive :chdir
File.stub exists?: true
Kernel.stub system: true
FileUtils.stub cp_r: true
@@ -41,9 +41,9 @@ describe 'gitlab:app namespace rake task' do
it 'should invoke restoration on mach' do
YAML.stub load_file: {gitlab_version: gitlab_version}
- Rake::Task["gitlab:backup:db:restore"].should_receive :invoke
- Rake::Task["gitlab:backup:repo:restore"].should_receive :invoke
- Rake::Task["gitlab:shell:setup"].should_receive :invoke
+ expect(Rake::Task["gitlab:backup:db:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:repo:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:shell:setup"]).to receive :invoke
expect { run_rake_task }.to_not raise_error
end
end
diff --git a/spec/tasks/gitlab/mail_google_schema_whitelisting.rb b/spec/tasks/gitlab/mail_google_schema_whitelisting.rb
index 45aaf0fc90b..22e746870dc 100644
--- a/spec/tasks/gitlab/mail_google_schema_whitelisting.rb
+++ b/spec/tasks/gitlab/mail_google_schema_whitelisting.rb
@@ -12,7 +12,7 @@ describe 'gitlab:mail_google_schema_whitelisting rake task' do
describe 'call' do
before do
# avoid writing task output to spec progress
- $stdout.stub :write
+ allow($stdout).to receive :write
end
let :run_rake_task do
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index 4273fd1019a..8eabc46112b 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe PostReceive do
context "as a resque worker" do
it "reponds to #perform" do
- PostReceive.new.should respond_to(:perform)
+ expect(PostReceive.new).to respond_to(:perform)
end
end
@@ -13,23 +13,23 @@ describe PostReceive do
let(:key_id) { key.shell_id }
it "fetches the correct project" do
- Project.should_receive(:find_with_namespace).with(project.path_with_namespace).and_return(project)
+ expect(Project).to receive(:find_with_namespace).with(project.path_with_namespace).and_return(project)
PostReceive.new.perform(pwd(project), key_id, changes)
end
it "does not run if the author is not in the project" do
- Key.stub(:find_by).with(hash_including(id: anything())) { nil }
+ allow(Key).to receive(:find_by).with(hash_including(id: anything())) { nil }
- project.should_not_receive(:execute_hooks)
+ expect(project).not_to receive(:execute_hooks)
- PostReceive.new.perform(pwd(project), key_id, changes).should be_false
+ expect(PostReceive.new.perform(pwd(project), key_id, changes)).to be_falsey
end
it "asks the project to trigger all hooks" do
Project.stub(find_with_namespace: project)
- project.should_receive(:execute_hooks)
- project.should_receive(:execute_services)
- project.should_receive(:update_merge_requests)
+ expect(project).to receive(:execute_hooks)
+ expect(project).to receive(:execute_services)
+ expect(project).to receive(:update_merge_requests)
PostReceive.new.perform(pwd(project), key_id, changes)
end