Commit 47ab3da1 authored by dgt's avatar dgt Committed by azul

Remove obslolete prototype_rails files

Go back to schema.rb after last migration (and do not dump schema with
rails 5, because field sizes for varchars would be erased)
parent a32469f6
This diff is collapsed.
......@@ -19,15 +19,15 @@ FactoryBot.define do
sequence(:caption) { |_n| Faker::Lorem.sentence }
factory :site do
domain 'localhost'
email_sender 'robot@$current_host'
domain { 'localhost' }
email_sender { 'robot@$current_host' }
end
factory :user do
login
email
password 'foobarbaz'
password_confirmation 'foobarbaz'
password { 'foobarbaz' }
password_confirmation { 'foobarbaz' }
end
factory :group do
......@@ -47,7 +47,7 @@ FactoryBot.define do
factory :page, class: DiscussionPage do
title
summary
stars_count 0
stars_count { 0 }
created_at { generate(:created_date) }
updated_at { generate(:updated_date) }
resolved { generate(:boolean) }
......@@ -66,7 +66,7 @@ FactoryBot.define do
created_at { generate(:created_date) }
updated_at { generate(:updated_date) }
caption
version 1
version { 1 }
# association :parent_page, factory: :asset_page
factory :image_asset, class: Asset::Image do
......@@ -90,16 +90,16 @@ FactoryBot.define do
end
factory 'user_participation', class: User::Participation do
access 1
watch false
access { 1 }
watch { false }
end
factory 'group_participation', class: Group::Participation do
access 1
access { 1 }
end
factory :wiki do
version 1
version { 1 }
sequence(:body) { |_n| Faker::Lorem.paragraphs(10).join "\n" }
end
......@@ -117,11 +117,11 @@ FactoryBot.define do
factory :profile do
factory :public_profile do
stranger true
stranger { true }
end
factory :private_profile do
friend true
friend { true }
end
end
......
This diff is collapsed.
# rcov generated
coverage
# rdoc generated
rdoc
# yard generated
doc
.yardoc
# bundler
.bundle
# jeweler generated
pkg
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
# * Include files you want ignored
# * Run: git config --global core.excludesfile ~/.gitignore
#
# After doing this, these files will be ignored in all your git projects,
# saving you from having to 'pollute' every project you touch with them
#
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
#
# For MacOS:
#
#.DS_Store
#
# For TextMate
#*.tmproj
#tmtags
#
# For emacs:
#*~
#\#*
#.\#*
#
# For vim:
#*.swp
source 'https://rubygems.org'
gemspec
PATH
remote: .
specs:
prototype-rails (4.0.0)
rails (~> 5.0.7)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.7)
actionpack (= 5.0.7)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7)
actionpack (= 5.0.7)
actionview (= 5.0.7)
activejob (= 5.0.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7)
actionview (= 5.0.7)
activesupport (= 5.0.7)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7)
activesupport (= 5.0.7)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7)
activesupport (= 5.0.7)
globalid (>= 0.3.6)
activemodel (5.0.7)
activesupport (= 5.0.7)
activerecord (5.0.7)
activemodel (= 5.0.7)
activesupport (= 5.0.7)
arel (~> 7.0)
activesupport (5.0.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
builder (3.2.3)
concurrent-ruby (1.0.5)
crass (1.0.4)
erubis (2.7.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
metaclass (0.0.4)
method_source (0.9.0)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
mocha (1.7.0)
metaclass (~> 0.0.1)
nio4r (2.3.1)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
rack (2.0.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7)
actioncable (= 5.0.7)
actionmailer (= 5.0.7)
actionpack (= 5.0.7)
actionview (= 5.0.7)
activejob (= 5.0.7)
activemodel (= 5.0.7)
activerecord (= 5.0.7)
activesupport (= 5.0.7)
bundler (>= 1.3.0)
railties (= 5.0.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.0.7)
actionpack (= 5.0.7)
activesupport (= 5.0.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
mocha
prototype-rails!
BUNDLED WITH
1.16.1
Copyright (c) 2004-2013 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
prototype-rails provides Prototype, Scriptaculous, and RJS on Rails 3.1
and later.
Prototype and Scriptaculous are pulled in by the asset pipeline, so you don't
need to copy the source files into your app. You may reference them in your
s app/assets/javascripts/application.js:
//= require prototype
//= require prototype_ujs
//= require effects
//= require dragdrop
//= require controls
prototype-rails supports RJS debugging. RJS responses are wrapped to catch
exceptions, alert() them, and re-raise the exception. Debugging is disabled by
default. To enable in development, set `config.action_view.debug_rjs = true`
in config/environments/development.rb.
---
## Support for Rails 4.1 and above
Unfortunately, due to limited manpower and resources, the Rails core team has
not been able to confirm if this gem currently works with Rails 4.1 and above.
If you have found any problems while upgrading your application, please report
them at the [issue tracker](https://github.com/rails/prototype-rails/issues),
or better yet, submit patches by sending a [pull request](https://github.com/rails/prototype-rails/pulls).
In any case, this gem will *NOT* be officially supported on Rails 5.0 and above.
require 'bundler/gem_tasks'
require 'rake/testtask'
task :default => :test
Rake::TestTask.new do |t|
t.libs << 'test/lib'
t.test_files = Dir.glob('test/*_test.rb') + Dir.glob('test/{controller,template}/**/*_test.rb')
t.warning = true
t.verbose = true
end
module ActionView
module Template::Handlers
class RJS
# Default format used by RJS.
class_attribute :default_format
# see https://github.com/mileszs/wicked_pdf/pull/627
self.default_format = Mime[:js]
def call(template)
"update_page do |page|;#{template.source}\nend"
end
end
end
end
require 'rails'
require 'active_support'
module PrototypeRails
class Engine < Rails::Engine
initializer 'prototype-rails.initialize' do
ActiveSupport.on_load(:action_controller) do
require 'prototype-rails/on_load_action_controller'
end
ActiveSupport.on_load(:action_view) do
require 'prototype-rails/on_load_action_view'
end
end
end
end
require 'action_view/helpers/javascript_helper'
ActionView::Helpers::JavaScriptHelper.module_eval do
include ActionView::Helpers::PrototypeHelper
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:
# <a href="#" id="more_link" onclick="try {
# $(&quot;details&quot;).visualEffect(&quot;toggle_blind&quot;);
# $(&quot;more_link&quot;).update(&quot;Show me less&quot;);
# }
# catch (e) {
# alert('RJS error:\n\n' + e.toString());
# alert('$(\&quot;details\&quot;).visualEffect(\&quot;toggle_blind\&quot;);
# \n$(\&quot;more_link\&quot;).update(\&quot;Show me less\&quot;);');
# throw e
# };
# return false;">Show me more</a>
#
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
end
require 'prototype-rails/selector_assertions'
require 'prototype-rails/renderers'
require 'action_view/helpers/prototype_helper'
require 'action_view/helpers/scriptaculous_helper'
require 'action_view/template/handlers/rjs'
require 'prototype-rails/javascript_helper'
require 'prototype-rails/rendering'
ActionView::Base.class_eval do
cattr_accessor :debug_rjs
self.debug_rjs = false
end
ActionView::Base.class_eval do
include ActionView::Helpers::PrototypeHelper
include ActionView::Helpers::ScriptaculousHelper
end
if defined?(Rails.env) && Rails.env.test?
ActionView::TestCase.class_eval do
include ActionView::Helpers::PrototypeHelper
include ActionView::Helpers::ScriptaculousHelper
end
end
ActionView::Template.register_template_handler :rjs, ActionView::Template::Handlers::RJS.new
require 'action_controller/metal/renderers'
module ActionController
module Renderers
add :update do |proc, options|
view_context = self.view_context
generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(view_context, &proc)
self.content_type = Mime::JS
self.response_body = generator.to_s
end
end
end
\ No newline at end of file
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 :update, :render
end
require 'active_support/core_ext/module/aliasing'
require 'action_dispatch/testing/assertions'
require 'rails/dom/testing/assertions/selector_assertions'
#--
# Copyright (c) 2006 Assaf Arkin (http://labnotes.org)
# Under MIT and/or CC By license.
#++
module PrototypeRails
module SelectorAssertions
# 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 <tt>:replace</tt>, <tt>:replace_html</tt>,
# <tt>:show</tt>, <tt>:hide</tt>, <tt>:toggle</tt>, <tt>:remove</tta>,
# <tt>:insert_html</tt> and <tt>:redirect</tt>.
#
# Use the argument <tt>:insert</tt> followed by an insertion position to narrow
# down the assertion to only statements that insert elements in that
# position. Possible values are <tt>:top</tt>, <tt>:bottom</tt>, <tt>:before</tt>
# and <tt>:after</tt>.
#
# Use the argument <tt>:redirect</tt> followed by a path to check that an statement
# which redirects to the specified path is generated.
#
# Using the <tt>:remove</tt> 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 => "\\$\\(#{RJS_ANY_ID}\\)\\.replace\\(#{RJS_PATTERN_HTML}\\)",
:chained_replace_html => "\\$\\(#{RJS_ANY_ID}\\)\\.update\\(#{RJS_PATTERN_HTML}\\)",
:replace_html => "Element\\.update\\(#{RJS_ANY_ID}, #{RJS_PATTERN_HTML}\\)",
:replace => "Element\\.replace\\(#{RJS_ANY_ID}, #{RJS_PATTERN_HTML}\\)",
:redirect => "window.location.href = #{RJS_ANY_ID}"
}
[:remove, :show, :hide, :toggle].each do |action|
RJS_STATEMENTS[action] = "Element\\.#{action}\\(#{RJS_ANY_ID}\\)"
end
RJS_INSERTIONS = ["top", "bottom", "before", "after"]
RJS_INSERTIONS.each do |insertion|
RJS_STATEMENTS["insert_#{insertion}".to_sym] = "Element.insert\\(#{RJS_ANY_ID}, \\{ #{insertion}: #{RJS_PATTERN_HTML} \\}\\)"
end
RJS_STATEMENTS[:insert_html] = "Element.insert\\(#{RJS_ANY_ID}, \\{ (#{RJS_INSERTIONS.join('|')}): #{RJS_PATTERN_HTML} \\}\\)"
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
# 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
end
Gem::Specification.new do |spec|
spec.name = 'prototype-rails'
spec.version = '4.0.0'
spec.summary = 'Prototype, Scriptaculous, and RJS for Ruby on Rails'
spec.homepage = 'http://github.com/rails/prototype-rails'
spec.author = 'Xavier Noria'
spec.email = 'fxn@hashref.com'
spec.files = %w(README.md Rakefile Gemfile MIT-LICENSE) + Dir['lib/**/*', 'vendor/**/*', 'test/**/*']
spec.add_dependency('rails', '~> 5.0.7')
spec.add_development_dependency('mocha')
spec.license = "MIT"
end