calliope 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/lib/calliope.rb +16 -0
  2. data/lib/calliope/config.rb +4 -0
  3. data/lib/calliope/controllers/blogs_controller.rb +18 -0
  4. data/lib/calliope/controllers/posts_controller.rb +55 -0
  5. data/lib/calliope/models/blog.rb +24 -0
  6. data/lib/calliope/models/post.rb +19 -0
  7. data/lib/calliope/routes.rb +25 -0
  8. data/test/functional/blogs_controller_test.rb +15 -0
  9. data/test/functional/comments_controller_test.rb +45 -0
  10. data/test/functional/posts_controller_test.rb +58 -0
  11. data/test/functional/routes_test.rb +45 -0
  12. data/test/integration/blogs_test.rb +17 -0
  13. data/test/integration/posts_test.rb +36 -0
  14. data/test/rails_app/app/controllers/application_controller.rb +3 -0
  15. data/test/rails_app/app/controllers/blogs_controller.rb +3 -0
  16. data/test/rails_app/app/controllers/comments_controller.rb +21 -0
  17. data/test/rails_app/app/controllers/home_controller.rb +2 -0
  18. data/test/rails_app/app/controllers/posts_controller.rb +3 -0
  19. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  20. data/test/rails_app/app/models/blog.rb +3 -0
  21. data/test/rails_app/app/models/comment.rb +3 -0
  22. data/test/rails_app/app/models/post.rb +5 -0
  23. data/test/rails_app/config/application.rb +42 -0
  24. data/test/rails_app/config/boot.rb +6 -0
  25. data/test/rails_app/config/environment.rb +5 -0
  26. data/test/rails_app/config/environments/development.rb +26 -0
  27. data/test/rails_app/config/environments/production.rb +49 -0
  28. data/test/rails_app/config/environments/test.rb +35 -0
  29. data/test/rails_app/config/initializers/calliope.rb +2 -0
  30. data/test/rails_app/config/initializers/secret_token.rb +7 -0
  31. data/test/rails_app/config/initializers/session_store.rb +8 -0
  32. data/test/rails_app/config/routes.rb +5 -0
  33. data/test/rails_app/db/migrate/20110416154842_create_blogs.rb +16 -0
  34. data/test/rails_app/db/migrate/20110416154847_create_posts.rb +17 -0
  35. data/test/rails_app/db/migrate/20110417162758_create_comments.rb +21 -0
  36. data/test/rails_app/db/schema.rb +52 -0
  37. data/test/rails_app/db/seeds.rb +7 -0
  38. data/test/test_helper.rb +15 -0
  39. metadata +149 -0
