Commit 47251b85 authored by Robert Speicher's avatar Robert Speicher

ensure_length_of -> validate_length_of

parent 07215f7f
...@@ -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
......
...@@ -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
......
...@@ -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)
......
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