Skip to content
This repository
Browse code

Fix model specs.

  • Loading branch information...
commit 9db901c29e338048cbe67848505f5436496a0baf 1 parent 43c78b1
Sean Cribbs seancribbs authored
10 app/controllers/admin/resource_controller.rb
@@ -2,7 +2,7 @@ class Admin::ResourceController < ApplicationController
2 2 extend Radiant::ResourceResponses
3 3
4 4 helper_method :model, :current_object, :models, :current_objects, :model_symbol, :plural_model_symbol, :model_class, :model_name, :plural_model_name
5   - before_filter :populate_format
  5 + # before_filter :populate_format
6 6 before_filter :load_models, :only => :index
7 7 before_filter :load_model, :only => [:new, :create, :edit, :update, :remove, :destroy]
8 8 after_filter :clear_model_cache, :only => [:create, :update, :destroy]
@@ -173,8 +173,8 @@ def format
173 173 end
174 174
175 175 # Assist with user agents that cause improper content-negotiation
176   - warn "Remove default HTML format, Accept header no longer used. (#{__FILE__}: #{__LINE__})" if Rails.version !~ /^2\.1/
177   - def populate_format
178   - params[:format] ||= 'html' unless request.xhr?
179   - end
  176 + # warn "Remove default HTML format, Accept header no longer used. (#{__FILE__}: #{__LINE__})" if Rails.version !~ /^2\.1/
  177 + # def populate_format
  178 + # params[:format] ||= 'html' unless request.xhr?
  179 + # end
180 180 end
2  app/models/layout.rb
@@ -11,6 +11,6 @@ class Layout < ActiveRecord::Base
11 11 # Validations
12 12 validates_presence_of :name, :message => 'required'
13 13 validates_uniqueness_of :name, :message => 'name already in use'
14   - validates_length_of :name, :maximum => 100, :message => '%d-character limit'
  14 + validates_length_of :name, :maximum => 100, :message => '{{count}}-character limit'
15 15
16 16 end
6 app/models/page.rb
@@ -18,9 +18,9 @@ def initialize(message = 'Database missing root page'); super end
18 18 # Validations
19 19 validates_presence_of :title, :slug, :breadcrumb, :status_id, :message => 'required'
20 20
21   - validates_length_of :title, :maximum => 255, :message => '%d-character limit'
22   - validates_length_of :slug, :maximum => 100, :message => '%d-character limit'
23   - validates_length_of :breadcrumb, :maximum => 160, :message => '%d-character limit'
  21 + validates_length_of :title, :maximum => 255, :message => '{{count}}-character limit'
  22 + validates_length_of :slug, :maximum => 100, :message => '{{count}}-character limit'
  23 + validates_length_of :breadcrumb, :maximum => 160, :message => '{{count}}-character limit'
24 24
25 25 validates_format_of :slug, :with => %r{^([-_.A-Za-z0-9]*|/)$}, :message => 'invalid format'
26 26 validates_uniqueness_of :slug, :scope => :parent_id, :message => 'slug already in use for child of parent'
4 app/models/page_part.rb
@@ -8,8 +8,8 @@ class PagePart < ActiveRecord::Base
8 8
9 9 # Validations
10 10 validates_presence_of :name, :message => 'required'
11   - validates_length_of :name, :maximum => 100, :message => '%d-character limit'
12   - validates_length_of :filter_id, :maximum => 25, :allow_nil => true, :message => '%d-character limit'
  11 + validates_length_of :name, :maximum => 100, :message => '{{count}}-character limit'
  12 + validates_length_of :filter_id, :maximum => 25, :allow_nil => true, :message => '{{count}}-character limit'
13 13 validates_numericality_of :id, :page_id, :allow_nil => true, :only_integer => true, :message => 'must be a number'
14 14
15 15 object_id_attr :filter, TextFilter
4 app/models/snippet.rb
@@ -9,8 +9,8 @@ class Snippet < ActiveRecord::Base
9 9
10 10 # Validations
11 11 validates_presence_of :name, :message => 'required'
12   - validates_length_of :name, :maximum => 100, :message => '%d-character limit'
13   - validates_length_of :filter_id, :maximum => 25, :allow_nil => true, :message => '%d-character limit'
  12 + validates_length_of :name, :maximum => 100, :message => '{{count}}-character limit'
  13 + validates_length_of :filter_id, :maximum => 25, :allow_nil => true, :message => '{{count}}-character limit'
