jquery_on_rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +48 -50
- data/VERSION +1 -1
- data/jquery_on_rails.gemspec +22 -6
- data/lib/jquery_on_rails/helpers/jquery_helper.rb +2 -2
- data/spec/dummy/app/controllers/dummy_controller.rb +5 -0
- data/spec/dummy/app/helpers/dummy_helper.rb +2 -0
- data/spec/dummy/config/application.rb +16 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/test.rb +0 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/jquery_helper_spec.rb +79 -0
- data/spec/jquery_on_rails_spec.rb +8 -3
- data/spec/spec_helper.rb +18 -8
- metadata +24 -6
- data/spec/spec.opts +0 -1
data/Rakefile
CHANGED
@@ -1,51 +1,49 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "jquery_on_rails"
|
8
|
-
gem.summary = %Q{JQuery on Rails - Replace prototype/scriptaculous with jquery}
|
9
|
-
gem.description = %Q{A complete replacement for Rails 3 javascript helpers and unobstrusive javacript (ujs) using JQuery instead of prototype/scriptaculous}
|
10
|
-
gem.email = "joe@ankhcraft.com"
|
11
|
-
gem.homepage = "http://github.com/joekhoobyar/jquery_on_rails"
|
12
|
-
gem.authors = ["Joe Khoobyar"]
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "jquery_on_rails"
|
8
|
+
gem.summary = %Q{JQuery on Rails - Replace prototype/scriptaculous with jquery}
|
9
|
+
gem.description = %Q{A complete replacement for Rails 3 javascript helpers and unobstrusive javacript (ujs) using JQuery instead of prototype/scriptaculous}
|
10
|
+
gem.email = "joe@ankhcraft.com"
|
11
|
+
gem.homepage = "http://github.com/joekhoobyar/jquery_on_rails"
|
12
|
+
gem.authors = ["Joe Khoobyar"]
|
13
13
|
gem.files = Dir["{lib,public,spec}/**/*", "{bin}/*", "*"]
|
14
|
-
gem.rubyforge_project = "jquery_on_rails"
|
15
|
-
gem.add_dependency "actionpack", ">= 3.0.0.beta1"
|
16
|
-
gem.add_development_dependency "rspec", ">=
|
17
|
-
# gem
|
18
|
-
|
19
|
-
|
20
|
-
Jeweler::
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
spec.
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
spec.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
task :
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
rdoc.
|
48
|
-
rdoc.
|
49
|
-
|
50
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
-
end
|
14
|
+
gem.rubyforge_project = "jquery_on_rails"
|
15
|
+
gem.add_dependency "actionpack", ">= 3.0.0.beta1"
|
16
|
+
gem.add_development_dependency "rspec", ">= 2.0.0.beta.8"
|
17
|
+
# gem.add_development_dependency "rspec-rails", ">= 2.0.0.beta.8"
|
18
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
22
|
+
rubyforge.doc_task = "rdoc"
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
Rspec::Core::RakeTask.new(:rspec) do |spec|
|
30
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
31
|
+
end
|
32
|
+
Rspec::Core::RakeTask.new(:rcov) do |spec|
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
end
|
36
|
+
|
37
|
+
task :rspec => :check_dependencies
|
38
|
+
|
39
|
+
task :default => :rspec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "jquery_on_rails #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/jquery_on_rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jquery_on_rails}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joe Khoobyar"]
|
@@ -27,8 +27,16 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/jquery_on_rails/railtie.rb",
|
28
28
|
"public/javascripts/jquery.js",
|
29
29
|
"public/javascripts/rails.js",
|
30
|
+
"spec/dummy/app/controllers/dummy_controller.rb",
|
31
|
+
"spec/dummy/app/helpers/dummy_helper.rb",
|
32
|
+
"spec/dummy/config/application.rb",
|
33
|
+
"spec/dummy/config/boot.rb",
|
34
|
+
"spec/dummy/config/environment.rb",
|
35
|
+
"spec/dummy/config/environments/test.rb",
|
36
|
+
"spec/dummy/config/routes.rb",
|
37
|
+
"spec/dummy/log/test.log",
|
38
|
+
"spec/jquery_helper_spec.rb",
|
30
39
|
"spec/jquery_on_rails_spec.rb",
|
31
|
-
"spec/spec.opts",
|
32
40
|
"spec/spec_helper.rb"
|
33
41
|
]
|
34
42
|
s.homepage = %q{http://github.com/joekhoobyar/jquery_on_rails}
|
@@ -38,7 +46,15 @@ Gem::Specification.new do |s|
|
|
38
46
|
s.rubygems_version = %q{1.3.6}
|
39
47
|
s.summary = %q{JQuery on Rails - Replace prototype/scriptaculous with jquery}
|
40
48
|
s.test_files = [
|
41
|
-
"spec/
|
49
|
+
"spec/dummy/app/controllers/dummy_controller.rb",
|
50
|
+
"spec/dummy/app/helpers/dummy_helper.rb",
|
51
|
+
"spec/dummy/config/application.rb",
|
52
|
+
"spec/dummy/config/boot.rb",
|
53
|
+
"spec/dummy/config/environment.rb",
|
54
|
+
"spec/dummy/config/environments/test.rb",
|
55
|
+
"spec/dummy/config/routes.rb",
|
56
|
+
"spec/jquery_helper_spec.rb",
|
57
|
+
"spec/jquery_on_rails_spec.rb",
|
42
58
|
"spec/spec_helper.rb"
|
43
59
|
]
|
44
60
|
|
@@ -48,14 +64,14 @@ Gem::Specification.new do |s|
|
|
48
64
|
|
49
65
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
66
|
s.add_runtime_dependency(%q<actionpack>, [">= 3.0.0.beta1"])
|
51
|
-
s.add_development_dependency(%q<rspec>, [">=
|
67
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
|
52
68
|
else
|
53
69
|
s.add_dependency(%q<actionpack>, [">= 3.0.0.beta1"])
|
54
|
-
s.add_dependency(%q<rspec>, [">=
|
70
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
|
55
71
|
end
|
56
72
|
else
|
57
73
|
s.add_dependency(%q<actionpack>, [">= 3.0.0.beta1"])
|
58
|
-
s.add_dependency(%q<rspec>, [">=
|
74
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
|
59
75
|
end
|
60
76
|
end
|
61
77
|
|
@@ -273,8 +273,8 @@ module JQueryOnRails
|
|
273
273
|
"}"
|
274
274
|
end
|
275
275
|
|
276
|
-
if !(FalseClass === options[:protect_against_forgery
|
277
|
-
|
276
|
+
if !(FalseClass === options[:protect_against_forgery]) and
|
277
|
+
protect_against_forgery? and !options[:form]
|
278
278
|
then
|
279
279
|
if js_options['data']
|
280
280
|
js_options['data'] << " + '&"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_dispatch/railtie"
|
4
|
+
require "action_controller/railtie"
|
5
|
+
require "action_view/railtie"
|
6
|
+
|
7
|
+
require 'jquery_on_rails'
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
config.root = File.expand_path '../../', __FILE__
|
12
|
+
config.secret_token = 'abcdefghijklmnopqrstuvwxyz0123456789'
|
13
|
+
config.session_store :cookie_store, :key => '_dummy_session'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
File without changes
|
File without changes
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require 'dummy_controller'
|
4
|
+
|
5
|
+
describe JQueryOnRails::Helpers::JQueryHelper do
|
6
|
+
before(:each) do
|
7
|
+
@t = DummyController.new.tap do |c|
|
8
|
+
c.request = ActionDispatch::Request.new Rack::MockRequest.env_for('/dummy')
|
9
|
+
end.view_context
|
10
|
+
end
|
11
|
+
|
12
|
+
it "overrides all instance methods ActionView::Helpers::PrototypeHelper" do
|
13
|
+
(ActionView::Helpers::PrototypeHelper.instance_methods -
|
14
|
+
JQueryOnRails::Helpers::JQueryHelper.instance_methods).should == []
|
15
|
+
end
|
16
|
+
it "overrides all instance methods ActionView::Helpers::ScriptaculousHelper" do
|
17
|
+
return pending("not yet implemented")
|
18
|
+
(ActionView::Helpers::ScriptaculousHelper.instance_methods -
|
19
|
+
JQueryOnRails::Helpers::JQueryHelper.instance_methods).should == []
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#options_for_javascript' do
|
23
|
+
before(:each) do
|
24
|
+
@t.singleton_class.instance_eval{ public :options_for_javascript }
|
25
|
+
end
|
26
|
+
|
27
|
+
it "handles empty options" do
|
28
|
+
@t.options_for_javascript({}).should == '{}'
|
29
|
+
end
|
30
|
+
it "orders options deterministically" do
|
31
|
+
@t.options_for_javascript(:b=>1,:c=>3,:a=>2).should == '{a:2, b:1, c:3}'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#remote_function' do
|
36
|
+
it "calls jQuery.ajax" do
|
37
|
+
# jQuery.ajax({async:true, ... method:'GET', processData:false, ... })
|
38
|
+
@t.remote_function(:url=>'/foo').should =~ /jQuery\.ajax\(.*.*\)/
|
39
|
+
end
|
40
|
+
it "is asynchronous by default" do
|
41
|
+
@t.remote_function(:url=>'/foo').should =~ /async: *true/
|
42
|
+
end
|
43
|
+
it "can be explicitly synchronous" do
|
44
|
+
@t.remote_function(:url=>'/foo', :type=>:synchronous).should =~ /async: *false/
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'request forgery protection' do
|
48
|
+
before(:each) do
|
49
|
+
@regex = /data: *'#{@t.request_forgery_protection_token}=' *\+ *encodeURIComponent/
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is included by default" do
|
53
|
+
@t.remote_function(:url=>'/foo').should =~ @regex
|
54
|
+
end
|
55
|
+
it "can be explicitly omitted" do
|
56
|
+
@t.remote_function(:url=>'/foo', :protect_against_forgery=>false).should_not =~ @regex
|
57
|
+
end
|
58
|
+
it "is omitted when :form is given" do
|
59
|
+
@t.remote_function(:url=>'/foo', :form=>true).should_not =~ @regex
|
60
|
+
end
|
61
|
+
end
|
62
|
+
describe ':url' do
|
63
|
+
it "accepts a string" do
|
64
|
+
@t.remote_function(:url=>'/foo').should =~ /url: *'\/foo'/
|
65
|
+
end
|
66
|
+
it "accepts a hash" do
|
67
|
+
@t.remote_function(:url=>{:controller=>'dummy', :action=>'index'}).should =~ /url: *'\/dummy'/
|
68
|
+
end
|
69
|
+
end
|
70
|
+
describe ':method' do
|
71
|
+
it "defaults to GET" do
|
72
|
+
@t.remote_function(:url=>'/foo').should =~ /method: *'GET'/
|
73
|
+
end
|
74
|
+
it "is capitalized" do
|
75
|
+
@t.remote_function(:url=>'/foo', :method=>:post).should =~ /method: *'POST'/
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe "
|
4
|
-
|
5
|
-
|
3
|
+
describe "JQueryOnRails" do
|
4
|
+
|
5
|
+
it "should not screw up the VERSION" do
|
6
|
+
JQueryOnRails.constants.should be_include('VERSION')
|
7
|
+
version_file = File.expand_path '../../VERSION', __FILE__
|
8
|
+
File.should be_exists(version_file)
|
9
|
+
JQueryOnRails::VERSION.should == File.read(version_file).strip
|
6
10
|
end
|
11
|
+
|
7
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
begin require 'win32console' and include Win32::Console::ANSI
|
5
|
+
rescue LoadError
|
6
|
+
end if RUBY_PLATFORM =~ /msvc|mingw|cygwin|win32/
|
7
|
+
|
8
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
9
|
+
require "rails/test_help"
|
10
|
+
require "rspec"
|
11
|
+
#require "rspec/rails"
|
12
|
+
|
13
|
+
Rails.backtrace_cleaner.remove_silencers!
|
14
|
+
|
15
|
+
Rspec.configure do |config|
|
16
|
+
require 'rspec/expectations'
|
17
|
+
config.include Rspec::Matchers
|
18
|
+
config.mock_with :rspec
|
9
19
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joe Khoobyar
|
@@ -40,10 +40,12 @@ dependencies:
|
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
segments:
|
43
|
-
- 1
|
44
43
|
- 2
|
45
|
-
-
|
46
|
-
|
44
|
+
- 0
|
45
|
+
- 0
|
46
|
+
- beta
|
47
|
+
- 8
|
48
|
+
version: 2.0.0.beta.8
|
47
49
|
type: :development
|
48
50
|
version_requirements: *id002
|
49
51
|
description: A complete replacement for Rails 3 javascript helpers and unobstrusive javacript (ujs) using JQuery instead of prototype/scriptaculous
|
@@ -66,8 +68,16 @@ files:
|
|
66
68
|
- lib/jquery_on_rails/railtie.rb
|
67
69
|
- public/javascripts/jquery.js
|
68
70
|
- public/javascripts/rails.js
|
71
|
+
- spec/dummy/app/controllers/dummy_controller.rb
|
72
|
+
- spec/dummy/app/helpers/dummy_helper.rb
|
73
|
+
- spec/dummy/config/application.rb
|
74
|
+
- spec/dummy/config/boot.rb
|
75
|
+
- spec/dummy/config/environment.rb
|
76
|
+
- spec/dummy/config/environments/test.rb
|
77
|
+
- spec/dummy/config/routes.rb
|
78
|
+
- spec/dummy/log/test.log
|
79
|
+
- spec/jquery_helper_spec.rb
|
69
80
|
- spec/jquery_on_rails_spec.rb
|
70
|
-
- spec/spec.opts
|
71
81
|
- spec/spec_helper.rb
|
72
82
|
has_rdoc: true
|
73
83
|
homepage: http://github.com/joekhoobyar/jquery_on_rails
|
@@ -100,5 +110,13 @@ signing_key:
|
|
100
110
|
specification_version: 3
|
101
111
|
summary: JQuery on Rails - Replace prototype/scriptaculous with jquery
|
102
112
|
test_files:
|
113
|
+
- spec/dummy/app/controllers/dummy_controller.rb
|
114
|
+
- spec/dummy/app/helpers/dummy_helper.rb
|
115
|
+
- spec/dummy/config/application.rb
|
116
|
+
- spec/dummy/config/boot.rb
|
117
|
+
- spec/dummy/config/environment.rb
|
118
|
+
- spec/dummy/config/environments/test.rb
|
119
|
+
- spec/dummy/config/routes.rb
|
120
|
+
- spec/jquery_helper_spec.rb
|
103
121
|
- spec/jquery_on_rails_spec.rb
|
104
122
|
- spec/spec_helper.rb
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|