Changeset 1622

Show
Ignore:
Timestamp:
01/10/08 08:22:32 (4 months ago)
Author:
pdcawley
Message:

More test tweaks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/application.rb

    r1602 r1622  
    6161  end 
    6262 
    63   @@blog_id_for = Hash.new 
    64  
    6563  # The Blog object for the blog that matches the current request.  This is looked 
    6664  # up using Blog.find_blog and cached for the lifetime of the controller instance; 
    6765  # generally one request. 
    6866  def this_blog 
    69     @blog ||= if @@blog_id_for[blog_base_url] 
    70                 Blog.find(@@blog_id_for[blog_base_url]) 
    71               else 
    72                 returning(Blog.find_blog(blog_base_url)) do |blog| 
    73                   @@blog_id_for[blog_base_url] = blog.id 
    74                 end 
    75               end 
     67    @blog ||= Blog.default 
    7668  end 
    7769 
    7870  helper_method :this_blog 
    7971 
    80  
    8172  def reset_blog_ids 
    82     @@blog_id_for = {} 
    8373  end 
    8474 
  • trunk/spec/controllers/accounts_controller_spec.rb

    r1611 r1622  
    88    User.stub!(:authenticate).and_return(@user) 
    99    User.stub!(:count).and_return(1) 
     10    controller.stub!(:this_blot).and_return(Blog.default) 
    1011  end 
    1112 
     
    190191      .any_number_of_times \ 
    191192      .and_return(@user) 
    192      
     193 
    193194    request.cookies[:is_admin] = 'yes' 
    194195  end 
  • trunk/spec/controllers/articles_controller_spec.rb

    r1608 r1622  
    1111  controller_name :articles 
    1212  Article.delete_all 
    13   fixtures(:contents, :feedback, :categories, :blogs, :users, :categorizations, 
    14            :text_filters, :tags, :blacklist_patterns, :resources, 
    15            :sidebars) 
    1613 
    1714  before(:each) do 
  • trunk/spec/controllers/authors_controller_spec.rb

    r1590 r1622  
    99      .and_return(true) 
    1010 
    11     this_blog = Blog.new 
     11    this_blog = Blog.default 
    1212    controller.stub!(:this_blog) \ 
    1313      .and_return(this_blog) 
     
    5151    controller.stub!(:template_exists?) \ 
    5252      .and_return(true) 
    53     this_blog = Blog.new 
     53    this_blog = Blog.default 
    5454    controller.stub!(:this_blog) \ 
    5555      .and_return(this_blog) 
  • trunk/spec/controllers/categories_controller_spec.rb

    r1590 r1622  
    99      .and_return(true) 
    1010 
    11     this_blog = Blog.new 
     11    this_blog = Blog.default 
    1212    controller.stub!(:this_blog) \ 
    1313      .and_return(this_blog) 
     
    5151    controller.stub!(:template_exists?) \ 
    5252      .and_return(true) 
    53     this_blog = Blog.new 
     53    this_blog = Blog.default 
    5454    controller.stub!(:this_blog) \ 
    5555      .and_return(this_blog) 
  • trunk/spec/controllers/comments_controller_spec.rb

    r1574 r1622  
    200200    @the_mock = mock('blog', :null_object => true) 
    201201    @the_mock.stub!(:lang).and_return('en_US') 
    202     Blog.stub!(:find).and_return(@the_mock) 
     202    controller.stub!(:this_blog).and_return(@the_mock) 
    203203  end 
    204204 
  • trunk/spec/controllers/tags_controller_spec.rb

    r1590 r1622  
    99      .and_return(true) 
    1010 
    11     this_blog = Blog.new 
     11    this_blog = Blog.default 
    1212    controller.stub!(:this_blog) \ 
    1313      .and_return(this_blog) 
     
    5151    controller.stub!(:template_exists?) \ 
    5252      .and_return(true) 
    53     this_blog = Blog.new 
     53    this_blog = Blog.default 
    5454    controller.stub!(:this_blog) \ 
    5555      .and_return(this_blog) 
  • trunk/spec/models/blog_spec.rb

    r1440 r1622  
    22 
    33describe "Given the first Blog fixture" do 
    4   fixtures :blogs, :contents, :sidebars 
    5  
    64  before(:each) { @blog = blogs(:default) } 
    75 
  • trunk/spec/models/cache_support_spec.rb

    r1440 r1622  
    22 
    33describe 'Given a published article' do 
    4   fixtures :blogs, :contents, :feedback, :users, :text_filters 
    5  
    64  before(:each) do 
    75    @article = contents(:article1) 
     
    3533 
    3634describe "Given an unpublished article" do 
    37   fixtures :blogs, :contents, :feedback, :users, :text_filters 
    38  
    3935  before(:each) { @article = contents(:article4) } 
    4036 
  • trunk/spec/models/category_spec.rb

    r1440 r1622  
    22 
    33describe 'Given the results of Category.find_all_with_article_counters' do 
    4   fixtures :contents, :categories, :categorizations, :blogs 
    5  
    64  before(:each) { @cats = Category.find_all_with_article_counters } 
    75 
     
    1816 
    1917describe 'Given the fixtures' do 
    20   fixtures :contents, :categories, :categorizations, :blogs 
    21  
    2218  it 'find gets the order right' do 
    2319    cats = Category.find(:all) 
  • trunk/spec/models/configuration_spec.rb

    r1614 r1622  
    22 
    33describe 'Given a new blog' do 
    4   before(:each) { @blog = Blog.new } 
     4  before(:each) do 
     5    Blog.delete_all 
     6    @blog = Blog.new 
     7  end 
    58 
    69  # Must find a better name for this key! 
  • trunk/spec/models/page_spec.rb

    r1608 r1622  
    22 
    33describe 'Given the fixture :first_page' do 
    4   fixtures :contents, :blogs 
    5  
    64  before(:each) do 
    75    @page = contents(:first_page) 
  • trunk/spec/models/ping_spec.rb

    r1465 r1622  
    22 
    33describe 'Given a post which references a pingback enabled article' do 
    4   fixtures :contents, :blogs, :text_filters 
    5  
    64  def pingback_target; 'http://anotherblog.org/xml-rpc'; end 
    75  def referenced_url; 'http://anotherblog.org/a-post'; end 
     
    7674 
    7775describe "An article links to another article, which contains a trackback URL" do 
    78   fixtures :contents, :blogs 
    79  
    80  
    8176  def referenced_url;  'http://anotherblog.org/a-post'; end 
    8277  def trackback_url;  "http://anotherblog.org/a-post/trackback"; end 
     
    122117 
    123118describe 'Given a remote site to notify, eg technorati' do 
    124   fixtures :contents, :blogs 
    125  
    126119  it 'we can ping them correctly' do 
    127120    mock = mock('response') 
  • trunk/spec/models/resource_spec.rb

    r1440 r1622  
    22 
    33describe Resource, ' with its fixtures loaded' do 
    4   fixtures(:resources) 
    5  
    64  before(:each) do 
    75    File.stub!(:exist?).and_return(true) 
  • trunk/spec/models/tag_spec.rb

    r1608 r1622  
    22 
    33describe 'Given loaded fixtures' do 
    4   fixtures :tags, :contents, :blogs 
    5  
    64  it 'we can Tag.get by name' do 
    7     Tag.get('foo').should == tags(:foo_tag
     5    Tag.get('foo').should == tags(:foo
    86  end 
    97 
     
    3028  it 'articles can be tagged' do 
    3129    a = Article.create(:title => 'an article') 
    32     a.tags << tags(:foo_tag
    33     a.tags << tags(:bar_tag
     30    a.tags << tags(:foo
     31    a.tags << tags(:bar
    3432 
    3533    a.reload 
    3634    a.tags.size.should == 2 
    37     a.tags.sort_by(&:id).should == [tags(:foo_tag), tags(:bar_tag)].sort_by(&:id) 
     35    a.tags.sort_by(&:id).should == [tags(:foo), tags(:bar)].sort_by(&:id) 
    3836  end 
    3937 
  • trunk/spec/models/theme_spec.rb

    r1571 r1622  
    1313describe 'Given a the default theme' do 
    1414  before(:each) do 
    15     @theme = Blog.new.current_theme 
     15    @theme = Blog.default.current_theme 
    1616  end 
    1717 
  • trunk/spec/models/trackback_spec.rb

    r1511 r1622  
    44  before(:each) do 
    55    IPSocket.stub!(:getaddress).and_return { raise SocketError.new("getaddrinfo: Name or service not known") } 
    6     @blog = Blog.new 
     6    @blog = Blog.default 
    77    @blog.sp_global = true 
    88    @blog.default_moderate_comments = false 
  • trunk/spec/models/trigger_spec.rb

    r1440 r1622  
    22 
    33describe 'With the contents fixture' do 
    4   fixtures :contents, :triggers 
    5  
    64  before(:each) do 
    75    @page = mock('fake_page') 
  • trunk/spec/models/user_spec.rb

    r1440 r1622  
    22 
    33describe 'With the contents and users fixtures loaded' do 
    4   fixtures :users, :contents, :blogs 
    5  
    64  before(:each) do 
    75    User.stub!(:salt).and_return('change-me') 
     
    2119 
    2220  it 'The various article finders work appropriately' do 
    23     User.find(1).articles.size.should == 8 
     21    users(:tobi).articles.size.should == 7 
    2422#    User.find(1).articles.find_published.size.should == Article.find(:all, :conditions => {:published => true}).size 
    25     User.find(1).articles.published.size == 7 
     23    users(:tobi).articles.published.size.should == 6 
    2624  end 
    2725 
  • trunk/spec/spec_helper.rb

    r1608 r1622  
    88  config.use_transactional_fixtures = true 
    99  config.use_instantiated_fixtures  = false 
    10   config.fixture_path = RAILS_ROOT + '/spec/fixtures' 
    11   config.global_fixtures = [:contents, :tags, :blogs, :profiles] 
     10  config.fixture_path = RAILS_ROOT + '/test/fixtures' 
     11  config.global_fixtures = 
     12    %w{ blacklist_patterns blogs categories categorizations contents 
     13        feedback notifications page_caches profiles redirects resources sidebars 
     14        tags text_filters triggers users } 
    1215 
    1316  config.before(:each) do 
  • trunk/test/fixtures/blogs.yml

    r1621 r1622  
    2222    default_allow_pings: false 
    2323    itunes_author: "" 
    24     send_outbound_pings: tru
     24    send_outbound_pings: fals
    2525    itunes_copyright: "" 
    2626    sp_global: true