14 14 validates_format_of :name, :with => %r{^\S*$}, :message => 'cannot contain spaces or tabs'
15 15 validates_uniqueness_of :name, :message => 'name already in use'
16 16
2  app/models/standard_tags.rb
@@ -977,7 +977,7 @@ def build_regexp_for(tag, attribute_name)
977 977 end
978 978
979 979 def relative_url_for(url, request)
980   - File.join(request.relative_url_root, url)
  980 + File.join(ActionController::Base.relative_url_root, url)
981 981 end
982 982
983 983 def absolute_path_for(base_path, new_path)
8 app/models/user.rb
@@ -19,10 +19,10 @@ class User < ActiveRecord::Base
19 19
20 20 validates_format_of :email, :message => 'invalid e-mail address', :allow_nil => true, :with => /^$|^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
21 21
22   - validates_length_of :name, :maximum => 100, :allow_nil => true, :message => '%d-character limit'
23   - validates_length_of :login, :within => 3..40, :allow_nil => true, :too_long => '%d-character limit', :too_short => '%d-character minimum'
24   - validates_length_of :password, :within => 5..40, :allow_nil => true, :too_long => '%d-character limit', :too_short => '%d-character minimum', :if => :validate_length_of_password?
25   - validates_length_of :email, :maximum => 255, :allow_nil => true, :message => '%d-character limit'
  22 + validates_length_of :name, :maximum => 100, :allow_nil => true, :message => '{{count}}-character limit'
  23 + validates_length_of :login, :within => 3..40, :allow_nil => true, :too_long => '{{count}}-character limit', :too_short => '{{count}}-character minimum'
  24 + validates_length_of :password, :within => 5..40, :allow_nil => true, :too_long => '{{count}}-character limit', :too_short => '{{count}}-character minimum', :if => :validate_length_of_password?
  25 + validates_length_of :email, :maximum => 255, :allow_nil => true, :message => '{{count}}-character limit'
26 26
27 27 validates_numericality_of :id, :only_integer => true, :allow_nil => true, :message => 'must be a number'
28 28
2  spec/matchers/render_matcher.rb
@@ -83,7 +83,7 @@ def render_content_with_page(tag_content, page)
83 83 page.request = ActionController::TestRequest.new(:sample_param => 'data')
84 84 page.request.request_uri = @request_uri || page.url
85 85 page.request.host = @host || test_host
86   - page.request.relative_url_root = @relative_root || ""
  86 + ActionController::Base.relative_url_root = @relative_root || ""
87 87 page.response = ActionController::TestResponse.new
88 88 if tag_content.nil?
89 89 page.render
6 spec/models/response_cache_spec.rb
@@ -184,7 +184,7 @@ def initialize(body = '', headers = {})
184 184 last_modified = Time.now.httpdate
185 185 result = @cache.cache_response('test', response('content', 'Last-Modified' => last_modified))
186 186 request = ActionController::TestRequest.new
187   - request.env = { 'HTTP_IF_MODIFIED_SINCE' => last_modified }
  187 + request.env['HTTP_IF_MODIFIED_SINCE'] = last_modified
188 188 second_call = @cache.update_response('test', response, request)
189 189 second_call.headers['Status'].should match(/^304/)
190 190 second_call.body.should == ''
@@ -195,7 +195,7 @@ def initialize(body = '', headers = {})
195 195 etag = Digest::SHA1.hexdigest('content')
196 196 result = @cache.cache_response('test', response('content', 'ETag' => etag))
197 197 request = ActionController::TestRequest.new
198   - request.env = { 'HTTP_IF_NONE_MATCH' => etag }
  198 + request.env['HTTP_IF_NONE_MATCH'] = etag
199 199 second_call = @cache.update_response('test', response, request)
200 200 second_call.headers['Status'].should match(/^304/)
201 201 second_call.body.should == ''
@@ -206,7 +206,7 @@ def initialize(body = '', headers = {})
206 206 last_modified = Time.now.httpdate
207 207 result = @cache.cache_response('test', response('content', 'Last-Modified' => last_modified))
208 208 request = ActionController::TestRequest.new
209   - request.env = { 'HTTP_IF_MODIFIED_SINCE' => 5.minutes.ago.httpdate }
  209 + request.env['HTTP_IF_MODIFIED_SINCE'] = 5.minutes.ago.httpdate
210 210 second_call = @cache.update_response('test', response, request)
211 211 second_call.body.should == 'content'
212 212 result.should be_kind_of(TestResponse)
2  spec/spec.opts
... ... @@ -1,4 +1,4 @@
1 1 --colour
2   ---format profile
  2 +--format progress
3 3 --reverse
4 4 --backtrace

0 comments on commit 9db901c

Please sign in to comment.
Something went wrong with that request. Please try again.