Commit e407a481 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'rs-pre-rspec-3' into 'master'

Changes back-ported from rspec3 branch

This is just breaking up the large `road-to-rspec-3` branch a bit. Each of these commits have been cherry-picked and would be good to have in place before the upgrade.

See merge request !792
parents 5a9135ad 94cbf009
...@@ -254,10 +254,10 @@ group :development, :test do ...@@ -254,10 +254,10 @@ group :development, :test do
end end
group :test do group :test do
gem "simplecov", require: false gem 'simplecov', require: false
gem "shoulda-matchers", "~> 2.7.0" gem 'shoulda-matchers', '~> 2.8.0', require: false
gem 'email_spec' gem 'email_spec'
gem "webmock" gem 'webmock', '~> 1.21.0'
gem 'test_after_commit' gem 'test_after_commit'
end end
......
...@@ -36,7 +36,7 @@ GEM ...@@ -36,7 +36,7 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
acts-as-taggable-on (3.5.0) acts-as-taggable-on (3.5.0)
activerecord (>= 3.2, < 5) activerecord (>= 3.2, < 5)
addressable (2.3.5) addressable (2.3.8)
annotate (2.6.0) annotate (2.6.0)
activerecord (>= 2.3.0) activerecord (>= 2.3.0)
rake (>= 0.8.7) rake (>= 0.8.7)
...@@ -119,8 +119,8 @@ GEM ...@@ -119,8 +119,8 @@ GEM
simplecov (>= 0.7) simplecov (>= 0.7)
term-ansicolor term-ansicolor
thor thor
crack (0.4.1) crack (0.4.2)
safe_yaml (~> 0.9.0) safe_yaml (~> 1.0.0)
creole (0.3.8) creole (0.3.8)
d3_rails (3.5.5) d3_rails (3.5.5)
railties (>= 3.1.0) railties (>= 3.1.0)
...@@ -564,7 +564,7 @@ GEM ...@@ -564,7 +564,7 @@ GEM
rubypants (0.2.0) rubypants (0.2.0)
rugged (0.22.2) rugged (0.22.2)
rugments (1.0.0.beta7) rugments (1.0.0.beta7)
safe_yaml (0.9.7) safe_yaml (1.0.4)
sanitize (2.1.0) sanitize (2.1.0)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
sass (3.2.19) sass (3.2.19)
...@@ -586,7 +586,7 @@ GEM ...@@ -586,7 +586,7 @@ GEM
thor (~> 0.14) thor (~> 0.14)
settingslogic (2.0.9) settingslogic (2.0.9)
sexp_processor (4.4.5) sexp_processor (4.4.5)
shoulda-matchers (2.7.0) shoulda-matchers (2.8.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
sidekiq (3.3.0) sidekiq (3.3.0)
celluloid (>= 0.16.0) celluloid (>= 0.16.0)
...@@ -704,8 +704,8 @@ GEM ...@@ -704,8 +704,8 @@ GEM
equalizer (~> 0.0.7) equalizer (~> 0.0.7)
warden (1.2.3) warden (1.2.3)
rack (>= 1.0) rack (>= 1.0)
webmock (1.16.0) webmock (1.21.0)
addressable (>= 2.2.7) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
websocket-driver (0.3.3) websocket-driver (0.3.3)
wikicloth (0.8.1) wikicloth (0.8.1)
...@@ -824,7 +824,7 @@ DEPENDENCIES ...@@ -824,7 +824,7 @@ DEPENDENCIES
seed-fu seed-fu
select2-rails select2-rails
settingslogic settingslogic
shoulda-matchers (~> 2.7.0) shoulda-matchers (~> 2.8.0)
sidekiq (~> 3.3) sidekiq (~> 3.3)
sidetiq (= 0.6.3) sidetiq (= 0.6.3)
simplecov simplecov
...@@ -853,5 +853,5 @@ DEPENDENCIES ...@@ -853,5 +853,5 @@ DEPENDENCIES
unicorn-worker-killer unicorn-worker-killer
version_sorter version_sorter
virtus virtus
webmock webmock (~> 1.21.0)
wikicloth (= 0.8.1) wikicloth (= 0.8.1)
...@@ -172,10 +172,8 @@ class Commit ...@@ -172,10 +172,8 @@ class Commit
@raw.send(m, *args, &block) @raw.send(m, *args, &block)
end end
def respond_to?(method) def respond_to_missing?(method, include_private = false)
return true if @raw.respond_to?(method) @raw.respond_to?(method, include_private) || super
super
end end
# Truncate sha to 8 characters # Truncate sha to 8 characters
......
require 'task_list' require 'task_list'
require 'task_list/filter'
# Contains functionality for objects that can have task lists in their # Contains functionality for objects that can have task lists in their
# descriptions. Task list items can be added with Markdown like "* [x] Fix # descriptions. Task list items can be added with Markdown like "* [x] Fix
......
...@@ -163,10 +163,8 @@ class Repository ...@@ -163,10 +163,8 @@ class Repository
end end
end end
def respond_to?(method) def respond_to_missing?(method, include_private = false)
return true if raw_repository.respond_to?(method) raw_repository.respond_to?(method, include_private) || super
super
end end
def blob_at(sha, path) def blob_at(sha, path)
......
...@@ -69,14 +69,13 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps ...@@ -69,14 +69,13 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end end
step 'I visit big commit page' do step 'I visit big commit page' do
Commit::DIFF_SAFE_FILES = 20 stub_const('Commit::DIFF_SAFE_FILES', 20)
visit namespace_project_commit_path(@project.namespace, @project, sample_big_commit.id) visit namespace_project_commit_path(@project.namespace, @project, sample_big_commit.id)
end end
step 'I see big commit warning' do step 'I see big commit warning' do
page.should have_content sample_big_commit.message page.should have_content sample_big_commit.message
page.should have_content "Too many changes" page.should have_content "Too many changes"
Commit::DIFF_SAFE_FILES = 100
end end
step 'I visit a commit with an image that changed' do step 'I visit a commit with an image that changed' do
......
module Gitlab
module GitoriousImport
GITORIOUS_HOST = "https://gitorious.org"
end
end
module Gitlab module Gitlab
module GitoriousImport module GitoriousImport
GITORIOUS_HOST = "https://gitorious.org"
class Client class Client
attr_reader :repo_list attr_reader :repo_list
......
module Gitlab module Gitlab
module GitoriousImport module GitoriousImport
GITORIOUS_HOST = "https://gitorious.org"
Repository = Struct.new(:full_name) do Repository = Struct.new(:full_name) do
def id def id
Digest::SHA1.hexdigest(full_name) Digest::SHA1.hexdigest(full_name)
......
...@@ -16,7 +16,7 @@ describe Issue, "Issuable" do ...@@ -16,7 +16,7 @@ describe Issue, "Issuable" do
it { is_expected.to validate_presence_of(:iid) } it { is_expected.to validate_presence_of(:iid) }
it { is_expected.to validate_presence_of(:author) } it { is_expected.to validate_presence_of(:author) }
it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:title) }
it { is_expected.to ensure_length_of(:title).is_at_least(0).is_at_most(255) } it { is_expected.to validate_length_of(:title).is_at_least(0).is_at_most(255) }
end end
describe "Scope" do describe "Scope" do
......
...@@ -36,9 +36,7 @@ describe DeployKeysProject do ...@@ -36,9 +36,7 @@ describe DeployKeysProject do
it "doesn't destroy the deploy key" do it "doesn't destroy the deploy key" do
subject.destroy subject.destroy
expect { expect { deploy_key.reload }.not_to raise_error
deploy_key.reload
}.not_to raise_error(ActiveRecord::RecordNotFound)
end end
end end
...@@ -63,9 +61,7 @@ describe DeployKeysProject do ...@@ -63,9 +61,7 @@ describe DeployKeysProject do
it "doesn't destroy the deploy key" do it "doesn't destroy the deploy key" do
subject.destroy subject.destroy
expect { expect { deploy_key.reload }.not_to raise_error
deploy_key.reload
}.not_to raise_error(ActiveRecord::RecordNotFound)
end end
end end
end end
......
...@@ -26,8 +26,8 @@ describe Key do ...@@ -26,8 +26,8 @@ describe Key do
describe "Validation" do describe "Validation" do
it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_presence_of(:key) } it { is_expected.to validate_presence_of(:key) }
it { is_expected.to ensure_length_of(:title).is_within(0..255) } it { is_expected.to validate_length_of(:title).is_within(0..255) }
it { is_expected.to ensure_length_of(:key).is_within(0..5000) } it { is_expected.to validate_length_of(:key).is_within(0..5000) }
end end
describe "Methods" do describe "Methods" do
......
...@@ -69,14 +69,14 @@ describe Project do ...@@ -69,14 +69,14 @@ describe Project do
it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_uniqueness_of(:name).scoped_to(:namespace_id) } 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 { is_expected.to validate_length_of(:name).is_within(0..255) }
it { is_expected.to validate_presence_of(:path) } it { is_expected.to validate_presence_of(:path) }
it { is_expected.to validate_uniqueness_of(:path).scoped_to(:namespace_id) } 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 validate_length_of(:path).is_within(0..255) }
it { is_expected.to ensure_length_of(:description).is_within(0..2000) } it { is_expected.to validate_length_of(:description).is_within(0..2000) }
it { is_expected.to validate_presence_of(:creator) } 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_length_of(:issues_tracker_id).is_within(0..255) }
it { is_expected.to validate_presence_of(:namespace) } it { is_expected.to validate_presence_of(:namespace) }
it 'should not allow new projects beyond user limits' do it 'should not allow new projects beyond user limits' do
......
...@@ -38,10 +38,10 @@ describe Snippet do ...@@ -38,10 +38,10 @@ describe Snippet do
it { is_expected.to validate_presence_of(:author) } it { is_expected.to validate_presence_of(:author) }
it { is_expected.to validate_presence_of(:title) } it { is_expected.to validate_presence_of(:title) }
it { is_expected.to ensure_length_of(:title).is_within(0..255) } it { is_expected.to validate_length_of(:title).is_within(0..255) }
it { is_expected.to validate_presence_of(:file_name) } it { is_expected.to validate_presence_of(:file_name) }
it { is_expected.to ensure_length_of(:file_name).is_within(0..255) } it { is_expected.to validate_length_of(:file_name).is_within(0..255) }
it { is_expected.to validate_presence_of(:content) } it { is_expected.to validate_presence_of(:content) }
......
...@@ -96,7 +96,7 @@ describe User do ...@@ -96,7 +96,7 @@ describe User do
it { is_expected.to allow_value(0).for(:projects_limit) } it { is_expected.to allow_value(0).for(:projects_limit) }
it { is_expected.not_to allow_value(-1).for(:projects_limit) } it { is_expected.not_to allow_value(-1).for(:projects_limit) }
it { is_expected.to ensure_length_of(:bio).is_within(0..255) } it { is_expected.to validate_length_of(:bio).is_within(0..255) }
describe 'email' do describe 'email' do
it 'accepts info@example.com' do it 'accepts info@example.com' do
......
if ENV['SIMPLECOV']
require 'simplecov'
end
if ENV['COVERALLS']
require 'coveralls'
Coveralls.wear_merged!
end
ENV["RAILS_ENV"] ||= 'test' ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__) require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails' require 'rspec/rails'
require 'webmock/rspec' require 'shoulda/matchers'
require 'email_spec' require 'email_spec'
require 'sidekiq/testing/inline' require 'sidekiq/testing/inline'
...@@ -18,8 +9,6 @@ require 'sidekiq/testing/inline' ...@@ -18,8 +9,6 @@ require 'sidekiq/testing/inline'
# in spec/support/ and its subdirectories. # in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
WebMock.disable_net_connect!(allow_localhost: true)
RSpec.configure do |config| RSpec.configure do |config|
config.use_transactional_fixtures = false config.use_transactional_fixtures = false
config.use_instantiated_fixtures = false config.use_instantiated_fixtures = false
......
...@@ -29,6 +29,6 @@ module ApiHelpers ...@@ -29,6 +29,6 @@ module ApiHelpers
end end
def json_response def json_response
JSON.parse(response.body) @_json_response ||= JSON.parse(response.body)
end end
end end
if ENV['SIMPLECOV']
require 'simplecov'
end
if ENV['COVERALLS']
require 'coveralls'
Coveralls.wear_merged!
end
...@@ -70,7 +70,7 @@ end ...@@ -70,7 +70,7 @@ end
# Extend shoulda-matchers # Extend shoulda-matchers
module Shoulda::Matchers::ActiveModel module Shoulda::Matchers::ActiveModel
class EnsureLengthOfMatcher class ValidateLengthOfMatcher
# Shortcut for is_at_least and is_at_most # Shortcut for is_at_least and is_at_most
def is_within(range) def is_within(range)
is_at_least(range.min) && is_at_most(range.max) is_at_least(range.min) && is_at_most(range.max)
......
require 'webmock'
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment