ajaxlibs 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.6
@@ -6,7 +6,6 @@ module Ajaxlibs::IncludesHelper
6
6
  # == Options
7
7
  # * <tt>version</tt> : specify the version to use for each library
8
8
  # * <tt>local</tt> : if true, always serve file locally, if false, use Google CDN
9
- # * <tt>remote</tt> : if false, always serve file locally, if true, use Google CDN
10
9
  #
11
10
  # == Exceptions
12
11
  # * <tt>Ajaxlibs::Exception::LibraryNotFound</tt> : raised if one or more of the given library is not available
@@ -50,8 +49,9 @@ module Ajaxlibs::IncludesHelper
50
49
  def javascript_include_library(library, options)
51
50
  library = library.to_sym
52
51
  version = options.delete(:version)
53
- source = (options[:local] === true or RAILS_ENV != 'production') ? :local : :remote
54
- ajaxlib = Ajaxlibs::Library.by_name(library, :version => version, :source => source)
52
+ local = options.delete(:local)
53
+ options[:source] ||= (local === true or (local.nil? and RAILS_ENV != 'production')) ? :local : :remote
54
+ ajaxlib = Ajaxlibs::Library.by_name(library, options.merge({:version => version}))
55
55
 
56
56
  @included_javascript_libraries ||= []
57
57
 
@@ -61,7 +61,7 @@ module Ajaxlibs::IncludesHelper
61
61
  result = []
62
62
 
63
63
  ajaxlib.requires.each do |required_library, required_version|
64
- result << javascript_include_library(required_library, :version => required_version)
64
+ result << javascript_include_library(required_library, options.merge({:version => required_version}))
65
65
  end
66
66
 
67
67
  result << ajaxlib
@@ -69,6 +69,15 @@ describe "Ajaxlibs::IncludesHelper" do
69
69
  end
70
70
  end # end of context "while specifying a specific version number"
71
71
  end # end of context "should call javascript_include_tag to include local javascript library file"
72
+
73
+ example "should call javascript_include_tag with google cdn include path if specified source is remote" do
74
+ @fake_action_view.should_receive(:javascript_include_tag).
75
+ with(Ajaxlibs::Library.by_name(:prototype).google_cdn_include_path).
76
+ once
77
+
78
+ @fake_action_view.ajaxlibs_include :prototype, :local => false
79
+ end
80
+
72
81
  end # end of context "in development environment"
73
82
 
74
83
  context "in production environment" do
@@ -108,7 +117,15 @@ describe "Ajaxlibs::IncludesHelper" do
108
117
  once
109
118
 
110
119
  @fake_action_view.ajaxlibs_include :prototype, :prototype
111
- end
120
+ end
121
+
122
+ example "using a secured connection if secured was specified" do
123
+ @fake_action_view.should_receive(:javascript_include_tag).
124
+ with(Ajaxlibs::Library.by_name(:prototype, :secure => true).google_cdn_include_path).
125
+ once
126
+
127
+ @fake_action_view.ajaxlibs_include :prototype, :secure => true
128
+ end
112
129
 
113
130
  context "while specifying a specific version number" do
114
131
  example "once if one library was specified" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 4
9
- version: 0.1.4
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Fabien Jakimowicz