Changeset 1622
- Timestamp:
- 01/10/08 08:22:32 (4 months ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (1 diff)
- trunk/spec/controllers/accounts_controller_spec.rb (modified) (2 diffs)
- trunk/spec/controllers/articles_controller_spec.rb (modified) (1 diff)
- trunk/spec/controllers/authors_controller_spec.rb (modified) (2 diffs)
- trunk/spec/controllers/categories_controller_spec.rb (modified) (2 diffs)
- trunk/spec/controllers/comments_controller_spec.rb (modified) (1 diff)
- trunk/spec/controllers/tags_controller_spec.rb (modified) (2 diffs)
- trunk/spec/models/blog_spec.rb (modified) (1 diff)
- trunk/spec/models/cache_support_spec.rb (modified) (2 diffs)
- trunk/spec/models/category_spec.rb (modified) (2 diffs)
- trunk/spec/models/configuration_spec.rb (modified) (1 diff)
- trunk/spec/models/page_spec.rb (modified) (1 diff)
- trunk/spec/models/ping_spec.rb (modified) (3 diffs)
- trunk/spec/models/resource_spec.rb (modified) (1 diff)
- trunk/spec/models/tag_spec.rb (modified) (2 diffs)
- trunk/spec/models/theme_spec.rb (modified) (1 diff)
- trunk/spec/models/trackback_spec.rb (modified) (1 diff)
- trunk/spec/models/trigger_spec.rb (modified) (1 diff)
- trunk/spec/models/user_spec.rb (modified) (2 diffs)
- trunk/spec/spec_helper.rb (modified) (1 diff)
- trunk/test/fixtures/blogs.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r1602 r1622 61 61 end 62 62 63 @@blog_id_for = Hash.new64 65 63 # The Blog object for the blog that matches the current request. This is looked 66 64 # up using Blog.find_blog and cached for the lifetime of the controller instance; 67 65 # generally one request. 68 66 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 76 68 end 77 69 78 70 helper_method :this_blog 79 71 80 81 72 def reset_blog_ids 82 @@blog_id_for = {}83 73 end 84 74 trunk/spec/controllers/accounts_controller_spec.rb
r1611 r1622 8 8 User.stub!(:authenticate).and_return(@user) 9 9 User.stub!(:count).and_return(1) 10 controller.stub!(:this_blot).and_return(Blog.default) 10 11 end 11 12 … … 190 191 .any_number_of_times \ 191 192 .and_return(@user) 192 193 193 194 request.cookies[:is_admin] = 'yes' 194 195 end trunk/spec/controllers/articles_controller_spec.rb
r1608 r1622 11 11 controller_name :articles 12 12 Article.delete_all 13 fixtures(:contents, :feedback, :categories, :blogs, :users, :categorizations,14 :text_filters, :tags, :blacklist_patterns, :resources,15 :sidebars)16 13 17 14 before(:each) do trunk/spec/controllers/authors_controller_spec.rb
r1590 r1622 9 9 .and_return(true) 10 10 11 this_blog = Blog. new11 this_blog = Blog.default 12 12 controller.stub!(:this_blog) \ 13 13 .and_return(this_blog) … … 51 51 controller.stub!(:template_exists?) \ 52 52 .and_return(true) 53 this_blog = Blog. new53 this_blog = Blog.default 54 54 controller.stub!(:this_blog) \ 55 55 .and_return(this_blog) trunk/spec/controllers/categories_controller_spec.rb
r1590 r1622 9 9 .and_return(true) 10 10 11 this_blog = Blog. new11 this_blog = Blog.default 12 12 controller.stub!(:this_blog) \ 13 13 .and_return(this_blog) … … 51 51 controller.stub!(:template_exists?) \ 52 52 .and_return(true) 53 this_blog = Blog. new53 this_blog = Blog.default 54 54 controller.stub!(:this_blog) \ 55 55 .and_return(this_blog) trunk/spec/controllers/comments_controller_spec.rb
r1574 r1622 200 200 @the_mock = mock('blog', :null_object => true) 201 201 @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) 203 203 end 204 204 trunk/spec/controllers/tags_controller_spec.rb
r1590 r1622 9 9 .and_return(true) 10 10 11 this_blog = Blog. new11 this_blog = Blog.default 12 12 controller.stub!(:this_blog) \ 13 13 .and_return(this_blog) … … 51 51 controller.stub!(:template_exists?) \ 52 52 .and_return(true) 53 this_blog = Blog. new53 this_blog = Blog.default 54 54 controller.stub!(:this_blog) \ 55 55 .and_return(this_blog) trunk/spec/models/blog_spec.rb
r1440 r1622 2 2 3 3 describe "Given the first Blog fixture" do 4 fixtures :blogs, :contents, :sidebars5 6 4 before(:each) { @blog = blogs(:default) } 7 5 trunk/spec/models/cache_support_spec.rb
r1440 r1622 2 2 3 3 describe 'Given a published article' do 4 fixtures :blogs, :contents, :feedback, :users, :text_filters5 6 4 before(:each) do 7 5 @article = contents(:article1) … … 35 33 36 34 describe "Given an unpublished article" do 37 fixtures :blogs, :contents, :feedback, :users, :text_filters38 39 35 before(:each) { @article = contents(:article4) } 40 36 trunk/spec/models/category_spec.rb
r1440 r1622 2 2 3 3 describe 'Given the results of Category.find_all_with_article_counters' do 4 fixtures :contents, :categories, :categorizations, :blogs5 6 4 before(:each) { @cats = Category.find_all_with_article_counters } 7 5 … … 18 16 19 17 describe 'Given the fixtures' do 20 fixtures :contents, :categories, :categorizations, :blogs21 22 18 it 'find gets the order right' do 23 19 cats = Category.find(:all) trunk/spec/models/configuration_spec.rb
r1614 r1622 2 2 3 3 describe '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 5 8 6 9 # Must find a better name for this key! trunk/spec/models/page_spec.rb
r1608 r1622 2 2 3 3 describe 'Given the fixture :first_page' do 4 fixtures :contents, :blogs5 6 4 before(:each) do 7 5 @page = contents(:first_page) trunk/spec/models/ping_spec.rb
r1465 r1622 2 2 3 3 describe 'Given a post which references a pingback enabled article' do 4 fixtures :contents, :blogs, :text_filters5 6 4 def pingback_target; 'http://anotherblog.org/xml-rpc'; end 7 5 def referenced_url; 'http://anotherblog.org/a-post'; end … … 76 74 77 75 describe "An article links to another article, which contains a trackback URL" do 78 fixtures :contents, :blogs79 80 81 76 def referenced_url; 'http://anotherblog.org/a-post'; end 82 77 def trackback_url; "http://anotherblog.org/a-post/trackback"; end … … 122 117 123 118 describe 'Given a remote site to notify, eg technorati' do 124 fixtures :contents, :blogs125 126 119 it 'we can ping them correctly' do 127 120 mock = mock('response') trunk/spec/models/resource_spec.rb
r1440 r1622 2 2 3 3 describe Resource, ' with its fixtures loaded' do 4 fixtures(:resources)5 6 4 before(:each) do 7 5 File.stub!(:exist?).and_return(true) trunk/spec/models/tag_spec.rb
r1608 r1622 2 2 3 3 describe 'Given loaded fixtures' do 4 fixtures :tags, :contents, :blogs5 6 4 it 'we can Tag.get by name' do 7 Tag.get('foo').should == tags(:foo _tag)5 Tag.get('foo').should == tags(:foo) 8 6 end 9 7 … … 30 28 it 'articles can be tagged' do 31 29 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) 34 32 35 33 a.reload 36 34 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) 38 36 end 39 37 trunk/spec/models/theme_spec.rb
r1571 r1622 13 13 describe 'Given a the default theme' do 14 14 before(:each) do 15 @theme = Blog. new.current_theme15 @theme = Blog.default.current_theme 16 16 end 17 17 trunk/spec/models/trackback_spec.rb
r1511 r1622 4 4 before(:each) do 5 5 IPSocket.stub!(:getaddress).and_return { raise SocketError.new("getaddrinfo: Name or service not known") } 6 @blog = Blog. new6 @blog = Blog.default 7 7 @blog.sp_global = true 8 8 @blog.default_moderate_comments = false trunk/spec/models/trigger_spec.rb
r1440 r1622 2 2 3 3 describe 'With the contents fixture' do 4 fixtures :contents, :triggers5 6 4 before(:each) do 7 5 @page = mock('fake_page') trunk/spec/models/user_spec.rb
r1440 r1622 2 2 3 3 describe 'With the contents and users fixtures loaded' do 4 fixtures :users, :contents, :blogs5 6 4 before(:each) do 7 5 User.stub!(:salt).and_return('change-me') … … 21 19 22 20 it 'The various article finders work appropriately' do 23 User.find(1).articles.size.should == 821 users(:tobi).articles.size.should == 7 24 22 # User.find(1).articles.find_published.size.should == Article.find(:all, :conditions => {:published => true}).size 25 User.find(1).articles.published.size == 723 users(:tobi).articles.published.size.should == 6 26 24 end 27 25 trunk/spec/spec_helper.rb
r1608 r1622 8 8 config.use_transactional_fixtures = true 9 9 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 } 12 15 13 16 config.before(:each) do trunk/test/fixtures/blogs.yml
r1621 r1622 22 22 default_allow_pings: false 23 23 itunes_author: "" 24 send_outbound_pings: true24 send_outbound_pings: false 25 25 itunes_copyright: "" 26 26 sp_global: true
