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