Skip to content

Commit

Permalink
adding a plugin api
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Jul 10, 2008
1 parent 59f36fd commit fd07367
Show file tree
Hide file tree
Showing 25 changed files with 1,055 additions and 311 deletions.
2 changes: 1 addition & 1 deletion config/environment.rb
Expand Up @@ -38,7 +38,7 @@
# in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
config.plugins = [ :theme_support, :better_nested_set, :safemode, :all ]
config.plugins = [ :engines_config, :theme_support, :better_nested_set, :safemode, :all ]

config.plugin_paths << "#{RAILS_ROOT}/vendor/engines"
config.plugin_paths << "#{RAILS_ROOT}/vendor/spec" if Rails.env == 'test'
Expand Down
259 changes: 259 additions & 0 deletions db/schema.rb
Expand Up @@ -11,4 +11,263 @@

ActiveRecord::Schema.define(:version => 0) do

create_table "activities", :force => true do |t|
t.integer "site_id"
t.integer "section_id"
t.integer "author_id"
t.string "author_type"
t.string "author_name", :limit => 40
t.string "author_email", :limit => 40
t.string "author_homepage"
t.string "actions"
t.integer "object_id"
t.string "object_type", :limit => 15
t.text "object_attributes"
t.datetime "created_at", :null => false
end

create_table "anonymouses", :force => true do |t|
t.string "name", :limit => 40
t.string "email", :limit => 100
t.string "homepage"
t.string "ip"
t.string "agent"
t.string "referer"
t.string "token_key", :limit => 40
t.datetime "token_expiration"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "asset_assignments", :force => true do |t|
t.integer "content_id"
t.integer "asset_id"
t.string "label"
t.datetime "created_at"
t.boolean "active"
end

create_table "assets", :force => true do |t|
t.integer "site_id"
t.integer "parent_id"
t.integer "user_id"
t.string "content_type"
t.string "filename"
t.integer "size"
t.string "thumbnail"
t.integer "width"
t.integer "height"
t.string "title"
t.integer "thumbnails_count", :default => 0
t.datetime "created_at"
end

create_table "cached_page_references", :force => true do |t|
t.integer "cached_page_id"
t.integer "object_id"
t.string "object_type"
t.string "method"
end

create_table "cached_pages", :force => true do |t|
t.integer "site_id"
t.integer "section_id"
t.string "url"
t.datetime "updated_at"
t.datetime "cleared_at"
end

create_table "categories", :force => true do |t|
t.integer "section_id"
t.integer "parent_id"
t.integer "lft", :default => 0, :null => false
t.integer "rgt", :default => 0, :null => false
t.string "title"
t.string "path"
t.string "permalink"
end

create_table "category_assignments", :force => true do |t|
t.integer "content_id"
t.integer "category_id"
end

create_table "comments", :force => true do |t|
t.integer "site_id"
t.integer "section_id"
t.integer "commentable_id"
t.string "commentable_type"
t.integer "author_id"
t.string "author_type"
t.string "author_name", :limit => 40
t.string "author_email", :limit => 40
t.string "author_homepage"
t.text "body"
t.text "body_html"
t.integer "approved", :default => 0, :null => false
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "content_versions", :force => true do |t|
t.integer "content_id"
t.integer "version"
t.integer "site_id"
t.integer "section_id"
t.integer "position"
t.string "title"
t.string "permalink"
t.text "excerpt"
t.text "excerpt_html"
t.text "body"
t.text "body_html"
t.integer "author_id"
t.string "author_type"
t.string "author_name", :limit => 40
t.string "author_email", :limit => 40
t.string "author_homepage"
t.string "filter"
t.integer "comment_age", :default => 0
t.datetime "published_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "versioned_type", :limit => 20
end

create_table "contents", :force => true do |t|
t.integer "site_id"
t.integer "section_id"
t.string "type", :limit => 20
t.integer "position"
t.string "title"
t.string "permalink"
t.text "excerpt"
t.text "excerpt_html"
t.text "body"
t.text "body_html"
t.integer "author_id"
t.string "author_type"
t.string "author_name", :limit => 40
t.string "author_email", :limit => 40
t.string "author_homepage"
t.integer "version"
t.string "filter"
t.integer "comment_age", :default => 0
t.string "cached_tag_list"
t.integer "assets_count", :default => 0
t.datetime "published_at"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "counters", :force => true do |t|
t.integer "owner_id"
t.string "owner_type"
t.string "name", :limit => 25
t.integer "count", :default => 0
end

