From 7ef7208c66c6d224505cc186eccbeb6ddd85ff43 Mon Sep 17 00:00:00 2001 From: Emili Parreno Date: Thu, 5 Sep 2013 12:50:53 +0200 Subject: [PATCH] fix user_controller_spec when testing too long usernames --- spec/controllers/users_controller_spec.rb | 2 +- spec/spec_helper.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 0233062bb82..5d1494dfcae 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -637,7 +637,7 @@ describe UsersController do context 'is too long' do before do - xhr :get, :check_username, username: 'abcdefghijklmnop' + xhr :get, :check_username, username: generate_username(User.username_length.last + 1) end include_examples 'checking an invalid username' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d48bf2643b6..87947e4781b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -146,6 +146,11 @@ def create_post(args={}) PostCreator.create(user, args) end +def generate_username(length=10) + range = [*'a'..'z'] + Array.new(length){range.sample}.join +end + module MessageBus::DiagnosticsHelper def publish(channel, data, opts = nil) id = super(channel, data, opts)