-<%= lightbox_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %>
+<%= modal_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %>
<%= _('You need to login to be able to use all the features in this environment.') %>
<% end %>
<% end %>
diff --git a/app/views/shared/usermenu/xmpp_chat.html.erb b/app/views/shared/usermenu/xmpp_chat.html.erb
deleted file mode 100644
index b838bda..0000000
--- a/app/views/shared/usermenu/xmpp_chat.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= link_to(' ' + _('Open chat') +'', '#', :id => 'openchat', :onclick => 'open_chat_window(this)') %>
diff --git a/config/application.rb b/config/application.rb
index 86319a7..3a4347b 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,6 +1,7 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
+require 'active_support/dependencies'
# FIXME this silences the warnings about Rails 2.3-style plugins under
# vendor/plugins, which are deprecated. Hiding those warnings makes it easier
diff --git a/config/database.yml.multitenancy b/config/database.yml.multitenancy
index 04c0228..5422229 100644
--- a/config/database.yml.multitenancy
+++ b/config/database.yml.multitenancy
@@ -1,5 +1,5 @@
# Refer to INSTALL.multitenancy for more information on Multitenancy support
-env1_production:
+env1_production: &DEFAULT
adapter: postgresql
encoding: unicode
database: noosfero
@@ -30,4 +30,4 @@ env3_production:
- env3.net
production:
- env1_production
+ <<: *DEFAULT
diff --git a/config/noosfero.yml.dist b/config/noosfero.yml.dist
index 86aafd2..e4df627 100644
--- a/config/noosfero.yml.dist
+++ b/config/noosfero.yml.dist
@@ -9,6 +9,7 @@ development:
googlemaps_initial_zoom: 4
exception_recipients: [admin@example.com]
max_upload_size: 5MB
+ hours_until_user_activation_check: 72
test:
diff --git a/config/schedule.rb b/config/schedule.rb
index 0811bed..de1e06d 100644
--- a/config/schedule.rb
+++ b/config/schedule.rb
@@ -25,6 +25,6 @@ every 1.day do
runner "SearchTerm.calculate_scores"
end
-every 90.days do
+every 30.days do
runner "ProfileSuggestion.generate_all_profile_suggestions"
end
diff --git a/db/migrate/20120820120000_index_parent_id_from_all_tables.rb b/db/migrate/20120820120000_index_parent_id_from_all_tables.rb
new file mode 100644
index 0000000..4010a48
--- /dev/null
+++ b/db/migrate/20120820120000_index_parent_id_from_all_tables.rb
@@ -0,0 +1,17 @@
+class IndexParentIdFromAllTables < ActiveRecord::Migration
+ def self.up
+ add_index :article_versions, :parent_id
+ add_index :categories, :parent_id
+ add_index :images, :parent_id
+ add_index :tags, :parent_id
+ add_index :thumbnails, :parent_id
+ end
+
+ def self.down
+ remove_index :article_versions, :parent_id
+ remove_index :categories, :parent_id
+ remove_index :images, :parent_id
+ remove_index :tags, :parent_id
+ remove_index :thumbnails, :parent_id
+ end
+end
diff --git a/db/migrate/20120820142056_add_ancestry_to_categories.rb b/db/migrate/20120820142056_add_ancestry_to_categories.rb
new file mode 100644
index 0000000..c0b2dc7
--- /dev/null
+++ b/db/migrate/20120820142056_add_ancestry_to_categories.rb
@@ -0,0 +1,11 @@
+class AddAncestryToCategories < ActiveRecord::Migration
+ def self.up
+ add_column :categories, :ancestry, :text
+
+ Category.build_ancestry
+ end
+
+ def self.down
+ remove_column :categories, :ancestry
+ end
+end
diff --git a/db/migrate/20140519113821_add_last_login_at_to_user.rb b/db/migrate/20140519113821_add_last_login_at_to_user.rb
new file mode 100644
index 0000000..31b82e3
--- /dev/null
+++ b/db/migrate/20140519113821_add_last_login_at_to_user.rb
@@ -0,0 +1,9 @@
+class AddLastLoginAtToUser < ActiveRecord::Migration
+ def self.up
+ add_column :users, :last_login_at, :datetime
+ end
+
+ def self.down
+ remove_column :users, :last_login_at
+ end
+end
diff --git a/db/migrate/20140709212646_add_spam_comments_counter_cache_to_articles.rb b/db/migrate/20140709212646_add_spam_comments_counter_cache_to_articles.rb
index 8448e93..40819a1 100644
--- a/db/migrate/20140709212646_add_spam_comments_counter_cache_to_articles.rb
+++ b/db/migrate/20140709212646_add_spam_comments_counter_cache_to_articles.rb
@@ -3,7 +3,7 @@ class AddSpamCommentsCounterCacheToArticles < ActiveRecord::Migration
add_column :articles, :spam_comments_count, :integer, :default => 0
add_column :article_versions, :spam_comments_count, :integer, :default => 0
- execute("SELECT comments.source_id as source_id, count(comments.id) as comments_count FROM comments LEFT OUTER JOIN articles ON articles.id = source_id WHERE comments.source_type = 'Article' AND comments.spam = 't' GROUP BY comments.source_id;").each do |data|
+ execute("SELECT comments.source_id as source_id, count(comments.id) as comments_count FROM comments LEFT OUTER JOIN articles ON articles.id = source_id WHERE comments.source_type = 'Article' AND comments.spam = true GROUP BY comments.source_id;").each do |data|
execute("UPDATE articles SET spam_comments_count = '#{data['comments_count']}' WHERE id = #{data['source_id']}")
end
end
diff --git a/db/migrate/20150112233715_normalize_users_email.rb b/db/migrate/20150112233715_normalize_users_email.rb
new file mode 100644
index 0000000..374ec7e
--- /dev/null
+++ b/db/migrate/20150112233715_normalize_users_email.rb
@@ -0,0 +1,11 @@
+class NormalizeUsersEmail < ActiveRecord::Migration
+ def up
+ User.find_each do |u|
+ u.update_column :email, u.send(:normalize_email)
+ end
+ end
+
+ def down
+ say "this migration can't be reverted"
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 72722e9..6971f09 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -101,6 +101,7 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
end
add_index "article_versions", ["article_id"], :name => "index_article_versions_on_article_id"
+ add_index "article_versions", ["parent_id"], :name => "index_article_versions_on_parent_id"
add_index "article_versions", ["path", "profile_id"], :name => "index_article_versions_on_path_and_profile_id"
add_index "article_versions", ["path"], :name => "index_article_versions_on_path"
add_index "article_versions", ["published_at", "id"], :name => "index_article_versions_on_published_at_and_id"
@@ -217,8 +218,11 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
t.string "acronym"
t.string "abbreviation"
t.string "display_color", :limit => 6
+ t.text "ancestry"
end
+ add_index "categories", ["parent_id"], :name => "index_categories_on_parent_id"
+
create_table "categories_profiles", :id => false, :force => true do |t|
t.integer "profile_id"
t.integer "category_id"
@@ -237,6 +241,14 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
t.datetime "updated_at"
end
+ create_table "chat_messages", :force => true do |t|
+ t.integer "to_id"
+ t.integer "from_id"
+ t.string "body"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "comments", :force => true do |t|
t.string "title"
t.text "body"
@@ -251,6 +263,8 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
t.string "source_type"
t.string "user_agent"
t.string "referrer"
+ t.text "setting"
+ t.integer "paragraph_id"
end
add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam"
@@ -357,6 +371,8 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
t.boolean "thumbnails_processed", :default => false
end
+ add_index "images", ["parent_id"], :name => "index_images_on_parent_id"
+
create_table "inputs", :force => true do |t|
t.integer "product_id", :null => false
t.integer "product_category_id", :null => false
@@ -650,6 +666,7 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
end
add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true
+ add_index "tags", ["parent_id"], :name => "index_tags_on_parent_id"
create_table "tasks", :force => true do |t|
t.text "data"
@@ -689,6 +706,8 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
t.string "thumbnail"
end
+ add_index "thumbnails", ["parent_id"], :name => "index_thumbnails_on_parent_id"
+
create_table "units", :force => true do |t|
t.string "singular", :null => false
t.string "plural", :null => false
@@ -699,23 +718,26 @@ ActiveRecord::Schema.define(:version => 20150122165042) do
create_table "users", :force => true do |t|
t.string "login"
t.string "email"
- t.string "crypted_password", :limit => 40
- t.string "salt", :limit => 40
+ t.string "crypted_password", :limit => 40
+ t.string "salt", :limit => 40
t.datetime "created_at"
t.datetime "updated_at"
t.string "remember_token"
t.datetime "remember_token_expires_at"
t.text "terms_of_use"
- t.string "terms_accepted", :limit => 1
+ t.string "terms_accepted", :limit => 1
t.integer "environment_id"
t.string "password_type"
- t.boolean "enable_email", :default => false
- t.string "last_chat_status", :default => ""
- t.string "chat_status", :default => ""
+ t.boolean "enable_email", :default => false
+ t.string "last_chat_status", :default => ""
+ t.string "chat_status", :default => ""
t.datetime "chat_status_at"
- t.string "activation_code", :limit => 40
+ t.string "activation_code", :limit => 40
t.datetime "activated_at"
t.string "return_to"
+ t.datetime "last_login_at"
+ t.string "private_token"
+ t.datetime "private_token_generated_at"
end
create_table "validation_infos", :force => true do |t|
diff --git a/debian/control b/debian/control
index a88b378..a586141 100644
--- a/debian/control
+++ b/debian/control
@@ -48,7 +48,6 @@ Depends: adduser,
ruby-feedparser,
ruby-feedparser (>= 0.7-3~),
ruby-gettext,
- ruby-hpricot,
ruby-memcache-client,
ruby-minitest,
ruby-nokogiri,
diff --git a/features/events.feature b/features/events.feature
index c9815ea..22772e2 100644
--- a/features/events.feature
+++ b/features/events.feature
@@ -9,6 +9,7 @@ Feature: events
And the following events
| owner | name | start_date |
| josesilva | Another Conference | 2009-10-24 |
+ | josesilva | Some Conference | 2009-10-22 |
Scenario: go to next month
Given I am on /profile/josesilva/events/2009/10
@@ -114,9 +115,11 @@ Feature: events
@selenium
Scenario: show events when i follow a specific day
Given I am on /profile/josesilva/events/2009/10
- And I should see "Another Conference"
+ And I should see "Another Conference" within "#agenda"
+ And I should see "Some Conference" within "#agenda"
When I follow "24"
- Then I should see "Another Conference"
+ Then I should see "Another Conference" within "#agenda"
+ And I should not see "Some Conference" within "#agenda"
@selenium
Scenario: show events in a range when i follow a specific day
diff --git a/lib/acts_as_filesystem.rb b/lib/acts_as_filesystem.rb
index b9aea69..b9bae29 100644
--- a/lib/acts_as_filesystem.rb
+++ b/lib/acts_as_filesystem.rb
@@ -1,6 +1,6 @@
module ActsAsFileSystem
- module ClassMethods
+ module ActsMethods
# Declares the ActiveRecord model to acts like a filesystem: objects are
# arranged in a tree (liks acts_as_tree), and . The underlying table must
@@ -14,66 +14,80 @@ module ActsAsFileSystem
# the parent, a "/" and the slug of the object)
# * children_count - a cache of the number of children elements.
def acts_as_filesystem
-
- include ActsAsFileSystem::InstanceMethods
-
# a filesystem is a tree
- acts_as_tree :order => 'name', :counter_cache => :children_count
+ acts_as_tree :counter_cache => :children_count
- # calculate the right path
- before_create do |record|
- if record.path == record.slug && (! record.top_level?)
- record.path = record.calculate_path
- end
- true
+ extend ClassMethods
+ include InstanceMethods
+ if self.has_path?
+ after_update :update_children_path
+ before_create :set_path
+ include InstanceMethods::PathMethods
end
- # when renaming a category, all children categories must have their paths
- # recalculated
- after_update do |record|
- if record.recalculate_path
- record.children.each do |item|
- item.path = item.calculate_path
- item.recalculate_path = true
- item.save!
- end
+ before_save :set_ancestry
+ end
+
+ end
+
+ module ClassMethods
+
+ def build_ancestry(parent_id = nil, ancestry = '')
+ ActiveRecord::Base.transaction do
+ self.base_class.all(:conditions => {:parent_id => parent_id}).each do |node|
+ node.update_column :ancestry, ancestry
+
+ build_ancestry node.id, (ancestry.empty? ? "#{node.formatted_ancestry_id}" :
+ "#{ancestry}#{node.ancestry_sep}#{node.formatted_ancestry_id}")
end
- record.recalculate_path = false
- true
end
+ #raise "Couldn't reach and set ancestry on every record" if self.base_class.count(:conditions => ['ancestry is null']) != 0
+ end
+
+ def has_path?
+ (['name', 'slug', 'path'] - self.column_names).blank?
end
+
end
module InstanceMethods
- # used to know when to trigger batch renaming
- attr_accessor :recalculate_path
- # calculates the full name of a category by accessing the name of all its
- # ancestors.
- #
- # If you have this category hierarchy:
- # Category "A"
- # Category "B"
- # Category "C"
- #
- # Then Category "C" will have "A/B/C" as its full name.
- def full_name(sep = '/')
- self.hierarchy.map {|item| item.name || '?' }.join(sep)
+ def ancestry_column
+ 'ancestry'
+ end
+ def ancestry_sep
+ '.'
+ end
+ def has_ancestry?
+ self.class.column_names.include? self.ancestry_column
+ end
+
+ def formatted_ancestry_id
+ "%010d" % self.id if self.id
end
- # gets the name without leading parents. Usefull when dividing categories
- # in top-level groups and full names must not include the top-level
- # category which is already a emphasized label
- def full_name_without_leading(count, sep = '/')
- parts = self.full_name(sep).split(sep)
- count.times { parts.shift }
- parts.join(sep)
+ def ancestry
+ self[ancestry_column]
+ end
+ def ancestor_ids
+ return nil if !has_ancestry? or ancestry.nil?
+ @ancestor_ids ||= ancestry.split(ancestry_sep).map{ |id| id.to_i }
+ end
+
+ def ancestry=(value)
+ self[ancestry_column] = value
+ end
+ def set_ancestry
+ return unless self.has_ancestry?
+ if self.ancestry.nil? or (new_record? or parent_id_changed?) or recalculate_path
+ self.ancestry = self.hierarchy(true)[0...-1].map{ |p| p.formatted_ancestry_id }.join(ancestry_sep)
+ end
end
- # calculates the level of the category in the category hierarchy. Top-level
- # categories have level 0; the children of the top-level categories have
- # level 1; the children of categories with level 1 have level 2, and so on.
+ # calculates the level of the record in the records hierarchy. Top-level
+ # records have level 0; the children of the top-level records have
+ # level 1; the children of records with level 1 have level 2, and so on.
#
# A level 0
# / \
@@ -82,61 +96,36 @@ module ActsAsFileSystem
# E F G H level 2
# ...
def level
- self.parent ? (self.parent.level + 1) : 0
+ self.hierarchy.size - 1
end
- # Is this category a top-level category?
+ # Is this record a top-level record?
def top_level?
self.parent.nil?
end
- # Is this category a leaf in the hierarchy tree of categories?
+ # Is this record a leaf in the hierarchy tree of records?
#
- # Being a leaf means that this category has no subcategories.
+ # Being a leaf means that this record has no subrecord.
def leaf?
self.children.empty?
end
- def set_name(value)
- if self.name != value
- self.recalculate_path = true
- end
- self[:name] = value
- end
-
- # sets the name of the category. Also sets #slug accordingly.
- def name=(value)
- self.set_name(value)
- unless self.name.blank?
- self.slug = self.name.to_slug
- end
- end
-
- # sets the slug of the category. Also sets the path with the new slug value.
- def slug=(value)
- self[:slug] = value
- unless self.slug.blank?
- self.path = self.calculate_path
+ def top_ancestor
+ if has_ancestry? and !ancestry.nil?
+ self.class.base_class.find_by_id self.top_ancestor_id
+ else
+ self.hierarchy.first
end
end
-
- # calculates the full path to this category using parent's path.
- def calculate_path
- if self.top_level?
- self.slug
+ def top_ancestor_id
+ if has_ancestry? and !ancestry.nil?
+ self.ancestor_ids.first
else
- self.parent.calculate_path + "/" + self.slug
+ self.hierarchy.first.id
end
end
- def top_ancestor
- self.top_level? ? self : self.parent.top_ancestor
- end
-
- def explode_path
- path.split(/\//)
- end
-
# returns the full hierarchy from the top-level item to this one. For
# example, if item1 has a children item2 and item2 has a children item3,
# then item3's hierarchy would be [item1, item2, item3].
@@ -145,16 +134,21 @@ module ActsAsFileSystem
# when the ActiveRecord object was modified in some way, or just after
# changing parent)
def hierarchy(reload = false)
- if reload
- @hierarchy = nil
- end
+ @hierarchy = nil if reload or recalculate_path
- unless @hierarchy
+ if @hierarchy.nil?
@hierarchy = []
- item = self
- while item
- @hierarchy.unshift(item)
- item = item.parent
+
+ if !reload and !recalculate_path and ancestor_ids
+ objects = self.class.base_class.all(:conditions => {:id => ancestor_ids})
+ ancestor_ids.each{ |id| @hierarchy << objects.find{ |t| t.id == id } }
+ @hierarchy << self
+ else
+ item = self
+ while item
+ @hierarchy.unshift(item)
+ item = item.parent
+ end
end
end
@@ -181,8 +175,86 @@ module ActsAsFileSystem
res
end
+ #####
+ # Path methods
+ # These methods are used when _path_, _name_ and _slug_ attributes exist
+ # and should be calculated based on the tree
+ #####
+ module PathMethods
+ # used to know when to trigger batch renaming
+ attr_accessor :recalculate_path
+
+ # calculates the full path to this record using parent's path.
+ def calculate_path
+ self.hierarchy.map{ |obj| obj.slug }.join('/')
+ end
+ def set_path
+ if self.path == self.slug && !self.top_level?
+ self.path = self.calculate_path
+ end
+ end
+ def explode_path
+ path.split(/\//)
+ end
+
+ def update_children_path
+ if self.recalculate_path
+ self.children.each do |child|
+ child.path = child.calculate_path
+ child.recalculate_path = true
+ child.save!
+ end
+ end
+ self.recalculate_path = false
+ end
+
+ # calculates the full name of a record by accessing the name of all its
+ # ancestors.
+ #
+ # If you have this record hierarchy:
+ # Record "A"
+ # Record "B"
+ # Record "C"
+ #
+ # Then Record "C" will have "A/B/C" as its full name.
+ def full_name(sep = '/')
+ self.hierarchy.map {|item| item.name || '?' }.join(sep)
+ end
+
+ # gets the name without leading parents. Useful when dividing records
+ # in top-level groups and full names must not include the top-level
+ # record which is already a emphasized label
+ def full_name_without_leading(count, sep = '/')
+ parts = self.full_name(sep).split(sep)
+ count.times { parts.shift }
+ parts.join(sep)
+ end
+
+ def set_name(value)
+ if self.name != value
+ self.recalculate_path = true
+ end
+ self[:name] = value
+ end
+
+ # sets the name of the record. Also sets #slug accordingly.
+ def name=(value)
+ self.set_name(value)
+ unless self.name.blank?
+ self.slug = self.name.to_slug
+ end
+ end
+
+ # sets the slug of the record. Also sets the path with the new slug value.
+ def slug=(value)
+ self[:slug] = value
+ unless self.slug.blank?
+ self.path = self.calculate_path
+ end
+ end
+ end
end
end
-ActiveRecord::Base.extend ActsAsFileSystem::ClassMethods
+ActiveRecord::Base.extend ActsAsFileSystem::ActsMethods
diff --git a/lib/acts_as_having_boxes.rb b/lib/acts_as_having_boxes.rb
index a6a3c06..77a82cd 100644
--- a/lib/acts_as_having_boxes.rb
+++ b/lib/acts_as_having_boxes.rb
@@ -27,8 +27,9 @@ module ActsAsHavingBoxes
end
# returns 3 unless the class table has a boxes_limit column. In that case
- # return the value of the column.
- def boxes_limit
+ # return the value of the column.
+ def boxes_limit layout_template = nil
+ layout_template ||= self.layout_template
@boxes_limit ||= LayoutTemplate.find(layout_template).number_of_boxes || 3
end
diff --git a/lib/authenticated_system.rb b/lib/authenticated_system.rb
index 0b48db1..e522566 100644
--- a/lib/authenticated_system.rb
+++ b/lib/authenticated_system.rb
@@ -5,22 +5,23 @@ module AuthenticatedSystem
def logged_in?
current_user != nil
end
-
+
# Accesses the current user from the session.
def current_user
@current_user ||= (session[:user] && User.find_by_id(session[:user])) || nil
end
-
+
# Store the given user in the session.
def current_user=(new_user)
if new_user.nil?
session.delete(:user)
else
session[:user] = new_user.id
+ new_user.register_login
end
@current_user = new_user
end
-
+
# Check if the user is authorized.
#
# Override this method in your controllers if you want to restrict access
@@ -62,7 +63,7 @@ module AuthenticatedSystem
access_denied
end
end
-
+
# Redirect as appropriate when an access request fails.
#
# The default action is to redirect to the login screen.
@@ -88,15 +89,15 @@ module AuthenticatedSystem
end
end
false
- end
-
+ end
+
# Store the URI of the current request in the session.
#
# We can return to this location by calling #redirect_back_or_default.
def store_location(location = request.url)
session[:return_to] = location
end
-
+
# Redirect to the URI stored by the most recent store_location call or
# to the passed default.
def redirect_back_or_default(default)
@@ -106,7 +107,7 @@ module AuthenticatedSystem
redirect_to(default)
end
end
-
+
# Inclusion hook to make #current_user and #logged_in?
# available as ActionView helper methods.
def self.included(base)
@@ -132,6 +133,6 @@ module AuthenticatedSystem
def get_auth_data
auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
- return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
+ return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
end
end
diff --git a/lib/noosfero/constants.rb b/lib/noosfero/constants.rb
index b587fd4..e1d97c7 100644
--- a/lib/noosfero/constants.rb
+++ b/lib/noosfero/constants.rb
@@ -1,5 +1,5 @@
module Noosfero::Constants
- EMAIL_FORMAT = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
+ EMAIL_FORMAT = /\A([^@\s]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})\Z/i
INTEGER_FORMAT = /\A\d*\Z/i
PROFILE_PER_PAGE = 10
end
diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb
index 7ff4653..2626738 100644
--- a/lib/noosfero/plugin.rb
+++ b/lib/noosfero/plugin.rb
@@ -24,11 +24,17 @@ class Noosfero::Plugin
def initialize!
return if !should_load
- available_plugins.each do |plugin_dir|
+
+ klasses = available_plugins.map do |plugin_dir|
plugin_name = File.basename(plugin_dir)
- plugin = load_plugin(plugin_name)
- load_plugin_extensions(plugin_dir)
- load_plugin_filters(plugin)
+ load_plugin plugin_name
+ end
+ available_plugins.each do |plugin_dir|
+ load_plugin_extensions plugin_dir
+ end
+ # filters must be loaded after all extensions
+ klasses.each do |plugin|
+ load_plugin_filters plugin
end
end
@@ -88,7 +94,7 @@ class Noosfero::Plugin
# This is a generic method that initialize any possible filter defined by a
# plugin to a specific controller
def load_plugin_filters(plugin)
- Rails.configuration.to_prepare do
+ ActionDispatch::Reloader.to_prepare do
filters = plugin.new.send 'application_controller_filters' rescue []
Noosfero::Plugin.add_controller_filters ApplicationController, plugin, filters
@@ -116,7 +122,7 @@ class Noosfero::Plugin
end
def load_plugin_extensions(dir)
- Rails.configuration.to_prepare do
+ ActionDispatch::Reloader.to_prepare do
Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file }
end
end
@@ -267,7 +273,16 @@ class Noosfero::Plugin
nil
end
- # -> Adds content to catalog item
+ # -> Adds tabs to the products
+ # returns = { :title => title, :id => id, :content => content }
+ # title = name that will be displayed.
+ # id = div id.
+ # content = lambda block that creates html code.
+ def product_tabs product
+ nil
+ end
+
+ # -> Adds content to calalog item
# returns = lambda block that creates html code
def catalog_item_extras(item)
nil
@@ -444,7 +459,7 @@ class Noosfero::Plugin
def upload_files_extra_fields(article)
nil
end
-
+
# -> Adds fields to the signup form
# returns = proc that creates html code
def signup_extra_contents
diff --git a/lib/noosfero/plugin/macro.rb b/lib/noosfero/plugin/macro.rb
index 1fdeb09..b459a9d 100644
--- a/lib/noosfero/plugin/macro.rb
+++ b/lib/noosfero/plugin/macro.rb
@@ -35,7 +35,7 @@ class Noosfero::Plugin::Macro
def attributes(macro)
macro.attributes.to_hash.
select {|key, value| key[0..10] == 'data-macro-'}.
- inject({}){|result, a| result.merge({a[0][11..-1] => a[1]})}.
+ inject({}){|result, a| result.merge({a[0][11..-1] => a[1].to_s})}.
with_indifferent_access
end
diff --git a/lib/noosfero/plugin/routes.rb b/lib/noosfero/plugin/routes.rb
index ac9929b..2446799 100644
--- a/lib/noosfero/plugin/routes.rb
+++ b/lib/noosfero/plugin/routes.rb
@@ -1,17 +1,20 @@
plugins_root = Rails.env.test? ? 'plugins' : '{baseplugins,config/plugins}'
+prefixes_by_folder = {public: 'plugin',
+ profile: 'profile/:profile/plugin',
+ myprofile: 'myprofile/:profile/plugin',
+ admin: 'admin/plugin'}
Dir.glob(Rails.root.join(plugins_root, '*', 'controllers')) do |controllers_dir|
- prefixes_by_folder = {'public' => 'plugin',
- 'profile' => 'profile/:profile/plugin',
- 'myprofile' => 'myprofile/:profile/plugin',
- 'admin' => 'admin/plugin'}
+ plugin_name = File.basename(File.dirname(controllers_dir))
controllers_by_folder = prefixes_by_folder.keys.inject({}) do |hash, folder|
- hash.merge!({folder => Dir.glob(File.join(controllers_dir, folder, '*')).map {|full_names| File.basename(full_names).gsub(/_controller.rb$/,'')}})
+ path = "#{controllers_dir}/#{folder}/"
+ hash[folder] = Dir.glob("#{path}{*.rb,#{plugin_name}_plugin/*.rb}").map do |filename|
+ filename.gsub(path, '').gsub(/_controller.rb$/, '')
+ end
+ hash
end
- plugin_name = File.basename(File.dirname(controllers_dir))
-
controllers_by_folder.each do |folder, controllers|
controllers.each do |controller|
controller_name = controller.gsub("#{plugin_name}_plugin_",'')
diff --git a/lib/noosfero/plugin/spammable.rb b/lib/noosfero/plugin/spammable.rb
index d220bd8..a8a1712 100644
--- a/lib/noosfero/plugin/spammable.rb
+++ b/lib/noosfero/plugin/spammable.rb
@@ -1,4 +1,4 @@
-Rails.configuration.to_prepare do
+ActionDispatch::Reloader.to_prepare do
Spammable.module_eval do
def marked_as_spam
plugins.dispatch(:marked_as_spam, self)
diff --git a/lib/noosfero/translatable_content.rb b/lib/noosfero/translatable_content.rb
index f1ef3f6..d3bbc5a 100644
--- a/lib/noosfero/translatable_content.rb
+++ b/lib/noosfero/translatable_content.rb
@@ -1,6 +1,7 @@
module Noosfero::TranslatableContent
def translatable?
+ return false if self.profile && !self.profile.environment.languages.present?
parent.nil? || !parent.forum?
end
end
diff --git a/lib/tasks/multitenancy.rake b/lib/tasks/multitenancy.rake
index d2994ab..af646f4 100644
--- a/lib/tasks/multitenancy.rake
+++ b/lib/tasks/multitenancy.rake
@@ -1,16 +1,16 @@
namespace :multitenancy do
- task :create do
+ task :create => :environment do
db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
cd Rails.root.join('config', 'environments'), :verbose => true
- file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}"
+ file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}"
(db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env }
end
- task :remove do
+ task :remove => :environment do
db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
cd Rails.root.join('config', 'environments'), :verbose => true
- file_envs = Dir.glob "{*_development.rb,*_prodution.rb,*_test.rb}"
+ file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}"
(file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env }
end
@@ -22,7 +22,7 @@ namespace :db do
envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_#{Rails.env}$/) }
envs.each do |e|
puts "*** Migrating #{e}" if Rake.application.options.trace
- system "rake db:migrate RAILS_ENV=#{e}"
+ system "rake db:migrate RAILS_ENV=#{e} SCHEMA=/dev/null"
end
end
task :migrate => :migrate_other_environments
diff --git a/plugins/bsc/public/jquery.ui.spinner b/plugins/bsc/public/jquery.ui.spinner
deleted file mode 160000
index bd87900..0000000
--- a/plugins/bsc/public/jquery.ui.spinner
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit bd879003043b4a93b78cbd4a582b6e0650900bcb
diff --git a/plugins/bsc/views/shared/_fields.html.erb b/plugins/bsc/views/shared/_fields.html.erb
index 46a1e50..ede0eb1 100644
--- a/plugins/bsc/views/shared/_fields.html.erb
+++ b/plugins/bsc/views/shared/_fields.html.erb
@@ -11,7 +11,7 @@
+JAVASCRIPT
+ end
+
+ def javascript_include_tag_with_jquery(*source)
+ if source.first == :jrails
+ javascripts = []
+ if JRails.google?
+ javascripts \
+ << javascript_include_tag_without_jquery(JRails.jquery_path) \
+ << javascript_include_tag_without_jquery(JRails.jqueryui_path) \
+ << javascript_include_tag_without_jquery(JRails.jqueryui_i18n_path) \
+ end
+ javascripts << javascript_include_tag_without_jquery(*source)
+ javascripts << yield_authenticity_javascript if protect_against_forgery?
+ javascripts.join("\n")
+ else
+ javascript_include_tag_without_jquery(*source)
+ end
+ end
+ alias_method_chain :javascript_include_tag, :jquery
+end
diff --git a/vendor/plugins/eita-jrails/lib/jrails/engine.rb b/vendor/plugins/eita-jrails/lib/jrails/engine.rb
new file mode 100644
index 0000000..c288a78
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/engine.rb
@@ -0,0 +1,26 @@
+require 'rails'
+require 'active_support'
+
+if defined? Rails::Plugin
+ ActiveSupport.on_load :action_controller do
+ require 'jrails/on_load_action_controller'
+ end
+
+ ActiveSupport.on_load :action_view do
+ require 'jrails/on_load_action_view'
+ end
+else
+ module JRails
+ class Engine < Rails::Engine
+ initializer 'jrails.initialize' do
+ ActiveSupport.on_load :action_controller do
+ require 'jrails/on_load_action_controller'
+ end
+
+ ActiveSupport.on_load :action_view do
+ require 'jrails/on_load_action_view'
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/eita-jrails/lib/jrails/javascript_helper.rb b/vendor/plugins/eita-jrails/lib/jrails/javascript_helper.rb
new file mode 100644
index 0000000..4b73e31
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/javascript_helper.rb
@@ -0,0 +1,97 @@
+require 'action_view/helpers/javascript_helper'
+
+module ActionView
+ module Helpers
+ JavaScriptHelper.module_eval do
+
+ include ActionView::Helpers::JqueryHelper
+
+ undef_method :button_to_function if method_defined? :button_to_function
+ undef_method :link_to_function if method_defined? :link_to_function
+
+ # Returns a button with the given +name+ text that'll trigger a JavaScript +function+ using the
+ # onclick handler.
+ #
+ # The first argument +name+ is used as the button's value or display text.
+ #
+ # The next arguments are optional and may include the javascript function definition and a hash of html_options.
+ #
+ # The +function+ argument can be omitted in favor of an +update_page+
+ # block, which evaluates to a string when the template is rendered
+ # (instead of making an Ajax request first).
+ #
+ # The +html_options+ will accept a hash of html attributes for the link tag. Some examples are :class => "nav_button", :id => "articles_nav_button"
+ #
+ # Note: if you choose to specify the javascript function in a block, but would like to pass html_options, set the +function+ parameter to nil
+ #
+ # Examples:
+ # button_to_function "Greeting", "alert('Hello world!')"
+ # button_to_function "Delete", "if (confirm('Really?')) do_delete()"
+ # button_to_function "Details" do |page|
+ # page[:details].visual_effect :toggle_slide
+ # end
+ # button_to_function "Details", :class => "details_button" do |page|
+ # page[:details].visual_effect :toggle_slide
+ # end
+ def button_to_function(name, *args, &block)
+ html_options = args.extract_options!.symbolize_keys
+
+ function = block_given? ? update_page(&block) : args[0] || ''
+ onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function};"
+
+ tag(:input, html_options.merge(:type => 'button', :value => name, :onclick => onclick))
+ end
+
+ # link_to_function("Show me more", nil, :id => "more_link") do |page|
+ # page[:details].visual_effect :toggle_blind
+ # page[:more_link].replace_html "Show me less"
+ # end
+ # Produces:
+ # Show me more
+ #
+ def link_to_function(name, *args, &block)
+ html_options = args.extract_options!.symbolize_keys
+
+ function = block_given? ? update_page(&block) : args[0] || ''
+ onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;"
+ href = html_options[:href] || '#'
+
+ content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick))
+ end
+
+ # This function can be used to render rjs inline
+ #
+ # <%= javascript_function do |page|
+ # page.replace_html :list, :partial => 'list', :object => @list
+ # end %>
+ #
+ def javascript_function(*args, &block)
+ html_options = args.extract_options!
+ function = args[0] || ''
+
+ html_options.symbolize_keys!
+ function = update_page(&block) if block_given?
+ javascript_tag(function)
+ end
+
+ def jquery_id(id)
+ id.to_s.count('#.*,>+~:[/ ') == 0 ? "##{id}" : id
+ end
+
+ def jquery_ids(ids)
+ Array(ids).map{|id| jquery_id(id)}.join(',')
+ end
+
+ end
+ end
+end
diff --git a/vendor/plugins/eita-jrails/lib/jrails/on_load_action_controller.rb b/vendor/plugins/eita-jrails/lib/jrails/on_load_action_controller.rb
new file mode 100644
index 0000000..4f088c2
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/on_load_action_controller.rb
@@ -0,0 +1,2 @@
+require 'jrails/selector_assertions'
+require 'jrails/renderers'
diff --git a/vendor/plugins/eita-jrails/lib/jrails/on_load_action_view.rb b/vendor/plugins/eita-jrails/lib/jrails/on_load_action_view.rb
new file mode 100644
index 0000000..c9d4e4e
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/on_load_action_view.rb
@@ -0,0 +1,26 @@
+require 'action_view/helpers/jquery_helper'
+require 'action_view/helpers/jquery_ui_helper'
+require 'action_view/template/handlers/rjs'
+require 'jrails/javascript_helper'
+require 'jrails/rendering'
+
+ActionView::Base.class_eval do
+ cattr_accessor :debug_rjs
+ self.debug_rjs = false
+end
+
+ActionView::Base.class_eval do
+ #require 'jrails/asset_tag_ext'
+ include ActionView::Helpers::JqueryHelper
+ include ActionView::Helpers::JqueryUiHelper
+ include ActionView::Helpers::JavaScriptHelper
+end
+
+ActionView::TestCase.class_eval do
+ #require 'jrails/asset_tag_ext'
+ include ActionView::Helpers::JqueryHelper
+ include ActionView::Helpers::JqueryUiHelper
+ include ActionView::Helpers::JavaScriptHelper
+end
+
+ActionView::Template.register_template_handler :rjs, ActionView::Template::Handlers::RJS.new
diff --git a/vendor/plugins/eita-jrails/lib/jrails/renderers.rb b/vendor/plugins/eita-jrails/lib/jrails/renderers.rb
new file mode 100644
index 0000000..c8211e8
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/renderers.rb
@@ -0,0 +1,12 @@
+require 'action_controller/metal/renderers'
+
+module ActionController
+ module Renderers
+ add :update do |proc, options|
+ view_context = self.view_context
+ generator = ActionView::Helpers::JqueryHelper::JavaScriptGenerator.new view_context, &proc
+ self.content_type = Mime::JS
+ self.response_body = generator.to_s
+ end
+ end
+end
diff --git a/vendor/plugins/eita-jrails/lib/jrails/rendering.rb b/vendor/plugins/eita-jrails/lib/jrails/rendering.rb
new file mode 100644
index 0000000..d2ce178
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/rendering.rb
@@ -0,0 +1,13 @@
+require 'action_view/helpers/rendering_helper'
+
+ActionView::Helpers::RenderingHelper.module_eval do
+ def render_with_update options = {}, locals = {}, &block
+ if options == :update
+ update_page(&block)
+ else
+ render_without_update options, locals, &block
+ end
+ end
+
+ alias_method_chain :render, :update
+end
diff --git a/vendor/plugins/eita-jrails/lib/jrails/selector_assertions.rb b/vendor/plugins/eita-jrails/lib/jrails/selector_assertions.rb
new file mode 100644
index 0000000..e006efa
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/jrails/selector_assertions.rb
@@ -0,0 +1,211 @@
+require 'active_support/core_ext/module/aliasing'
+require 'action_controller/vendor/html-scanner'
+require 'action_dispatch/testing/assertions'
+require 'action_dispatch/testing/assertions/selector'
+
+#--
+# Copyright (c) 2006 Assaf Arkin (http://labnotes.org)
+# Under MIT and/or CC By license.
+#++
+
+ActionDispatch::Assertions::SelectorAssertions.module_eval do
+ # Selects content from the RJS response.
+ #
+ # === Narrowing down
+ #
+ # With no arguments, asserts that one or more elements are updated or
+ # inserted by RJS statements.
+ #
+ # Use the +id+ argument to narrow down the assertion to only statements
+ # that update or insert an element with that identifier.
+ #
+ # Use the first argument to narrow down assertions to only statements
+ # of that type. Possible values are :replace, :replace_html,
+ # :show, :hide, :toggle, :remove,
+ # :insert_html and :redirect.
+ #
+ # Use the argument :insert followed by an insertion position to narrow
+ # down the assertion to only statements that insert elements in that
+ # position. Possible values are :top, :bottom, :before
+ # and :after.
+ #
+ # Use the argument :redirect followed by a path to check that an statement
+ # which redirects to the specified path is generated.
+ #
+ # Using the :remove statement, you will be able to pass a block, but it will
+ # be ignored as there is no HTML passed for this statement.
+ #
+ # === Using blocks
+ #
+ # Without a block, +assert_select_rjs+ merely asserts that the response
+ # contains one or more RJS statements that replace or update content.
+ #
+ # With a block, +assert_select_rjs+ also selects all elements used in
+ # these statements and passes them to the block. Nested assertions are
+ # supported.
+ #
+ # Calling +assert_select_rjs+ with no arguments and using nested asserts
+ # asserts that the HTML content is returned by one or more RJS statements.
+ # Using +assert_select+ directly makes the same assertion on the content,
+ # but without distinguishing whether the content is returned in an HTML
+ # or JavaScript.
+ #
+ # ==== Examples
+ #
+ # # Replacing the element foo.
+ # # page.replace 'foo', ...
+ # assert_select_rjs :replace, "foo"
+ #
+ # # Replacing with the chained RJS proxy.
+ # # page[:foo].replace ...
+ # assert_select_rjs :chained_replace, 'foo'
+ #
+ # # Inserting into the element bar, top position.
+ # assert_select_rjs :insert, :top, "bar"
+ #
+ # # Remove the element bar
+ # assert_select_rjs :remove, "bar"
+ #
+ # # Changing the element foo, with an image.
+ # assert_select_rjs "foo" do
+ # assert_select "img[src=/images/logo.gif""
+ # end
+ #
+ # # RJS inserts or updates a list with four items.
+ # assert_select_rjs do
+ # assert_select "ol>li", 4
+ # end
+ #
+ # # The same, but shorter.
+ # assert_select "ol>li", 4
+ #
+ # # Checking for a redirect.
+ # assert_select_rjs :redirect, root_path
+ def assert_select_rjs(*args, &block)
+ rjs_type = args.first.is_a?(Symbol) ? args.shift : nil
+ id = args.first.is_a?(String) ? args.shift : nil
+
+ # If the first argument is a symbol, it's the type of RJS statement we're looking
+ # for (update, replace, insertion, etc). Otherwise, we're looking for just about
+ # any RJS statement.
+ if rjs_type
+ if rjs_type == :insert
+ position = args.shift
+ id = args.shift
+ insertion = "insert_#{position}".to_sym
+ raise ArgumentError, "Unknown RJS insertion type #{position}" unless RJS_STATEMENTS[insertion]
+ statement = "(#{RJS_STATEMENTS[insertion]})"
+ else
+ raise ArgumentError, "Unknown RJS statement type #{rjs_type}" unless RJS_STATEMENTS[rjs_type]
+ statement = "(#{RJS_STATEMENTS[rjs_type]})"
+ end
+ else
+ statement = "#{RJS_STATEMENTS[:any]}"
+ end
+
+ # Next argument we're looking for is the element identifier. If missing, we pick
+ # any element, otherwise we replace it in the statement.
+ pattern = Regexp.new(
+ id ? statement.gsub(RJS_ANY_ID, "\"#{id}\"") : statement
+ )
+
+ # Duplicate the body since the next step involves destroying it.
+ matches = nil
+ case rjs_type
+ when :remove, :show, :hide, :toggle
+ matches = @response.body.match(pattern)
+ else
+ @response.body.gsub(pattern) do |match|
+ html = unescape_rjs(match)
+ matches ||= []
+ matches.concat HTML::Document.new(html).root.children.select { |n| n.tag? }
+ ""
+ end
+ end
+
+ if matches
+ assert true # to count the assertion
+ if block_given? && !([:remove, :show, :hide, :toggle].include? rjs_type)
+ begin
+ @selected ||= nil
+ in_scope, @selected = @selected, matches
+ yield matches
+ ensure
+ @selected = in_scope
+ end
+ end
+ matches
+ else
+ # RJS statement not found.
+ case rjs_type
+ when :remove, :show, :hide, :toggle
+ flunk_message = "No RJS statement that #{rjs_type.to_s}s '#{id}' was rendered."
+ else
+ flunk_message = "No RJS statement that replaces or inserts HTML content."
+ end
+ flunk args.shift || flunk_message
+ end
+ end
+
+ protected
+
+ RJS_PATTERN_HTML = "\"((\\\\\"|[^\"])*)\""
+ RJS_ANY_ID = "[\"']([^\"])*[\"']"
+
+ RJS_STATEMENTS = {
+ :chained_replace => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.replaceWith\\(#{RJS_PATTERN_HTML}\\)",
+ :chained_replace_html => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.updateWith\\(#{RJS_PATTERN_HTML}\\)",
+ :replace_html => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.html\\(#{RJS_PATTERN_HTML}\\)",
+ :insert_html => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.append\\(#{RJS_PATTERN_HTML}\\)",
+ :replace => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.replaceWith\\(#{RJS_PATTERN_HTML}\\)",
+ :insert_top => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.prepend\\(#{RJS_PATTERN_HTML}\\)",
+ :insert_bottom => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.append\\(#{RJS_PATTERN_HTML}\\)",
+ :effect => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.effect\\(",
+ :highlight => "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.effect\\('highlight'"
+ }
+ [:remove, :show, :hide, :toggle, :reset ].each do |action|
+ RJS_STATEMENTS[action] = "\(jQuery|$\)\\(#{RJS_ANY_ID}\\)\\.#{action}\\(\\)"
+ end
+
+ RJS_STATEMENTS[:any] = Regexp.new("(#{RJS_STATEMENTS.values.join('|')})")
+ RJS_PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
+
+ # +assert_select+ and +css_select+ call this to obtain the content in the HTML
+ # page, or from all the RJS statements, depending on the type of response.
+ def response_from_page_with_rjs
+ content_type = @response.content_type
+
+ if content_type && Mime::JS =~ content_type
+ body = @response.body.dup
+ root = HTML::Node.new(nil)
+
+ while true
+ next if body.sub!(RJS_STATEMENTS[:any]) do |match|
+ html = unescape_rjs(match)
+ matches = HTML::Document.new(html).root.children.select { |n| n.tag? }
+ root.children.concat matches
+ ""
+ end
+ break
+ end
+
+ root
+ else
+ response_from_page_without_rjs
+ end
+ end
+ alias_method_chain :response_from_page, :rjs
+
+ # Unescapes a RJS string.
+ def unescape_rjs(rjs_string)
+ # RJS encodes double quotes and line breaks.
+ unescaped= rjs_string.gsub('\"', '"')
+ unescaped.gsub!(/\\\//, '/')
+ unescaped.gsub!('\n', "\n")
+ unescaped.gsub!('\076', '>')
+ unescaped.gsub!('\074', '<')
+ # RJS encodes non-ascii characters.
+ unescaped.gsub!(RJS_PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
+ unescaped
+ end
+end
diff --git a/vendor/plugins/eita-jrails/lib/tasks/jrails.rake b/vendor/plugins/eita-jrails/lib/tasks/jrails.rake
new file mode 100644
index 0000000..29c56c5
--- /dev/null
+++ b/vendor/plugins/eita-jrails/lib/tasks/jrails.rake
@@ -0,0 +1,25 @@
+namespace :jrails do
+
+ namespace :assets do
+ desc "Install javascript and css files for jquery and jqueryui"
+ task :install do
+ puts "Copying files..."
+ project_dir = Rails.root + '/public/'
+ plugin_assets_dir = File.join(File.dirname(__FILE__), '../..', 'assets/.')
+ FileUtils.cp_r plugin_assets_dir, project_dir
+ puts "files install succesfully"
+ end
+
+ desc 'Remove the prototype / script.aculo.us javascript files'
+ task :scrub do
+ puts "Removing files..."
+ files = %W[controls.js dragdrop.js effects.js prototype.js]
+ project_dir = File.join(Rails.root, 'public', 'javascripts')
+ files.each do |fname|
+ FileUtils.rm(File.join(project_dir, fname)) if File.exists?(File.join(project_dir, fname))
+ end
+ puts "files removed successfully."
+ end
+ end
+
+end
diff --git a/vendor/plugins/eita-jrails/test/assert_select_test.rb b/vendor/plugins/eita-jrails/test/assert_select_test.rb
new file mode 100644
index 0000000..f627f17
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/assert_select_test.rb
@@ -0,0 +1,457 @@
+# coding: utf-8
+
+require 'abstract_unit'
+
+class AssertSelectTest < ActionController::TestCase
+ Assertion = ActiveSupport::TestCase::Assertion
+
+ class AssertSelectController < ActionController::Base
+ def response_with=(content)
+ @content = content
+ end
+
+ def response_with(&block)
+ @update = block
+ end
+
+ def rjs
+ render :update do |page|
+ @update.call page
+ end
+ @update = nil
+ end
+
+ def rescue_action(e)
+ raise e
+ end
+ end
+
+ tests AssertSelectController
+
+ def assert_failure(message, &block)
+ e = assert_raise(Assertion, &block)
+ assert_match(message, e.message) if Regexp === message
+ assert_equal(message, e.message) if String === message
+ end
+
+ # With single result.
+ def test_assert_select_from_rjs_with_single_result
+ render_rjs do |page|
+ page.replace_html "test", "
foo
\n
foo
"
+ end
+ assert_select "div" do |elements|
+ assert elements.size == 2
+ assert_select "#1"
+ assert_select "#2"
+ end
+ assert_select "div#?", /\d+/ do |elements|
+ assert_select "#1"
+ assert_select "#2"
+ end
+ end
+
+ # With multiple results.
+ def test_assert_select_from_rjs_with_multiple_results
+ render_rjs do |page|
+ page.replace_html "test", "
foo
"
+ page.replace_html "test2", "
foo
"
+ end
+ assert_select "div" do |elements|
+ assert elements.size == 2
+ assert_select "#1"
+ assert_select "#2"
+ end
+ end
+
+ # With one result.
+ def test_css_select_from_rjs_with_single_result
+ render_rjs do |page|
+ page.replace_html "test", "
foo
\n
foo
"
+ end
+ assert_equal 2, css_select("div").size
+ assert_equal 1, css_select("#1").size
+ assert_equal 1, css_select("#2").size
+ end
+
+ # With multiple results.
+ def test_css_select_from_rjs_with_multiple_results
+ render_rjs do |page|
+ page.replace_html "test", "
foo
"
+ page.replace_html "test2", "
foo
"
+ end
+
+ assert_equal 2, css_select("div").size
+ assert_equal 1, css_select("#1").size
+ assert_equal 1, css_select("#2").size
+ end
+
+ #
+ # Test assert_select_rjs.
+ #
+
+ def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments
+ render_rjs do |page|
+ page.insert_html :top, "test1", "
foo
"
+ page.insert_html :bottom, "test2", "
foo
"
+ end
+ assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"}
+ end
+
+ # Test that we can pick up all statements in the result.
+ def test_assert_select_rjs_picks_up_all_statements
+ render_rjs do |page|
+ page.replace "test", "
foo
"
+ page.replace_html "test2", "
foo
"
+ page.insert_html :top, "test3", "
foo
"
+ end
+
+ found = false
+ assert_select_rjs do
+ assert_select "#1"
+ assert_select "#2"
+ assert_select "#3"
+ found = true
+ end
+ assert found
+ end
+
+ # Test that we fail if there is nothing to pick.
+ def test_assert_select_rjs_fails_if_nothing_to_pick
+ render_rjs { }
+ assert_raise(Assertion) { assert_select_rjs }
+ end
+
+ def test_assert_select_rjs_with_unicode
+ # Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly.
+
+ unicode = "\343\203\201\343\202\261\343\203\203\343\203\210"
+ render_rjs do |page|
+ page.replace "test", %(
#{unicode}
)
+ end
+
+ assert_select_rjs do
+ str = "#1"
+ assert_select str, :text => unicode
+ assert_select str, unicode
+ if str.respond_to?(:force_encoding)
+ assert_select str, /\343\203\201..\343\203\210/u
+ assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u }
+ else
+ assert_select str, Regexp.new("\343\203\201..\343\203\210", 0, 'U')
+ assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210", 0, 'U') }
+ end
+ end
+ end
+
+ def test_assert_select_rjs_with_id
+ # Test that we can pick up all statements in the result.
+ render_rjs do |page|
+ page.replace "test1", "
foo
"
+ page.replace_html "test2", "
foo
"
+ page.insert_html :top, "test3", "
foo
"
+ end
+ assert_select_rjs "test1" do
+ assert_select "div", 1
+ assert_select "#1"
+ end
+ assert_select_rjs "test2" do
+ assert_select "div", 1
+ assert_select "#2"
+ end
+ assert_select_rjs "test3" do
+ assert_select "div", 1
+ assert_select "#3"
+ end
+ assert_raise(Assertion) { assert_select_rjs "test4" }
+ end
+
+ def test_assert_select_rjs_for_replace
+ render_rjs do |page|
+ page.replace "test1", "
foo
"
+ page.replace_html "test2", "
foo
"
+ page.insert_html :top, "test3", "
foo
"
+ end
+ # Replace.
+ assert_select_rjs :replace do
+ assert_select "div", 1
+ assert_select "#1"
+ end
+ assert_select_rjs :replace, "test1" do
+ assert_select "div", 1
+ assert_select "#1"
+ end
+ assert_raise(Assertion) { assert_select_rjs :replace, "test2" }
+ # Replace HTML.
+ assert_select_rjs :replace_html do
+ assert_select "div", 1
+ assert_select "#2"
+ end
+ assert_select_rjs :replace_html, "test2" do
+ assert_select "div", 1
+ assert_select "#2"
+ end
+ assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
+ end
+
+ def test_assert_select_rjs_for_chained_replace
+ render_rjs do |page|
+ page['test1'].replace "
foo
"
+ page['test2'].replace_html "
foo
"
+ page.insert_html :top, "test3", "
foo
"
+ end
+ # Replace.
+ assert_select_rjs :chained_replace do
+ assert_select "div", 1
+ assert_select "#1"
+ end
+ assert_select_rjs :chained_replace, "test1" do
+ assert_select "div", 1
+ assert_select "#1"
+ end
+ assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" }
+ # Replace HTML.
+ assert_select_rjs :chained_replace_html do
+ assert_select "div", 1
+ assert_select "#2"
+ end
+ assert_select_rjs :chained_replace_html, "test2" do
+ assert_select "div", 1
+ assert_select "#2"
+ end
+ assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
+ end
+
+ # Simple remove
+ def test_assert_select_rjs_for_remove
+ render_rjs do |page|
+ page.remove "test1"
+ end
+
+ assert_select_rjs :remove, "test1"
+ end
+
+ def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails
+ render_rjs do |page|
+ page.remove "test_with_typo"
+ end
+
+ assert_select_rjs :remove, "test1"
+
+ rescue Assertion => e
+ assert_equal "No RJS statement that removes 'test1' was rendered.", e.message
+ end
+
+ def test_assert_select_rjs_for_remove_ignores_block
+ render_rjs do |page|
+ page.remove "test1"
+ end
+
+ assert_nothing_raised do
+ assert_select_rjs :remove, "test1" do
+ assert_select "p"
+ end
+ end
+ end
+
+ # Simple show
+ def test_assert_select_rjs_for_show
+ render_rjs do |page|
+ page.show "test1"
+ end
+
+ assert_select_rjs :show, "test1"
+ end
+
+ def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails
+ render_rjs do |page|
+ page.show "test_with_typo"
+ end
+
+ assert_select_rjs :show, "test1"
+
+ rescue Assertion => e
+ assert_equal "No RJS statement that shows 'test1' was rendered.", e.message
+ end
+
+ def test_assert_select_rjs_for_show_ignores_block
+ render_rjs do |page|
+ page.show "test1"
+ end
+
+ assert_nothing_raised do
+ assert_select_rjs :show, "test1" do
+ assert_select "p"
+ end
+ end
+ end
+
+ # Simple hide
+ def test_assert_select_rjs_for_hide
+ render_rjs do |page|
+ page.hide "test1"
+ end
+
+ assert_select_rjs :hide, "test1"
+ end
+
+ def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails
+ render_rjs do |page|
+ page.hide "test_with_typo"
+ end
+
+ assert_select_rjs :hide, "test1"
+
+ rescue Assertion => e
+ assert_equal "No RJS statement that hides 'test1' was rendered.", e.message
+ end
+
+ def test_assert_select_rjs_for_hide_ignores_block
+ render_rjs do |page|
+ page.hide "test1"
+ end
+
+ assert_nothing_raised do
+ assert_select_rjs :hide, "test1" do
+ assert_select "p"
+ end
+ end
+ end
+
+ # Simple toggle
+ def test_assert_select_rjs_for_toggle
+ render_rjs do |page|
+ page.toggle "test1"
+ end
+
+ assert_select_rjs :toggle, "test1"
+ end
+
+ def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails
+ render_rjs do |page|
+ page.toggle "test_with_typo"
+ end
+
+ assert_select_rjs :toggle, "test1"
+
+ rescue Assertion => e
+ assert_equal "No RJS statement that toggles 'test1' was rendered.", e.message
+ end
+
+ def test_assert_select_rjs_for_toggle_ignores_block
+ render_rjs do |page|
+ page.toggle "test1"
+ end
+
+ assert_nothing_raised do
+ assert_select_rjs :toggle, "test1" do
+ assert_select "p"
+ end
+ end
+ end
+
+ # Non-positioned insert.
+ def test_assert_select_rjs_for_nonpositioned_insert
+ render_rjs do |page|
+ page.replace "test1", "
foo
"
+ page.replace_html "test2", "
foo
"
+ page.insert_html :top, "test3", "
foo
"
+ end
+ assert_select_rjs :insert_html do
+ assert_select "div", 1
+ assert_select "#3"
+ end
+ assert_select_rjs :insert_html, "test3" do
+ assert_select "div", 1
+ assert_select "#3"
+ end
+ assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" }
+ end
+
+ # Positioned insert.
+ def test_assert_select_rjs_for_positioned_insert
+ render_rjs do |page|
+ page.insert_html :top, "test1", "
foo
"
+ page.insert_html :bottom, "test2", "
foo
"
+ page.insert_html :before, "test3", "
foo
"
+ page.insert_html :after, "test4", "
foo
"
+ end
+ assert_select_rjs :insert, :top do
+ assert_select "div", 1
+ assert_select "#1"
+ end
+ assert_select_rjs :insert, :bottom do
+ assert_select "div", 1
+ assert_select "#2"
+ end
+ assert_select_rjs :insert, :before do
+ assert_select "div", 1
+ assert_select "#3"
+ end
+ assert_select_rjs :insert, :after do
+ assert_select "div", 1
+ assert_select "#4"
+ end
+ assert_select_rjs :insert_html do
+ assert_select "div", 4
+ end
+ end
+
+ def test_assert_select_rjs_raise_errors
+ assert_raise(ArgumentError) { assert_select_rjs(:destroy) }
+ assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) }
+ end
+
+ # Simple selection from a single result.
+ def test_nested_assert_select_rjs_with_single_result
+ render_rjs do |page|
+ page.replace_html "test", "
foo
\n
foo
"
+ end
+
+ assert_select_rjs "test" do |elements|
+ assert_equal 2, elements.size
+ assert_select "#1"
+ assert_select "#2"
+ end
+ end
+
+ # Deal with two results.
+ def test_nested_assert_select_rjs_with_two_results
+ render_rjs do |page|
+ page.replace_html "test", "
foo
"
+ page.replace_html "test2", "
foo
"
+ end
+
+ assert_select_rjs "test" do |elements|
+ assert_equal 1, elements.size
+ assert_select "#1"
+ end
+
+ assert_select_rjs "test2" do |elements|
+ assert_equal 1, elements.size
+ assert_select "#2"
+ end
+ end
+
+ def test_assert_select_rjs_for_redirect_to
+ render_rjs do |page|
+ page.redirect_to '/'
+ end
+ assert_select_rjs :redirect, '/'
+ end
+
+ protected
+ def render_html(html)
+ @controller.response_with = html
+ get :html
+ end
+
+ def render_rjs(&block)
+ @controller.response_with(&block)
+ get :rjs
+ end
+
+ def render_xml(xml)
+ @controller.response_with = xml
+ get :xml
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/controller/caching_test.rb b/vendor/plugins/eita-jrails/test/controller/caching_test.rb
new file mode 100644
index 0000000..5bc1617
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/controller/caching_test.rb
@@ -0,0 +1,43 @@
+require 'abstract_unit'
+
+# Don't change '/../temp/' cavalierly or you might hose something you don't want hosed
+FILE_STORE_PATH = File.expand_path('../../../temp/test_cache', __FILE__)
+
+class CachingController < ActionController::Base
+ abstract!
+
+ self.cache_store = :file_store, FILE_STORE_PATH
+end
+
+class FunctionalCachingController < CachingController
+ def js_fragment_cached_with_partial
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def formatted_fragment_cached
+ respond_to do |format|
+ format.js
+ end
+ end
+end
+
+class FunctionalFragmentCachingTest < ActionController::TestCase
+ def setup
+ super
+ @store = ActiveSupport::Cache::MemoryStore.new
+ @controller = FunctionalCachingController.new
+ @controller.perform_caching = true
+ @controller.cache_store = @store
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_fragment_caching_in_rjs_partials
+ xhr :get, :js_fragment_cached_with_partial
+ assert_response :success
+ assert_match(/Old fragment caching in a partial/, @response.body)
+ assert_match "Old fragment caching in a partial", @store.instance_variable_get('@data').values.first.value
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/controller/content_type_test.rb b/vendor/plugins/eita-jrails/test/controller/content_type_test.rb
new file mode 100644
index 0000000..db32e11
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/controller/content_type_test.rb
@@ -0,0 +1,16 @@
+require 'abstract_unit'
+
+class OldContentTypeController < ActionController::Base
+ def render_default_for_rjs
+ end
+end
+
+class ContentTypeTest < ActionController::TestCase
+ tests OldContentTypeController
+
+ def test_default_for_rjs
+ xhr :post, :render_default_for_rjs
+ assert_equal Mime::JS, @response.content_type
+ assert_equal "utf-8", @response.charset
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/controller/mime_responds_test.rb b/vendor/plugins/eita-jrails/test/controller/mime_responds_test.rb
new file mode 100644
index 0000000..280b4b7
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/controller/mime_responds_test.rb
@@ -0,0 +1,213 @@
+require 'abstract_unit'
+require 'controller/fake_models'
+require 'active_support/core_ext/hash/conversions'
+
+class RespondToController < ActionController::Base
+ layout :set_layout
+
+ def html_xml_or_rss
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.xml { render :text => "XML" }
+ type.rss { render :text => "RSS" }
+ type.all { render :text => "Nothing" }
+ end
+ end
+
+ def js_or_html
+ respond_to do |type|
+ type.js { render :text => "JS" }
+ end
+ end
+
+ def json_or_yaml
+ respond_to do |type|
+ type.json { render :text => "JSON" }
+ type.yaml { render :text => "YAML" }
+ end
+ end
+
+ def html_or_xml
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.xml { render :text => "XML" }
+ type.all { render :text => "Nothing" }
+ end
+ end
+
+ def json_xml_or_html
+ respond_to do |type|
+ type.json { render :text => 'JSON' }
+ type.xml { render :xml => 'XML' }
+ type.html { render :text => 'HTML' }
+ end
+ end
+
+
+ def forced_xml
+ request.format = :xml
+
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.xml { render :text => "XML" }
+ end
+ end
+
+ def just_xml
+ respond_to do |type|
+ type.xml { render :text => "XML" }
+ end
+ end
+
+ def using_defaults
+ respond_to do |type|
+ type.js
+ end
+ end
+
+ def using_defaults_with_type_list
+ respond_to(:js)
+ end
+
+ def made_for_content_type
+ respond_to do |type|
+ type.rss { render :text => "RSS" }
+ type.atom { render :text => "ATOM" }
+ type.all { render :text => "Nothing" }
+ end
+ end
+
+ def custom_type_handling
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.custom("application/crazy-xml") { render :text => "Crazy XML" }
+ type.all { render :text => "Nothing" }
+ end
+ end
+
+
+ def custom_constant_handling
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.mobile { render :text => "Mobile" }
+ end
+ end
+
+ def custom_constant_handling_without_block
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.mobile
+ end
+ end
+
+ def handle_any
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.any(:js, :xml) { render :text => "Either JS or XML" }
+ end
+ end
+
+ def handle_any_any
+ respond_to do |type|
+ type.html { render :text => 'HTML' }
+ type.any { render :text => 'Whatever you ask for, I got it' }
+ end
+ end
+
+ def all_types_with_layout
+ respond_to do |type|
+ type.js
+ end
+ end
+
+
+ def iphone_with_html_response_type
+ request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone"
+
+ respond_to do |type|
+ type.html { @type = "Firefox" }
+ type.iphone { @type = "iPhone" }
+ end
+ end
+
+ def iphone_with_html_response_type_without_layout
+ request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
+
+ respond_to do |type|
+ type.html { @type = "Firefox"; render :action => "iphone_with_html_response_type" }
+ type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" }
+ end
+ end
+
+ def rescue_action(e)
+ raise
+ end
+
+ protected
+ def set_layout
+ if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name)
+ "respond_to/layouts/standard"
+ elsif action_name == "iphone_with_html_response_type_without_layout"
+ "respond_to/layouts/missing"
+ end
+ end
+end
+
+
+class RespondToControllerTest < ActionController::TestCase
+ tests RespondToController
+
+ def test_using_defaults
+ @request.accept = "text/javascript"
+ get :using_defaults
+ assert_equal "text/javascript", @response.content_type
+ assert_equal '$("body").visualEffect("highlight");', @response.body
+ end
+
+ def test_using_defaults_with_type_list
+ @request.accept = "text/javascript"
+ get :using_defaults_with_type_list
+ assert_equal "text/javascript", @response.content_type
+ assert_equal '$("body").visualEffect("highlight");', @response.body
+ end
+
+ def test_rjs_type_skips_layout
+ @request.accept = "text/javascript"
+ get :all_types_with_layout
+ assert_equal 'RJS for all_types_with_layout', @response.body
+ end
+
+ def test_xhr
+ xhr :get, :using_defaults
+ assert_equal '$("body").visualEffect("highlight");', @response.body
+ end
+end
+
+class RespondWithController < ActionController::Base
+ respond_to :html, :json, :js
+
+ def using_resource
+ respond_with(resource)
+ end
+protected
+
+ def resource
+ Customer.new("david", request.delete? ? nil : 13)
+ end
+
+ def _render_js(js, options)
+ self.content_type ||= Mime::JS
+ self.response_body = js.respond_to?(:to_js) ? js.to_js : js
+ end
+end
+
+class RespondWithControllerTest < ActionController::TestCase
+ tests RespondWithController
+
+ def test_using_resource
+ @request.accept = "text/javascript"
+ get :using_resource
+ assert_equal "text/javascript", @response.content_type
+ assert_equal '$("body").visualEffect("highlight");', @response.body
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/controller/new_base/content_type_test.rb b/vendor/plugins/eita-jrails/test/controller/new_base/content_type_test.rb
new file mode 100644
index 0000000..4e7a8e8
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/controller/new_base/content_type_test.rb
@@ -0,0 +1,19 @@
+require 'abstract_unit'
+
+module ContentType
+ class ImpliedController < ActionController::Base
+ # Template's mime type is used if no content_type is specified
+
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "content_type/implied/i_am_js_rjs.js.rjs" => "page.alert 'hello'"
+ )]
+ end
+
+ class ImpliedContentTypeTest < Rack::TestCase
+ test "sets Content-Type as text/javascript when rendering *.js" do
+ get "/content_type/implied/i_am_js_rjs", "format" => "js"
+
+ assert_header "Content-Type", "text/javascript; charset=utf-8"
+ end
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/controller/new_base/render_rjs_test.rb b/vendor/plugins/eita-jrails/test/controller/new_base/render_rjs_test.rb
new file mode 100644
index 0000000..74bf865
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/controller/new_base/render_rjs_test.rb
@@ -0,0 +1,71 @@
+require 'abstract_unit'
+
+module RenderRjs
+ class BasicController < ActionController::Base
+ layout "application", :only => :index_respond_to
+
+ self.view_paths = [ActionView::FixtureResolver.new(
+ "layouts/application.html.erb" => "",
+ "render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')",
+ "render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'",
+ "render_rjs/basic/index_no_js.js.erb" => "<%= render(:partial => 'developer') %>",
+ "render_rjs/basic/_customer.js.erb" => "JS Partial",
+ "render_rjs/basic/_customer.html.erb" => "HTML Partial",
+ "render_rjs/basic/_developer.html.erb" => "HTML Partial",
+ "render_rjs/basic/index_locale.js.rjs" => "page[:customer].replace_html :partial => 'customer'",
+ "render_rjs/basic/_customer.da.html.erb" => "Danish HTML Partial",
+ "render_rjs/basic/_customer.da.js.erb" => "Danish JS Partial"
+ )]
+
+ def index
+ render
+ end
+
+ def index_respond_to
+ respond_to do |format|
+ format.js { render :action => "index_no_js" }
+ end
+ end
+
+ def index_locale
+ self.locale = :da
+ end
+ end
+
+ class TestBasic < Rack::TestCase
+ testing BasicController
+
+ def setup
+ @old_locale = I18n.locale
+ end
+
+ def teardown
+ I18n.locale = @old_locale
+ end
+
+ test "rendering a partial in an RJS template should pick the JS template over the HTML one" do
+ get :index, "format" => "js"
+ assert_response("$(\"customer\").update(\"JS Partial\");")
+ end
+
+ test "rendering a partial in an RJS template should pick the HTML one if no JS is available" do
+ get :index_no_js, "format" => "js"
+ assert_response("HTML Partial")
+ end
+
+ test "rendering a partial in an RJS template should pick the HTML one if no JS is available on respond_to" do
+ get :index_respond_to, "format" => "js"
+ assert_response("HTML Partial")
+ end
+
+ test "replacing an element with a partial in an RJS template should pick the HTML template over the JS one" do
+ get :index_html, "format" => "js"
+ assert_response("$(\"customer\").update(\"HTML Partial\");")
+ end
+
+ test "replacing an element with a partial in an RJS template with a locale should pick the localed HTML template" do
+ get :index_locale, "format" => "js"
+ assert_response("$(\"customer\").update(\"Danish HTML Partial\");")
+ end
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/controller/render_js_test.rb b/vendor/plugins/eita-jrails/test/controller/render_js_test.rb
new file mode 100644
index 0000000..5b9c550
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/controller/render_js_test.rb
@@ -0,0 +1,22 @@
+require 'abstract_unit'
+
+class RenderJSTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
+
+ def self.controller_path
+ 'test'
+ end
+
+ def greeting
+ # let's just rely on the template
+ end
+ end
+
+ tests TestController
+
+ def test_render_with_default_from_accept_header
+ xhr :get, :greeting
+ assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/fixtures/functional_caching/_partial.erb b/vendor/plugins/eita-jrails/test/fixtures/functional_caching/_partial.erb
new file mode 100644
index 0000000..ec0da7c
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/functional_caching/_partial.erb
@@ -0,0 +1,3 @@
+<% cache do %>
+Old fragment caching in a partial
+<% end %>
diff --git a/vendor/plugins/eita-jrails/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs
new file mode 100644
index 0000000..057f15e
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs
@@ -0,0 +1,6 @@
+page.assign 'title', 'Hey'
+cache do
+ page['element_1'].visual_effect :highlight
+ page['element_2'].visual_effect :highlight
+end
+page.assign 'footer', 'Bye'
diff --git a/vendor/plugins/eita-jrails/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs
new file mode 100644
index 0000000..248842c
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs
@@ -0,0 +1 @@
+page.replace_html 'notices', :partial => 'partial'
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/old_content_type/render_default_for_rjs.rjs b/vendor/plugins/eita-jrails/test/fixtures/old_content_type/render_default_for_rjs.rjs
new file mode 100644
index 0000000..8d614d0
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/old_content_type/render_default_for_rjs.rjs
@@ -0,0 +1 @@
+page.alert 'hello world!'
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/respond_to/all_types_with_layout.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/respond_to/all_types_with_layout.js.rjs
new file mode 100644
index 0000000..b7aec7c
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/respond_to/all_types_with_layout.js.rjs
@@ -0,0 +1 @@
+page << "RJS for all_types_with_layout"
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/respond_to/layouts/standard.html.erb b/vendor/plugins/eita-jrails/test/fixtures/respond_to/layouts/standard.html.erb
new file mode 100644
index 0000000..c6c1a58
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/respond_to/layouts/standard.html.erb
@@ -0,0 +1 @@
+
<%= yield %>
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/respond_to/using_defaults.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/respond_to/using_defaults.js.rjs
new file mode 100644
index 0000000..469fcd8
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/respond_to/using_defaults.js.rjs
@@ -0,0 +1 @@
+page[:body].visual_effect :highlight
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
new file mode 100644
index 0000000..469fcd8
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
@@ -0,0 +1 @@
+page[:body].visual_effect :highlight
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/respond_with/using_resource.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/respond_with/using_resource.js.rjs
new file mode 100644
index 0000000..737c175
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/respond_with/using_resource.js.rjs
@@ -0,0 +1 @@
+page[:body].visual_effect :highlight
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/_one.html.erb b/vendor/plugins/eita-jrails/test/fixtures/test/_one.html.erb
new file mode 100644
index 0000000..f796291
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/_one.html.erb
@@ -0,0 +1 @@
+<%= render :partial => "two" %> world
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/_partial.html.erb b/vendor/plugins/eita-jrails/test/fixtures/test/_partial.html.erb
new file mode 100644
index 0000000..e39f6c9
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/_partial.html.erb
@@ -0,0 +1 @@
+partial html
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/_partial.js.erb b/vendor/plugins/eita-jrails/test/fixtures/test/_partial.js.erb
new file mode 100644
index 0000000..b350cdd
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/_partial.js.erb
@@ -0,0 +1 @@
+partial js
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/_two.html.erb b/vendor/plugins/eita-jrails/test/fixtures/test/_two.html.erb
new file mode 100644
index 0000000..5ab2f8a
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/_two.html.erb
@@ -0,0 +1 @@
+Hello
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/delete_with_js.rjs b/vendor/plugins/eita-jrails/test/fixtures/test/delete_with_js.rjs
new file mode 100644
index 0000000..4b75a95
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/delete_with_js.rjs
@@ -0,0 +1,2 @@
+page.remove 'person'
+page.visual_effect :highlight, "project-#{@project_id}"
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/enum_rjs_test.rjs b/vendor/plugins/eita-jrails/test/fixtures/test/enum_rjs_test.rjs
new file mode 100644
index 0000000..e300407
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/enum_rjs_test.rjs
@@ -0,0 +1,6 @@
+page.select('.product').each do |value|
+ page.visual_effect :highlight
+ page.visual_effect :highlight, value
+ page.sortable(value, :url => { :action => "order" })
+ page.draggable(value)
+end
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/greeting.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/test/greeting.js.rjs
new file mode 100644
index 0000000..469fcd8
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/greeting.js.rjs
@@ -0,0 +1 @@
+page[:body].visual_effect :highlight
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/render_explicit_html_template.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/test/render_explicit_html_template.js.rjs
new file mode 100644
index 0000000..4ac8e25
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/render_explicit_html_template.js.rjs
@@ -0,0 +1 @@
+page.call "document.write", render(:partial => 'one')
diff --git a/vendor/plugins/eita-jrails/test/fixtures/test/render_implicit_html_template.js.rjs b/vendor/plugins/eita-jrails/test/fixtures/test/render_implicit_html_template.js.rjs
new file mode 100644
index 0000000..3d68041
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/fixtures/test/render_implicit_html_template.js.rjs
@@ -0,0 +1 @@
+page.call "document.write", render(:partial => "one")
diff --git a/vendor/plugins/eita-jrails/test/javascript_helper_test.rb b/vendor/plugins/eita-jrails/test/javascript_helper_test.rb
new file mode 100644
index 0000000..c79b067
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/javascript_helper_test.rb
@@ -0,0 +1,61 @@
+require 'abstract_unit'
+
+class JavaScriptHelperTest < ActionView::TestCase
+ tests ActionView::Helpers::JavaScriptHelper
+
+ def _evaluate_assigns_and_ivars() end
+
+ attr_accessor :formats, :output_buffer
+
+ def update_details(details)
+ @details = details
+ yield if block_given?
+ end
+
+ def setup
+ super
+ ActiveSupport.escape_html_entities_in_json = true
+ @template = self
+ end
+
+ def teardown
+ ActiveSupport.escape_html_entities_in_json = false
+ end
+
+ def test_link_to_function_with_rjs_block
+ html = link_to_function( "Greet me!" ) do |page|
+ page.replace_html 'header', "
Greetings
"
+ end
+ assert_dom_equal %(Greet me!), html
+ end
+
+ def test_link_to_function_with_rjs_block_and_options
+ html = link_to_function( "Greet me!", :class => "updater" ) do |page|
+ page.replace_html 'header', "
Greetings
"
+ end
+ assert_dom_equal %(Greet me!), html
+ end
+
+ def test_link_to_function_with_inner_block_does_not_raise_exception
+ html = link_to_function( "Greet me!" ) do |page|
+ page.replace_html 'header', (content_tag :h1 do
+ 'Greetings'
+ end)
+ end
+ assert_dom_equal %(Greet me!), html
+ end
+
+ def test_button_to_function_with_rjs_block
+ html = button_to_function( "Greet me!" ) do |page|
+ page.replace_html 'header', "
Greetings
"
+ end
+ assert_dom_equal %(), html
+ end
+
+ def test_button_to_function_with_rjs_block_and_options
+ html = button_to_function( "Greet me!", :class => "greeter" ) do |page|
+ page.replace_html 'header', "
Greetings
"
+ end
+ assert_dom_equal %(), html
+ end
+end
\ No newline at end of file
diff --git a/vendor/plugins/eita-jrails/test/jrails_test.rb b/vendor/plugins/eita-jrails/test/jrails_test.rb
new file mode 100644
index 0000000..4ca0ab6
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/jrails_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class JrailsTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/lib/abstract_unit.rb b/vendor/plugins/eita-jrails/test/lib/abstract_unit.rb
new file mode 100644
index 0000000..41b92e0
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/lib/abstract_unit.rb
@@ -0,0 +1,225 @@
+require 'rubygems'
+require 'bundler/setup'
+require 'minitest/autorun'
+
+require 'active_support'
+require 'active_support/test_case'
+require 'action_controller'
+require 'action_view'
+require 'action_view/testing/resolvers'
+
+require 'prototype-rails/on_load_action_controller'
+require 'prototype-rails/on_load_action_view'
+
+FIXTURE_LOAD_PATH = File.expand_path('../../fixtures', __FILE__)
+FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
+
+
+module SetupOnce
+ extend ActiveSupport::Concern
+
+ included do
+ cattr_accessor :setup_once_block
+ self.setup_once_block = nil
+
+ setup :run_setup_once
+ end
+
+ module ClassMethods
+ def setup_once(&block)
+ self.setup_once_block = block
+ end
+ end
+
+ private
+ def run_setup_once
+ if self.setup_once_block
+ self.setup_once_block.call
+ self.setup_once_block = nil
+ end
+ end
+end
+
+SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
+
+module ActiveSupport
+ class TestCase
+ include SetupOnce
+ # Hold off drawing routes until all the possible controller classes
+ # have been loaded.
+ setup_once do
+ SharedTestRoutes.draw do
+ get ':controller(/:action)'
+ end
+
+ ActionDispatch::IntegrationTest.app.routes.draw do
+ get ':controller(/:action)'
+ end
+ end
+ end
+end
+
+class RoutedRackApp
+ attr_reader :routes
+
+ def initialize(routes, &blk)
+ @routes = routes
+ @stack = ActionDispatch::MiddlewareStack.new(&blk).build(@routes)
+ end
+
+ def call(env)
+ @stack.call(env)
+ end
+end
+
+class BasicController
+ attr_accessor :request
+
+ def config
+ @config ||= ActiveSupport::InheritableOptions.new(ActionController::Base.config).tap do |config|
+ # VIEW TODO: View tests should not require a controller
+ public_dir = "#{FIXTURE_LOAD_PATH}/public"
+ config.assets_dir = public_dir
+ config.javascripts_dir = "#{public_dir}/javascripts"
+ config.stylesheets_dir = "#{public_dir}/stylesheets"
+ config
+ end
+ end
+end
+
+class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
+ setup do
+ @routes = SharedTestRoutes
+ end
+
+ def self.build_app(routes = nil)
+ RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
+ middleware.use "ActionDispatch::ShowExceptions", ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
+ middleware.use "ActionDispatch::Callbacks"
+ middleware.use "ActionDispatch::ParamsParser"
+ middleware.use "ActionDispatch::Cookies"
+ middleware.use "ActionDispatch::Flash"
+ middleware.use "Rack::Head"
+ yield(middleware) if block_given?
+ end
+ end
+
+ self.app = build_app
+
+ # Stub Rails dispatcher so it does not get controller references and
+ # simply return the controller#action as Rack::Body.
+ class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
+ protected
+ def controller_reference(controller_param)
+ controller_param
+ end
+
+ def dispatch(controller, action, env)
+ [200, {'Content-Type' => 'text/html'}, ["#{controller}##{action}"]]
+ end
+ end
+
+ def self.stub_controllers
+ old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
+ yield ActionDispatch::Routing::RouteSet.new
+ ensure
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
+ end
+
+ def with_routing(&block)
+ temporary_routes = ActionDispatch::Routing::RouteSet.new
+ old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
+ old_routes = SharedTestRoutes
+ silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }
+
+ yield temporary_routes
+ ensure
+ self.class.app = old_app
+ silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
+ end
+
+ def with_autoload_path(path)
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
+ if ActiveSupport::Dependencies.autoload_paths.include?(path)
+ yield
+ else
+ begin
+ ActiveSupport::Dependencies.autoload_paths << path
+ yield
+ ensure
+ ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
+ ActiveSupport::Dependencies.clear
+ end
+ end
+ end
+end
+
+# Temporary base class
+class Rack::TestCase < ActionDispatch::IntegrationTest
+ def self.testing(klass = nil)
+ if klass
+ @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
+ else
+ @testing
+ end
+ end
+
+ def get(thing, *args)
+ if thing.is_a?(Symbol)
+ super("#{self.class.testing}/#{thing}", *args)
+ else
+ super
+ end
+ end
+
+ def assert_body(body)
+ assert_equal body, Array.wrap(response.body).join
+ end
+
+ def assert_status(code)
+ assert_equal code, response.status
+ end
+
+ def assert_response(body, status = 200, headers = {})
+ assert_body body
+ assert_status status
+ headers.each do |header, value|
+ assert_header header, value
+ end
+ end
+
+ def assert_content_type(type)
+ assert_equal type, response.headers["Content-Type"]
+ end
+
+ def assert_header(name, value)
+ assert_equal value, response.headers[name]
+ end
+end
+
+module ActionController
+ class Base
+ include ActionController::Testing
+ # This stub emulates the Railtie including the URL helpers from a Rails application
+ include SharedTestRoutes.url_helpers
+
+ self.view_paths = FIXTURE_LOAD_PATH
+
+ def self.test_routes(&block)
+ routes = ActionDispatch::Routing::RouteSet.new
+ routes.draw(&block)
+ include routes.url_helpers
+ end
+ end
+
+ class TestCase
+ include ActionDispatch::TestProcess
+
+ setup do
+ @routes = SharedTestRoutes
+ end
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/lib/controller/fake_models.rb b/vendor/plugins/eita-jrails/test/lib/controller/fake_models.rb
new file mode 100644
index 0000000..14ad191
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/lib/controller/fake_models.rb
@@ -0,0 +1,29 @@
+require "active_model"
+
+class Customer < Struct.new(:name, :id)
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ undef_method :to_json
+
+ def to_xml(options={})
+ if options[:builder]
+ options[:builder].name name
+ else
+ "#{name}"
+ end
+ end
+
+ def to_js(options={})
+ "name: #{name.inspect}"
+ end
+ alias :to_text :to_js
+
+ def errors
+ []
+ end
+
+ def persisted?
+ id.present?
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/render_other_test.rb b/vendor/plugins/eita-jrails/test/render_other_test.rb
new file mode 100644
index 0000000..27a533e
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/render_other_test.rb
@@ -0,0 +1,256 @@
+require 'abstract_unit'
+require 'pathname'
+require 'securerandom'
+
+ActionController.add_renderer :simon do |says, options|
+ self.content_type = Mime::TEXT
+ self.response_body = "Simon says: #{says}"
+end
+
+class RenderOtherTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
+
+ def self.controller_path
+ 'test'
+ end
+
+ layout :determine_layout
+
+ module RenderTestHelper
+ def rjs_helper_method_from_module
+ page.visual_effect :highlight
+ end
+ end
+
+ helper RenderTestHelper
+ helper do
+ def rjs_helper_method(value)
+ page.visual_effect :highlight, value
+ end
+ end
+
+ def enum_rjs_test
+ render :update do |page|
+ page.select('.product').each do |value|
+ page.rjs_helper_method_from_module
+ page.rjs_helper_method(value)
+ page.sortable(value, :url => { :action => "order" })
+ page.draggable(value)
+ end
+ end
+ end
+
+ def render_explicit_html_template
+ end
+
+ def render_custom_code_rjs
+ render :update, :status => 404 do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+
+ def render_implicit_html_template
+ end
+
+ def render_js_with_explicit_template
+ @project_id = 4
+ render :template => 'test/delete_with_js'
+ end
+
+ def render_js_with_explicit_action_template
+ @project_id = 4
+ render :action => 'delete_with_js'
+ end
+
+ def delete_with_js
+ @project_id = 4
+ end
+
+ def update_page
+ render :update do |page|
+ page.replace_html 'balance', '$37,000,000.00'
+ page.visual_effect :highlight, 'balance'
+ end
+ end
+
+ def update_page_with_instance_variables
+ @money = '$37,000,000.00'
+ @div_id = 'balance'
+ render :update do |page|
+ page.replace_html @div_id, @money
+ page.visual_effect :highlight, @div_id
+ end
+ end
+
+ def update_page_with_view_method
+ render :update do |page|
+ page.replace_html 'person', pluralize(2, 'person')
+ end
+ end
+
+ def partial_as_rjs
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+
+ def respond_to_partial_as_rjs
+ respond_to do |format|
+ format.js do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
+ end
+
+ def render_alternate_default
+ # For this test, the method "default_render" is overridden:
+ @alternate_default_render = lambda do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
+
+ def render_simon_says
+ render :simon => "foo"
+ end
+
+ private
+ def default_render
+ @alternate_default_render ||= nil
+ if @alternate_default_render
+ @alternate_default_render.call
+ else
+ super
+ end
+ end
+
+ def determine_layout
+ case action_name
+ when "hello_world", "layout_test", "rendering_without_layout",
+ "rendering_nothing_on_layout", "render_text_hello_world",
+ "render_text_hello_world_with_layout",
+ "hello_world_with_layout_false",
+ "partial_only", "partial_only_with_layout",
+ "accessing_params_in_template",
+ "accessing_params_in_template_with_layout",
+ "render_with_explicit_template",
+ "render_with_explicit_string_template",
+ "update_page", "update_page_with_instance_variables"
+
+ "layouts/standard"
+ when "action_talk_to_layout", "layout_overriding_layout"
+ "layouts/talk_from_action"
+ when "render_implicit_html_template_from_xhr_request"
+ (request.xhr? ? 'layouts/xhr' : 'layouts/standard')
+ end
+ end
+ end
+
+ tests TestController
+
+ def setup
+ # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
+ # a more accurate simulation of what happens in "real life".
+ super
+ @controller.logger = Logger.new(nil)
+
+ @request.host = "www.nextangle.com"
+ end
+
+ def test_enum_rjs_test
+ pre = %[$$(".product").each(function(value, index) {
+ new Effect.Highlight(element,{});
+ new Effect.Highlight(value,{});
+ Sortable.create(value, {onUpdate:function(){new Ajax.Request('/render_other_test/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('].gsub(/^\s+/, '')
+ post = %[')})}});\nnew Draggable(value, {});\n});]
+
+ get :enum_rjs_test
+ assert_match pre, @response.body
+ assert_match post, @response.body
+ end
+
+ def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template
+ [:js, "js"].each do |format|
+ assert_nothing_raised do
+ get :render_explicit_html_template, :format => format
+ assert_equal %(document.write("Hello world\\n");), @response.body
+ end
+ end
+ end
+
+ def test_render_custom_code_rjs
+ get :render_custom_code_rjs
+ assert_response 404
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
+ end
+
+ def test_render_in_an_rjs_template_should_pick_html_templates_when_available
+ [:js, "js"].each do |format|
+ assert_nothing_raised do
+ get :render_implicit_html_template, :format => format
+ assert_equal %(document.write("Hello world\\n");), @response.body
+ end
+ end
+ end
+
+ def test_render_rjs_template_explicitly
+ get :render_js_with_explicit_template
+ assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
+ end
+
+ def test_rendering_rjs_action_explicitly
+ get :render_js_with_explicit_action_template
+ assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
+ end
+
+ def test_render_rjs_with_default
+ get :delete_with_js
+ assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
+ end
+
+ def test_update_page
+ get :update_page
+ assert_template nil
+ assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-Type']
+ assert_equal 2, @response.body.split($/).length
+ end
+
+ def test_update_page_with_instance_variables
+ get :update_page_with_instance_variables
+ assert_template nil
+ assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
+ assert_match(/balance/, @response.body)
+ assert_match(/\$37/, @response.body)
+ end
+
+ def test_update_page_with_view_method
+ get :update_page_with_view_method
+ assert_template nil
+ assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
+ assert_match(/2 people/, @response.body)
+ end
+
+ def test_should_render_html_formatted_partial_with_rjs
+ xhr :get, :partial_as_rjs
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
+ end
+
+ def test_should_render_html_formatted_partial_with_rjs_and_js_format
+ xhr :get, :respond_to_partial_as_rjs
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
+ end
+
+ def test_should_render_with_alternate_default_render
+ xhr :get, :render_alternate_default
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
+ end
+
+ def test_using_custom_render_option
+ get :render_simon_says
+ assert_equal "Simon says: foo", @response.body
+ end
+end
diff --git a/vendor/plugins/eita-jrails/test/template/prototype_helper_test.rb b/vendor/plugins/eita-jrails/test/template/prototype_helper_test.rb
new file mode 100644
index 0000000..a6aa848
--- /dev/null
+++ b/vendor/plugins/eita-jrails/test/template/prototype_helper_test.rb
@@ -0,0 +1,476 @@
+require 'abstract_unit'
+require 'active_model'
+
+class Bunny < Struct.new(:Bunny, :id)
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+ def to_key() id ? [id] : nil end
+end
+
+class Author
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ attr_reader :id
+ def to_key() id ? [id] : nil end
+ def save; @id = 1 end
+ def new_record?; @id.nil? end
+ def name
+ @id.nil? ? 'new author' : "author ##{@id}"
+ end
+end
+
+class Article
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+ attr_reader :id
+ attr_reader :author_id
+ def to_key() id ? [id] : nil end
+ def save; @id = 1; @author_id = 1 end
+ def new_record?; @id.nil? end
+ def name
+ @id.nil? ? 'new article' : "article ##{@id}"
+ end
+end
+
+class Author::Nested < Author; end
+
+
+class PrototypeHelperBaseTest < ActionView::TestCase
+ attr_accessor :formats, :output_buffer
+
+ def update_details(details)
+ @details = details
+ yield if block_given?
+ end
+
+ def setup
+ super
+ @template = self
+ end
+
+ def url_for(options)
+ if options.is_a?(String)
+ options
+ else
+ url = "http://www.example.com/"
+ url << options[:action].to_s if options and options[:action]
+ url << "?a=#{options[:a]}" if options && options[:a]
+ url << "&b=#{options[:b]}" if options && options[:a] && options[:b]
+ url
+ end
+ end
+
+ protected
+ def request_forgery_protection_token
+ nil
+ end
+
+ def protect_against_forgery?
+ false
+ end
+
+ def create_generator
+ block = Proc.new { |*args| yield(*args) if block_given? }
+ JavaScriptGenerator.new self, &block
+ end
+end
+
+class PrototypeHelperTest < PrototypeHelperBaseTest
+ def _evaluate_assigns_and_ivars() end
+
+ def setup
+ @record = @author = Author.new
+ @article = Article.new
+ super
+ end
+
+ def test_update_page
+ old_output_buffer = output_buffer
+
+ block = Proc.new { |page| page.replace_html('foo', 'bar') }
+ assert_equal create_generator(&block).to_s, update_page(&block)
+
+ assert_equal old_output_buffer, output_buffer
+ end
+
+ def test_update_page_tag
+ block = Proc.new { |page| page.replace_html('foo', 'bar') }
+ assert_equal javascript_tag(create_generator(&block).to_s), update_page_tag(&block)
+ end
+
+ def test_update_page_tag_with_html_options
+ block = Proc.new { |page| page.replace_html('foo', 'bar') }
+ assert_equal javascript_tag(create_generator(&block).to_s, {:defer => 'true'}), update_page_tag({:defer => 'true'}, &block)
+ end
+
+ def test_remote_function
+ res = remote_function(:url => authors_path, :with => "'author[name]='+$F('author_name')+'&author[dob]='+$F('author_dob')")
+ assert_equal "new Ajax.Request('/authors', {asynchronous:true, evalScripts:true, parameters:'author[name]='+$F('author_name')+'&author[dob]='+$F('author_dob')})", res
+ assert res.html_safe?
+ end
+
+ protected
+ def author_path(record)
+ "/authors/#{record.id}"
+ end
+
+ def authors_path
+ "/authors"
+ end
+
+ def author_articles_path(author)
+ "/authors/#{author.id}/articles"
+ end
+
+ def author_article_path(author, article)
+ "/authors/#{author.id}/articles/#{article.id}"
+ end
+end
+
+class JavaScriptGeneratorTest < PrototypeHelperBaseTest
+ def setup
+ super
+ @generator = create_generator
+ ActiveSupport.escape_html_entities_in_json = true
+ end
+
+ def teardown
+ ActiveSupport.escape_html_entities_in_json = false
+ end
+
+ def _evaluate_assigns_and_ivars() end
+
+ def test_insert_html_with_string
+ assert_equal 'Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" });',
+ @generator.insert_html(:top, 'element', '
This is a test
')
+ assert_equal 'Element.insert("element", { bottom: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });',
+ @generator.insert_html(:bottom, 'element', '
This is a test
')
+ assert_equal 'Element.insert("element", { before: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });',
+ @generator.insert_html(:before, 'element', '
This is a test
')
+ assert_equal 'Element.insert("element", { after: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });',
+ @generator.insert_html(:after, 'element', '
This is a test
')
+ end
+
+ def test_replace_html_with_string
+ assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E");',
+ @generator.replace_html('element', '
This is a test
')
+ end
+
+ def test_replace_element_with_string
+ assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C/p\\u003E\\u003C/div\\u003E");',
+ @generator.replace('element', '