create_table "memberships", :force => true do |t|
t.integer "site_id"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "roles", :force => true do |t|
t.integer "user_id"
t.integer "context_id"
t.string "context_type"
t.string "type", :limit => 25
end

create_table "sections", :force => true do |t|
t.string "type"
t.integer "site_id"
t.integer "parent_id"
t.integer "lft", :default => 0, :null => false
t.integer "rgt", :default => 0, :null => false
t.string "path"
t.string "permalink"
t.string "title"
t.string "layout"
t.string "template"
t.text "options"
t.integer "contents_count"
t.integer "comment_age"
t.string "content_filter"
t.text "permissions"
end

create_table "sites", :force => true do |t|
t.string "name"
t.string "host"
t.string "title"
t.string "subtitle"
t.string "email"
t.string "timezone"
t.string "theme_names"
t.text "ping_urls"
t.string "akismet_key", :limit => 100
t.string "akismet_url"
t.boolean "approve_comments"
t.integer "comment_age"
t.string "comment_filter"
t.string "search_path"
t.string "tag_path"
t.string "tag_layout"
t.string "permalink_style"
t.text "permissions"
end

create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type"
t.datetime "created_at"
end

add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type"
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"

create_table "tags", :force => true do |t|
t.string "name"
end

create_table "topics", :force => true do |t|
t.integer "site_id"
t.integer "section_id"
t.string "title"
t.integer "sticky", :default => 0
t.boolean "locked", :default => false
t.integer "comments_count", :default => 0
t.integer "hits", :default => 0
t.integer "last_comment_id"
t.integer "last_author_id"
t.string "last_author_type"
t.string "last_author_name"
t.string "permalink"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "last_updated_at"
end

create_table "users", :force => true do |t|
t.string "name", :limit => 40
t.string "email", :limit => 100
t.string "homepage"
t.string "about"
t.string "signature"
t.string "login", :limit => 40
t.string "password_hash", :limit => 40
t.string "password_salt", :limit => 40
t.string "remember_me", :limit => 40
t.string "token_key", :limit => 40
t.datetime "token_expiration"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "verified_at"
t.datetime "deleted_at"
end

end
85 changes: 85 additions & 0 deletions spec/controllers/admin/plugins_controller_spec.rb
@@ -0,0 +1,85 @@
require File.dirname(__FILE__) + "/../../spec_helper"

describe Admin::PluginsController do
include SpecControllerHelper

before :each do
scenario :empty_site

@plugin = Engines.plugins[:plugin_test]
set_resource_paths :plugin, '/admin/sites/1/'

@controller.stub! :require_authentication
@controller.stub!(:has_permission?).and_return true
end

it "should be an Admin::BaseController" do
controller.should be_kind_of(Admin::BaseController)
end

describe "routing" do
with_options :path_prefix => '/admin/sites/1/', :site_id => "1" do |route|
route.it_maps :get, "plugins", :index
route.it_maps :get, "plugins/plugin_test", :show, :id => 'plugin_test'
route.it_maps :get, "plugins/plugin_test/edit", :edit, :id => 'plugin_test'
route.it_maps :put, "plugins/plugin_test", :update, :id => 'plugin_test'
end
end

describe "GET to :index" do
act! { request_to :get, @collection_path }
# it_guards_permissions :show, :plugin
it_assigns :plugins
it_renders_template :index
end

describe "GET to :show" do
act! { request_to :get, @member_path }
# it_guards_permissions :show, :plugin
it_assigns :plugin
it_renders_template :show
end

describe "PUT to :update" do
act! { request_to :put, @member_path, :plugin => {'name' => 'value'} }
it_assigns :plugin
it_redirects_to { @member_path }
it_assigns_flash_cookie :notice => :not_nil

it "updates the plugin's config options" do
@plugin.should_receive(:options=).with 'name' => 'value'
act!
end

it "saves the plugin" do
@plugin.should_receive(:save!)
act!
end
end

# describe "DELETE to :destroy" do
# act! { request_to :delete, @member_path }
# it_assigns :plugin
#
# it "fetches a plugin from section.plugins" do
# @section.plugins.should_receive(:find).and_return @plugin
# act!
# end
#
# it "should try to destroy the plugin" do
# @plugin.should_receive :destroy
# act!
# end
#
# describe "when destroy succeeds" do
# it_redirects_to { @collection_path }
# it_assigns_flash_cookie :notice => :not_nil
# end
#
# describe "when destroy fails" do
# before :each do @plugin.stub!(:destroy).and_return false end
# it_renders_template :edit
# it_assigns_flash_cookie :error => :not_nil
# end
# end
end

0 comments on commit fd07367

Please sign in to comment.