@@ -0,0 +1,16 @@
1
+ require "calliope/config"
2
+ require "calliope/routes"
3
+
4
+ module Calliope
5
+ autoload :BlogsController, "calliope/controllers/blogs_controller"
6
+ autoload :PostsController, "calliope/controllers/posts_controller"
7
+
8
+ module Models
9
+ autoload :Blog, "calliope/models/blog"
10
+ autoload :Post, "calliope/models/post"
11
+ end
12
+
13
+ def self.config
14
+ yield Calliope::Config
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ module Calliope
2
+ module Config
3
+ end
4
+ end
@@ -0,0 +1,18 @@
1
+ module Calliope
2
+ class BlogsController < ApplicationController
3
+ def edit
4
+ @blog = blog
5
+ respond_with(@blog)
6
+ end
7
+
8
+ def update
9
+ @blog = blog
10
+ @blog.update_attributes(params[:blog])
11
+ respond_with(@blog, :location => root_blog_url(params[:name]))
12
+ end
13
+
14
+ def blog
15
+ @blog ||= Blog.find_by_name(params[:name])
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ module Calliope
2
+ class PostsController < ApplicationController
3
+ helper_method :current_blog
4
+
5
+ def index
6
+ @posts = current_blog.posts.latest
7
+ respond_with(@posts)
8
+ end
9
+
10
+ def show
11
+ @post = current_blog.posts.find(params[:id])
12
+ respond_with(@post)
13
+ end
14
+
15
+ def new
16
+ @post = build_post
17
+ respond_with(@post)
18
+ end
19
+
20
+ def edit
21
+ @post = current_blog.posts.find(params[:id])
22
+ end
23
+
24
+ def create
25
+ @post = build_post(params[:post])
26
+ @post.save
27
+ respond_with(@post, :location => blog_post_url(current_blog.name, @post))
28
+ end
29
+
30
+ def update
31
+ @post = current_blog.posts.find(params[:id])
32
+ @post.update_attributes(params[:post])
33
+ respond_with(@post, :location => blog_post_url(current_blog.name, @post))
34
+ end
35
+
36
+ def destroy
37
+ @post = current_blog.posts.find(params[:id])
38
+ @post.destroy
39
+ respond_with(@post, :location => root_blog_url(current_blog.name))
40
+ end
41
+
42
+ def build_post(attributes = nil)
43
+ current_blog.posts.build(attributes)
44
+ end
45
+
46
+ def current_blog
47
+ unless @current_blog
48
+ @current_blog = Blog.find_by_name(params[:name])
49
+ raise ActiveRecord::RecordNotFound.new("Couldn't find blog with name #{params[:name]}") unless @current_blog
50
+ end
51
+
52
+ @current_blog
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,24 @@
1
+ module Calliope
2
+ module Models
3
+ module Blog
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ attr_protected :name
8
+
9
+ has_many :posts, :dependent => :destroy
10
+
11
+ validates_presence_of :name
12
+ end
13
+
14
+ module ClassMethods
15
+ def create_with_name(name)
16
+ blog = new
17
+ blog.name = name
18
+ blog.save
19
+ blog
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ module Calliope
2
+ module Models
3
+ module Post
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ attr_protected :blog_id
8
+
9
+ belongs_to :blog
10
+ has_many :comments, :as => :commentable, :dependent => :delete_all
11
+
12
+ scope :latest, order("created_at DESC")
13
+ end
14
+
15
+ # module ClassMethods
16
+ # end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ module ActionDispatch # :nodoc:
2
+ module Routing # :nodoc:
3
+ class Mapper
4
+ def calliope(*blogs)
5
+ options = blogs.extract_options!
6
+
7
+ _options = { :path => ":name", :only => [:edit, :update] }
8
+ _options[:constraints] = {
9
+ :name => Regexp.new(blogs.map { |b| Regexp.escape(b.to_s) }.join('|'))
10
+ } if blogs.any?
11
+
12
+ resource :blog, _options do
13
+ resources :posts, :except => :index do
14
+ commentable :commentable => 'post' unless options[:comments] == false
15
+ end
16
+
17
+ root :to => "posts#index", :via => :get
18
+ end
19
+
20
+ # match "/:blog/:year/:month/:day/:url_title" => "posts#show",
21
+ # :constraints => options[:constraints], :as => "pretty_blog_post"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ class BlogsControllerTest < ActionController::TestCase
4
+ [:blog, :news].each do |blog|
5
+ test "should get edit for #{blog}" do
6
+ get :edit, :name => blog
7
+ assert_response :ok
8
+ end
9
+
10
+ test "should update for #{blog}" do
11
+ put :update, :name => blog, :blog => { :title => "Da Blog" }
12
+ assert_redirected_to root_blog_url(blog)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ class CommentsControllerTest < ActionController::TestCase
4
+ [:blog, :news].each do |blog|
5
+ test "should get new for #{blog}" do
6
+ get :new, :commentable => "post", :name => blog, :post_id => posts(blog).to_param
7
+ assert_response :ok
8
+ assert_select "form[action=" + blog_post_comments_path(blog, posts(blog)) + "]"
9
+ end
10
+
11
+ test "should create for #{blog}" do
12
+ assert_difference('Comment.count') do
13
+ post :create, :commentable => "post", :name => blog, :post_id => posts(blog).to_param,
14
+ :comment => { :body => "some comment body" }
15
+ assert_redirected_to blog_post_url(blog, posts(blog), :anchor => "C#{assigns(:comment).to_param}")
16
+ end
17
+ end
18
+
19
+ test "should get edit for #{blog}" do
20
+ get :edit, :commentable => "post", :name => blog,
21
+ :post_id => posts(blog).to_param, :id => comments("#{blog}_post_1").to_param
22
+ assert_response :ok
23
+ assert_select "form[action=" + blog_post_comment_path(blog, posts(blog), comments("#{blog}_post_1")) + "]"
24
+ end
25
+
26
+ test "should update for #{blog}" do
27
+ assert_no_difference('Comment.count') do
28
+ put :update, :commentable => "post", :name => blog,
29
+ :post_id => posts(blog).to_param, :id => comments("#{blog}_post_1").to_param,
30
+ :comment => { :body => "some new comment body" }
31
+ assert_redirected_to blog_post_url(blog, posts(blog), :anchor => "C#{comments("#{blog}_post_1").to_param}")
32
+ end
33
+
34
+ assert_equal "some new comment body", comments("#{blog}_post_1").reload.body
35
+ end
36
+
37
+ test "should destroy for #{blog}" do
38
+ assert_difference('Comment.count', -1) do
39
+ delete :destroy, :commentable => "post", :name => blog,
40
+ :post_id => posts(blog).to_param, :id => comments("#{blog}_post_1").to_param
41
+ assert_redirected_to blog_post_url(blog, posts(blog))
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,58 @@
1
+ require 'test_helper'
2
+
3
+ class PostsControllerTest < ActionController::TestCase
4
+ [:blog, :news].each do |blog|
5
+ test "should get index for #{blog}" do
6
+ get :index, :name => blog
7
+ assert_response :ok
8
+ assert_select 'article.post', blogs(blog).posts.count
9
+ assert_select 'article.post h2', blogs(blog).posts.first.title
10
+ end
11
+
12
+ test "should get show for #{blog}" do
13
+ get :show, :name => blog, :id => posts(blog).to_param
14
+ assert_response :ok
15
+ assert_select '#post', 1
16
+ assert_select '#post h1', posts(blog).title
17
+ assert_select '#post form.new_comment', 1
18
+ assert_select "form[action=" + blog_post_comments_path(blogs(blog).name, posts(blog)) + "]", 1
19
+ end
20
+
21
+ test "should get new for #{blog}" do
22
+ get :new, :name => blog
23
+ assert_response :ok
24
+ assert_select "form[action=" + blog_posts_path(blog) + "]", 1
25
+ end
26
+
27
+ test "should get edit for #{blog}" do
28
+ get :edit, :name => blog, :id => posts(blog).to_param
29
+ assert_response :ok
30
+ assert_select "form[action=" + blog_post_path(blog, posts(blog)) + "]", 1
31
+ end
32
+
33
+ test "should create for #{blog}" do
34
+ assert_difference 'Post.count' do
35
+ post :create, :name => blog, :post => { :title => "some title" }
36
+ assert_redirected_to blog_post_url(blog, assigns(:post))
37
+ end
38
+
39
+ assert_equal "some title", assigns(:post).title
40
+ end
41
+
42
+ test "should update for #{blog}" do
43
+ assert_no_difference 'Post.count' do
44
+ put :update, :name => blog, :id => posts(blog).to_param, :post => { :title => "bla bla" }
45
+ assert_redirected_to blog_post_url(blog, posts(blog))
46
+ end
47
+
48
+ assert_equal "bla bla", posts(blog).reload.title
49
+ end
50
+
51
+ test "should destroy for #{blog}" do
52
+ assert_difference 'Post.count', -1 do
53
+ delete :destroy, :name => blog, :id => posts(blog).to_param
54
+ assert_redirected_to root_blog_url(blog)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ class RoutesTest < ActionController::TestCase
4
+ test "blog" do
5
+ assert_routing "/blog/edit", :controller => "blogs", :action => "edit", :name => "blog"
6
+ assert_routing({ :method => :put, :path => "/blog" }, :controller => "blogs", :action => "update", :name => "blog")
7
+ end
8
+
9
+ test "news" do
10
+ assert_routing "/news/edit", :controller => "blogs", :action => "edit", :name => "news"
11
+ assert_routing({ :method => :put, :path => "/news" }, :controller => "blogs", :action => "update", :name => "news")
12
+ end
13
+
14
+ test "unknown blog" do
15
+ assert_raise ActionController::RoutingError do
16
+ assert_routing "/blag/edit", :controller => "blogs", :action => "edit", :name => "blag"
17
+ end
18
+
19
+ assert_raise ActionController::RoutingError do
20
+ assert_routing({ :method => :put, :path => "/blag" }, :controller => "blogs", :action => "update", :name => "blag")
21
+ end
22
+ end
23
+
24
+ test "blog posts" do
25
+ assert_routing "/blog", :controller => "posts", :action => "index", :name => "blog"
26
+ assert_routing "/blog/posts/43", :controller => "posts", :action => "show", :name => "blog", :id => "43"
27
+
28
+ assert_routing "/blog/posts/new", :controller => "posts", :action => "new", :name => "blog"
29
+ assert_routing "/blog/posts/1/edit", :controller => "posts", :action => "edit", :name => "blog", :id => "1"
30
+
31
+ assert_routing({ :method => :post, :path => "/blog/posts" },
32
+ :controller => "posts", :action => "create", :name => "blog")
33
+
34
+ assert_routing({ :method => :put, :path => "/blog/posts/2" },
35
+ :controller => "posts", :action => "update", :name => "blog", :id => "2")
36
+
37
+ assert_routing({ :method => :delete, :path => "/blog/posts/3" },
38
+ :controller => "posts", :action => "destroy", :name => "blog", :id => "3")
39
+ end
40
+
41
+ test "comments" do
42
+ assert_routing "/blog/posts/1/comments/new",
43
+ :controller => "comments", :action => "new", :name => "blog", :post_id => "1", :commentable => "post"
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ class BlogsTest < ActionDispatch::IntegrationTest
4
+ [:blog, :news].each do |blog|
5
+ test "should update #{blog}" do
6
+ visit edit_blog_path(blog)
7
+
8
+ fill_in 'blog_title', :with => "some new title"
9
+ fill_in 'blog_about', :with => "some new about"
10
+ click_button 'blog_submit'
11
+
12
+ assert_equal root_blog_path(blog), current_path
13
+ assert_equal "some new title", blogs(blog).title
14
+ assert_equal "some new about", blogs(blog).about
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+
3
+ class PostsTest < ActionDispatch::IntegrationTest
4
+ [:blog, :news].each do |blog|
5
+ test "should create #{blog} post" do
6
+ visit new_blog_post_path(blog)
7
+
8
+ fill_in 'post_title', :with => "some title"
9
+ fill_in 'post_body', :with => "some body"
10
+
11
+ assert_difference('Post.count') do
12
+ click_button 'post_submit'
13
+ assert_equal blog_post_path(blog, Post.last), current_path
14
+ end
15
+
16
+ assert_equal "some title", Post.last.title
17
+ assert_equal "some body", Post.last.body
18
+ end
19
+
20
+ test "should edit #{blog} post" do
21
+ visit edit_blog_post_path(blog, posts(blog))
22
+
23
+ fill_in 'post_title', :with => "some new title"
24
+ fill_in 'post_body', :with => "some new body"
25
+
26
+ assert_no_difference('Post.count') do
27
+ click_button 'post_submit'
28
+ assert_equal blog_post_path(blog, posts(blog)), current_path
29
+ end
30
+
31
+ posts(blog).reload
32
+ assert_equal "some new title", posts(blog).title
33
+ assert_equal "some new body", posts(blog).body
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,3 @@
1
+ class BlogsController < Calliope::BlogsController
2
+ respond_to :html
3
+ end
@@ -0,0 +1,21 @@
1
+ class CommentsController < Commentable::Controller
2
+ respond_to :html
3
+
4
+ def comment_url
5
+ case @commentable
6
+ when Post
7
+ blog_post_url(params[:name], @commentable, :anchor => "C#{@comment.to_param}")
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ def commentable_url
14
+ case @commentable
15
+ when Post
16
+ blog_post_url(params[:name], @commentable)
17
+ else
18
+ super
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ class HomeController < ApplicationController
2
+ end
@@ -0,0 +1,3 @@
1
+ class PostsController < Calliope::PostsController
2
+ respond_to :html
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class Blog < ActiveRecord::Base
2
+ include Calliope::Models::Blog
3
+ end
@@ -0,0 +1,3 @@
1
+ class Comment < ActiveRecord::Base
2
+ include Commentable::Model
3
+ end
@@ -0,0 +1,5 @@
1
+ class Post < ActiveRecord::Base
2
+ include Calliope::Models::Post
3
+
4
+ has_many :comments, :as => :commentable, :order => 'created_at ASC'
5
+ end
@@ -0,0 +1,42 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module RailsApp
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Custom directories with classes and modules you want to be autoloadable.
16
+ # config.autoload_paths += %W(#{config.root}/extras)
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named.
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running.
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # JavaScript files you want as :defaults (application.js is always included).
34
+ config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+ end
42
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,26 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+
20
+ # Print deprecation notices to the Rails logger
21
+ config.active_support.deprecation = :log
22
+
23
+ # Only use best-standards-support built into browsers
24
+ config.action_dispatch.best_standards_support = :builtin
25
+ end
26
+
@@ -0,0 +1,49 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+
47
+ # Send deprecation notices to registered listeners
48
+ config.active_support.deprecation = :notify
49
+ end
@@ -0,0 +1,35 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,2 @@
1
+ Calliope.config do |config|
2
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ RailsApp::Application.config.secret_token = 'd02d44431970edceef6bc7746a41b876e1e828e48c0fa76fb94f2e8d068bdc6ae4f0ee129adeb69e8649b4840ba8e7d83894f9be0567eb0151da9b2478dc393d'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ RailsApp::Application.config.session_store :cookie_store, :key => '_rails_app_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # RailsApp::Application.config.session_store :active_record_store
@@ -0,0 +1,5 @@
1
+ RailsApp::Application.routes.draw do
2
+ calliope :blog, :news
3
+
4
+ root :to => "home#index"
5
+ end
@@ -0,0 +1,16 @@
1
+ class CreateBlogs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :blogs do |t|
4
+ t.string :name, :null => false
5
+ t.string :title
6
+ t.text :about
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :blogs, :name, :unique => true
11
+ end
12
+
13
+ def self.down
14
+ drop_table :blogs
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :posts do |t|
4
+ t.references :blog, :null => false
5
+ t.string :title
6
+ t.text :body
7
+ t.integer :comments_count
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :posts, :blog_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :posts
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ class CreateComments < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :comments do |t|
4
+ t.references :commentable, :polymorphic => true
5
+ t.text :body
6
+ t.string :user_name
7
+ t.string :user_email
8
+ t.string :user_url
9
+ t.string :user_ip, :limit => 15
10
+ t.boolean :spam, :default => false
11
+ t.boolean :troll, :default => false
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :comments, [:commentable_type, :commentable_id]
16
+ end
17
+
18
+ def self.down
19
+ drop_table :comments
20
+ end
21
+ end
@@ -0,0 +1,52 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20110417162758) do
14
+
15
+ create_table "blogs", :force => true do |t|
16
+ t.string "name", :null => false
17
+ t.string "title"
18
+ t.text "about"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ end
22
+
23
+ add_index "blogs", ["name"], :name => "index_blogs_on_name", :unique => true
24
+
25
+ create_table "comments", :force => true do |t|
26
+ t.integer "commentable_id"
27
+ t.string "commentable_type"
28
+ t.text "body"
29
+ t.string "user_name"
30
+ t.string "user_email"
31
+ t.string "user_url"
32
+ t.string "user_ip", :limit => 15
33
+ t.boolean "spam", :default => false
34
+ t.boolean "troll", :default => false
35
+ t.datetime "created_at"
36
+ t.datetime "updated_at"
37
+ end
38
+
39
+ add_index "comments", ["commentable_type", "commentable_id"], :name => "index_comments_on_commentable_type_and_commentable_id"
40
+
41
+ create_table "posts", :force => true do |t|
42
+ t.integer "blog_id", :null => false
43
+ t.string "title"
44
+ t.text "body"
45
+ t.integer "comments_count"
46
+ t.datetime "created_at"
47
+ t.datetime "updated_at"
48
+ end
49
+
50
+ add_index "posts", ["blog_id"], :name => "index_posts_on_blog_id"
51
+
52
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,15 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require File.expand_path('../rails_app/config/environment', __FILE__)
4
+ require 'rails/test_help'
5
+ require 'capybara/rails'
6
+
7
+ class ActiveSupport::TestCase
8
+ self.fixture_path = File.expand_path('../fixtures', __FILE__)
9
+ fixtures :all
10
+ end
11
+
12
+ class ActionDispatch::IntegrationTest
13
+ self.fixture_path = File.expand_path('../fixtures', __FILE__)
14
+ include Capybara
15
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: calliope
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Julien Portalier
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-17 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rails
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 7
34
+ version: 3.0.7
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Blog engine for Ruby on Rails.
38
+ email: ysbaddaden@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/calliope.rb
47
+ - lib/calliope/config.rb
48
+ - lib/calliope/controllers/blogs_controller.rb
49
+ - lib/calliope/controllers/posts_controller.rb
50
+ - lib/calliope/models/blog.rb
51
+ - lib/calliope/models/post.rb
52
+ - lib/calliope/routes.rb
53
+ - test/functional/blogs_controller_test.rb
54
+ - test/functional/comments_controller_test.rb
55
+ - test/functional/posts_controller_test.rb
56
+ - test/functional/routes_test.rb
57
+ - test/integration/blogs_test.rb
58
+ - test/integration/posts_test.rb
59
+ - test/rails_app/app/controllers/application_controller.rb
60
+ - test/rails_app/app/controllers/blogs_controller.rb
61
+ - test/rails_app/app/controllers/comments_controller.rb
62
+ - test/rails_app/app/controllers/home_controller.rb
63
+ - test/rails_app/app/controllers/posts_controller.rb
64
+ - test/rails_app/app/helpers/application_helper.rb
65
+ - test/rails_app/app/models/blog.rb
66
+ - test/rails_app/app/models/comment.rb
67
+ - test/rails_app/app/models/post.rb
68
+ - test/rails_app/config/application.rb
69
+ - test/rails_app/config/boot.rb
70
+ - test/rails_app/config/environment.rb
71
+ - test/rails_app/config/environments/development.rb
72
+ - test/rails_app/config/environments/production.rb
73
+ - test/rails_app/config/environments/test.rb
74
+ - test/rails_app/config/initializers/calliope.rb
75
+ - test/rails_app/config/initializers/secret_token.rb
76
+ - test/rails_app/config/initializers/session_store.rb
77
+ - test/rails_app/config/routes.rb
78
+ - test/rails_app/db/migrate/20110416154842_create_blogs.rb
79
+ - test/rails_app/db/migrate/20110416154847_create_posts.rb
80
+ - test/rails_app/db/migrate/20110417162758_create_comments.rb
81
+ - test/rails_app/db/schema.rb
82
+ - test/rails_app/db/seeds.rb
83
+ - test/test_helper.rb
84
+ has_rdoc: true
85
+ homepage: http://github.com/ysbaddaden/calliope
86
+ licenses: []
87
+
88
+ post_install_message:
89
+ rdoc_options: []
90
+
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ requirements: []
112
+
113
+ rubyforge_project:
114
+ rubygems_version: 1.6.2
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Blog engine for Ruby on Rails.
118
+ test_files:
119
+ - test/functional/blogs_controller_test.rb
120
+ - test/functional/comments_controller_test.rb
121
+ - test/functional/posts_controller_test.rb
122
+ - test/functional/routes_test.rb
123
+ - test/integration/blogs_test.rb
124
+ - test/integration/posts_test.rb
125
+ - test/rails_app/app/controllers/application_controller.rb
126
+ - test/rails_app/app/controllers/blogs_controller.rb
127
+ - test/rails_app/app/controllers/comments_controller.rb
128
+ - test/rails_app/app/controllers/home_controller.rb
129
+ - test/rails_app/app/controllers/posts_controller.rb
130
+ - test/rails_app/app/helpers/application_helper.rb
131
+ - test/rails_app/app/models/blog.rb
132
+ - test/rails_app/app/models/comment.rb
133
+ - test/rails_app/app/models/post.rb
134
+ - test/rails_app/config/application.rb
135
+ - test/rails_app/config/boot.rb
136
+ - test/rails_app/config/environment.rb
137
+ - test/rails_app/config/environments/development.rb
138
+ - test/rails_app/config/environments/production.rb
139
+ - test/rails_app/config/environments/test.rb
140
+ - test/rails_app/config/initializers/calliope.rb
141
+ - test/rails_app/config/initializers/secret_token.rb
142
+ - test/rails_app/config/initializers/session_store.rb
143
+ - test/rails_app/config/routes.rb
144
+ - test/rails_app/db/migrate/20110416154842_create_blogs.rb
145
+ - test/rails_app/db/migrate/20110416154847_create_posts.rb
146
+ - test/rails_app/db/migrate/20110417162758_create_comments.rb
147
+ - test/rails_app/db/schema.rb
148
+ - test/rails_app/db/seeds.rb
149
+ - test/test_helper.rb