tim 0.0.1
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/MIT-LICENSE +20 -0
- data/README.rdoc +392 -0
- data/Rakefile +33 -0
- data/app/assets/javascripts/tim/application.js +15 -0
- data/app/assets/stylesheets/tim/application.css +13 -0
- data/app/controllers/tim/application_controller.rb +19 -0
- data/app/controllers/tim/base_images_controller.rb +59 -0
- data/app/controllers/tim/entrypoint_controller.rb +8 -0
- data/app/controllers/tim/image_versions_controller.rb +48 -0
- data/app/controllers/tim/provider_images_controller.rb +59 -0
- data/app/controllers/tim/target_images_controller.rb +61 -0
- data/app/controllers/tim/templates_controller.rb +47 -0
- data/app/filters/tim/user_keys_filter.rb +59 -0
- data/app/helpers/tim/application_helper.rb +4 -0
- data/app/models/tim/base.rb +6 -0
- data/app/models/tim/base_image.rb +15 -0
- data/app/models/tim/image_version.rb +13 -0
- data/app/models/tim/provider_image.rb +51 -0
- data/app/models/tim/target_image.rb +50 -0
- data/app/models/tim/template.rb +19 -0
- data/app/responders/tim/custom_responder.rb +24 -0
- data/app/validators/template_validator.rb +15 -0
- data/app/views/layouts/tim/application.html.erb +14 -0
- data/app/views/tim/base_images/_base_image.xml.haml +11 -0
- data/app/views/tim/base_images/_base_image_minimal.xml.haml +2 -0
- data/app/views/tim/base_images/_form.html.erb +17 -0
- data/app/views/tim/base_images/edit.html.erb +6 -0
- data/app/views/tim/base_images/index.html.erb +17 -0
- data/app/views/tim/base_images/index.xml.haml +4 -0
- data/app/views/tim/base_images/new.html.erb +5 -0
- data/app/views/tim/base_images/show.html.erb +5 -0
- data/app/views/tim/base_images/show.xml.haml +2 -0
- data/app/views/tim/entrypoint/index.xml.haml +7 -0
- data/app/views/tim/image_versions/_form.html.erb +17 -0
- data/app/views/tim/image_versions/_image_version.xml.haml +9 -0
- data/app/views/tim/image_versions/_image_version_minimal.xml.haml +2 -0
- data/app/views/tim/image_versions/edit.html.erb +6 -0
- data/app/views/tim/image_versions/index.html.erb +17 -0
- data/app/views/tim/image_versions/index.xml.haml +4 -0
- data/app/views/tim/image_versions/new.html.erb +5 -0
- data/app/views/tim/image_versions/show.html.erb +5 -0
- data/app/views/tim/image_versions/show.xml.haml +2 -0
- data/app/views/tim/images/_form.html.erb +17 -0
- data/app/views/tim/images/edit.html.erb +6 -0
- data/app/views/tim/images/index.html.erb +21 -0
- data/app/views/tim/images/new.html.erb +5 -0
- data/app/views/tim/images/show.html.erb +5 -0
- data/app/views/tim/layouts/application.html.erb +14 -0
- data/app/views/tim/provider_images/_form.html.erb +17 -0
- data/app/views/tim/provider_images/_provider_image.xml.haml +12 -0
- data/app/views/tim/provider_images/_provider_image_minimal.xml.haml +2 -0
- data/app/views/tim/provider_images/edit.html.erb +6 -0
- data/app/views/tim/provider_images/index.html.erb +17 -0
- data/app/views/tim/provider_images/index.xml.haml +4 -0
- data/app/views/tim/provider_images/new.html.erb +5 -0
- data/app/views/tim/provider_images/show.html.erb +5 -0
- data/app/views/tim/provider_images/show.xml.haml +2 -0
- data/app/views/tim/target_images/_form.html.erb +17 -0
- data/app/views/tim/target_images/_target_image.xml.haml +13 -0
- data/app/views/tim/target_images/_target_image_minimal.xml.haml +2 -0
- data/app/views/tim/target_images/edit.html.erb +6 -0
- data/app/views/tim/target_images/index.html.erb +21 -0
- data/app/views/tim/target_images/index.xml.haml +4 -0
- data/app/views/tim/target_images/new.html.erb +5 -0
- data/app/views/tim/target_images/show.html.erb +5 -0
- data/app/views/tim/target_images/show.xml.haml +2 -0
- data/app/views/tim/templates/_form.html.erb +17 -0
- data/app/views/tim/templates/_template.xml.haml +8 -0
- data/app/views/tim/templates/_template_minimal.xml.haml +2 -0
- data/app/views/tim/templates/edit.html.erb +6 -0
- data/app/views/tim/templates/index.html.erb +17 -0
- data/app/views/tim/templates/index.xml.haml +4 -0
- data/app/views/tim/templates/new.html.erb +5 -0
- data/app/views/tim/templates/show.html.erb +5 -0
- data/app/views/tim/templates/show.xml.haml +2 -0
- data/config/cucumber.yml +8 -0
- data/config/initializers/haml.rb +1 -0
- data/config/routes.rb +9 -0
- data/config/schemas/tdl.rng +282 -0
- data/config/user_keys.yml +26 -0
- data/db/migrate/20120906180351_create_tim_base_images.rb +12 -0
- data/db/migrate/20120906210106_create_tim_image_versions.rb +10 -0
- data/db/migrate/20120910175233_create_tim_templates.rb +9 -0
- data/db/migrate/20120911202321_create_tim_target_images.rb +14 -0
- data/db/migrate/20120911204329_create_tim_provider_images.rb +19 -0
- data/lib/generators/tim/install_generator.rb +15 -0
- data/lib/generators/tim/templates/README +6 -0
- data/lib/generators/tim/templates/tim.rb +8 -0
- data/lib/image_factory/image_factory.rb +4 -0
- data/lib/image_factory/model/base.rb +88 -0
- data/lib/image_factory/model/provider_image.rb +6 -0
- data/lib/image_factory/model/target_image.rb +6 -0
- data/lib/tasks/cucumber.rake +59 -0
- data/lib/tasks/tim_tasks.rake +4 -0
- data/lib/tim.rb +8 -0
- data/lib/tim/engine.rb +9 -0
- data/lib/tim/version.rb +3 -0
- data/spec/controllers/base_images_controller_spec.rb +131 -0
- data/spec/controllers/entrypoint_controller_spec.rb +32 -0
- data/spec/controllers/image_versions_controller_spec.rb +146 -0
- data/spec/controllers/provider_images_controller_spec.rb +156 -0
- data/spec/controllers/target_images_controller_spec.rb +153 -0
- data/spec/controllers/templates_controller_spec.rb +41 -0
- data/spec/decorators/controllers/templates_controller_decorator_spec.rb +13 -0
- data/spec/factories/tim/base_image.rb +10 -0
- data/spec/factories/tim/image_factory/provider_image.rb +10 -0
- data/spec/factories/tim/image_factory/status_detail.rb +0 -0
- data/spec/factories/tim/image_factory/target_image.rb +7 -0
- data/spec/factories/tim/image_version.rb +20 -0
- data/spec/factories/tim/provider_image.rb +9 -0
- data/spec/factories/tim/target_image.rb +10 -0
- data/spec/factories/tim/template.rb +23 -0
- data/spec/filters/user_keys_filter_spec.rb +41 -0
- data/spec/fixtures/template.xml +13 -0
- data/spec/models/base_image_spec.rb +39 -0
- data/spec/models/dummy/pool_family_spec.rb +14 -0
- data/spec/models/dummy/provider_account_spec.rb +18 -0
- data/spec/models/dummy/provider_type_spec.rb +18 -0
- data/spec/models/dummy/user_spec.rb +14 -0
- data/spec/models/image_version_spec.rb +27 -0
- data/spec/models/provider_image_spec.rb +69 -0
- data/spec/models/target_image_spec.rb +75 -0
- data/spec/models/template_spec.rb +16 -0
- data/spec/spec_helper.rb +56 -0
- data/spec/support/routes.rb +41 -0
- data/spec/validators/template_validator_spec.rb +19 -0
- data/spec/views/base_images_spec.rb +23 -0
- data/spec/views/image_versions_spec.rb +25 -0
- data/spec/views/provider_images_spec.rb +30 -0
- data/spec/views/target_images_spec.rb +25 -0
- data/spec/views/templates_spec.rb +24 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/decorators/tim/controllers/templates_controller_decorator.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/pool_family.rb +3 -0
- data/test/dummy/app/models/provider_account.rb +3 -0
- data/test/dummy/app/models/provider_type.rb +3 -0
- data/test/dummy/app/models/tim/base_image.rb +6 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/tim/base_images/_custom.xml.haml +1 -0
- data/test/dummy/app/views/tim/image_versions/_custom.xml.haml +1 -0
- data/test/dummy/app/views/tim/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/tim/provider_images/_custom.xml.haml +1 -0
- data/test/dummy/app/views/tim/target_images/_custom.xml.haml +1 -0
- data/test/dummy/app/views/tim/templates/_custom.xml.haml +1 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +58 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +28 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/tim.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20120326103723532622_create_users.rb +9 -0
- data/test/dummy/db/migrate/20120423123114264114_create_pool_families.rb +7 -0
- data/test/dummy/db/migrate/20120911182850_add_pool_family_id_to_tim_base_image.rb +5 -0
- data/test/dummy/db/migrate/20120911202845_add_provider_type_id_to_tim_target_image.rb +5 -0
- data/test/dummy/db/migrate/20120911203222_create_provider_types.rb +7 -0
- data/test/dummy/db/migrate/20120911205431_create_provider_accounts.rb +7 -0
- data/test/dummy/db/schema.rb +86 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +982 -0
- data/test/dummy/log/test.log +8629 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test.rb +0 -0
- data/test/dummy/tmp/cache/assets/C7A/BB0/sprockets%2F13445f7a19078dd2df39517062aa6711 +0 -0
- data/test/dummy/tmp/cache/assets/C8C/CC0/sprockets%2F95d79f3b3096348427f3e4e38b5202e3 +0 -0
- data/test/dummy/tmp/cache/assets/CB0/2B0/sprockets%2F79106b90879c02a115d7f6f1c8390ac4 +0 -0
- data/test/dummy/tmp/cache/assets/CE0/690/sprockets%2F04c628c2a636286bfa92a4966b82b92a +0 -0
- data/test/dummy/tmp/cache/assets/D03/040/sprockets%2Fd9e94204d4b307145f12efc109b16c1f +0 -0
- data/test/dummy/tmp/cache/assets/D06/DC0/sprockets%2Fcd282851b6e4c463409ba3ece67e0510 +0 -0
- data/test/dummy/tmp/cache/assets/D23/5F0/sprockets%2F2a521f3183c6bbcd71bd26a5490b201e +0 -0
- data/test/dummy/tmp/cache/assets/D64/3A0/sprockets%2F56ac1aed10c39b12a88cb1b30f668f58 +0 -0
- data/test/dummy/tmp/cache/assets/D69/BD0/sprockets%2F0aaf75cf34556b33a9fec534fe4d0415 +0 -0
- data/test/dummy/tmp/cache/assets/D87/D80/sprockets%2Fefa3c8b210e87358c7add88cd6f49597 +0 -0
- data/test/dummy/tmp/cache/assets/D89/200/sprockets%2Ff9b4e953c874ed6a87de6490d055d9db +0 -0
- data/test/dummy/tmp/cache/assets/DF4/430/sprockets%2F403bb1de60cae4325cebd7e6c389b8ad +0 -0
- data/test/dummy/tmp/cache/assets/E00/500/sprockets%2Faaddc5b6f2cb6b98930cc54cf4c64a95 +0 -0
- data/test/dummy/tmp/cache/assets/EB3/CE0/sprockets%2Fd75a89c9fffacd99bce7eed96844eafc +0 -0
- metadata +432 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe Template do
|
|
5
|
+
describe "Model relationships" do
|
|
6
|
+
it 'should have many base images' do
|
|
7
|
+
template = FactoryGirl.build(:template)
|
|
8
|
+
2.times do
|
|
9
|
+
template.base_images << BaseImage.new
|
|
10
|
+
end
|
|
11
|
+
template.save!
|
|
12
|
+
Template.find(template).base_images.size.should == 2
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Setup Rails Envinronment
|
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
|
3
|
+
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
|
4
|
+
require File.expand_path("../../lib/image_factory/image_factory.rb", __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'rspec/rails'
|
|
7
|
+
require 'factory_girl'
|
|
8
|
+
|
|
9
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
|
10
|
+
|
|
11
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
12
|
+
# in spec/support/ and its subdirectories.
|
|
13
|
+
|
|
14
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
|
15
|
+
Dir.glob(File.join(File.dirname(__FILE__) + "/factories/", "**", "*.rb")).each do |file|
|
|
16
|
+
require file
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
config.color_enabled = true
|
|
21
|
+
config.formatter = 'documentation'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Override to_xml to use underscore rather than dash
|
|
25
|
+
ActiveRecord::Base.class_eval do
|
|
26
|
+
def to_xml(options={})
|
|
27
|
+
options[:dasherize] ||= false
|
|
28
|
+
super({ :root => self.class.name.split("::").last.underscore }.merge(options))
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
module RequestContentTypeHelper
|
|
33
|
+
def accept_all
|
|
34
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def accept_json
|
|
38
|
+
@request.env["HTTP_ACCEPT"] = "application/json"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def accept_xml
|
|
42
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def send_and_accept_xml
|
|
46
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
|
47
|
+
@request.env["CONTENT_TYPE"] = "application/xml"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def send_and_accept_json
|
|
51
|
+
@request.env["HTTP_ACCEPT"] = "application/json"
|
|
52
|
+
@request.env["CONTENT_TYPE"] = "application/json"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
include RequestContentTypeHelper
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Sets up use_route across controller tests, from:
|
|
2
|
+
# http://bit.ly/PU4Wm4 (stackoverflow)
|
|
3
|
+
|
|
4
|
+
module ControllerSetup
|
|
5
|
+
def get(action, parameters = nil, session = nil, flash = nil)
|
|
6
|
+
process_action(action, parameters, session, flash, "GET")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Executes a request simulating POST HTTP method and set/volley the
|
|
10
|
+
# response
|
|
11
|
+
def post(action, parameters = nil, session = nil, flash = nil)
|
|
12
|
+
process_action(action, parameters, session, flash, "POST")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Executes a request simulating PUT HTTP method and set/volley the
|
|
16
|
+
# response
|
|
17
|
+
def put(action, parameters = nil, session = nil, flash = nil)
|
|
18
|
+
process_action(action, parameters, session, flash, "PUT")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Executes a request simulating DELETE HTTP method and set/volley
|
|
22
|
+
# the response
|
|
23
|
+
def delete(action, parameters = nil, session = nil, flash = nil)
|
|
24
|
+
process_action(action, parameters, session, flash, "DELETE")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def process_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
|
|
30
|
+
parameters ||= {}
|
|
31
|
+
process(action, parameters.merge!(:use_route => :tim), session, flash, method)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
RSpec.configure do |c|
|
|
36
|
+
# This will include the routing helpers in the specs so that we can
|
|
37
|
+
# use base_image_path and so on to get to the routes.
|
|
38
|
+
c.include Tim::Engine.routes.url_helpers
|
|
39
|
+
# Always use the correct route for controller tests
|
|
40
|
+
c.include ControllerSetup, :type => :controller
|
|
41
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe TemplateValidator do
|
|
5
|
+
it "should not add errors on template with valid xml" do
|
|
6
|
+
template = FactoryGirl.build(:template)
|
|
7
|
+
TemplateValidator.new({}).validate(template)
|
|
8
|
+
template.errors.size.should == 0
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should add errors to template with invalid xml" do
|
|
12
|
+
template = FactoryGirl.build(:template,
|
|
13
|
+
:xml => "<invalid_template>
|
|
14
|
+
</invalid_template>")
|
|
15
|
+
TemplateValidator.new({}).validate(template)
|
|
16
|
+
template.errors.size.should > 0
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe "/tim/base_images/_base_image" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
view.stub(:base_image).and_return FactoryGirl.create(:base_image)
|
|
7
|
+
view.stub(:base_image_url)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should render custom content partial when it is defined" do
|
|
11
|
+
render
|
|
12
|
+
view.should render_template(:partial => "_custom", :count => 1)
|
|
13
|
+
Hash.from_xml(rendered)["base_image"].keys.include?("custom_content")
|
|
14
|
+
.should == true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should not fail to render when a content partial is not defined" do
|
|
18
|
+
view.controller.stub(:template_exists?).and_return false
|
|
19
|
+
render
|
|
20
|
+
view.should render_template(:partial => "_custom", :count => 0)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe "/tim/image_versions/_image_version" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
view.stub(:image_version).and_return FactoryGirl.build(:image_version)
|
|
7
|
+
[:image_version_url].each do |method|
|
|
8
|
+
view.stub(method)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should render custom content partial when it is defined" do
|
|
13
|
+
render
|
|
14
|
+
view.should render_template(:partial => "_custom", :count => 1)
|
|
15
|
+
Hash.from_xml(rendered)["image_version"].keys.include?("custom_content")
|
|
16
|
+
.should == true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should not fail to render when a content partial is not defined" do
|
|
20
|
+
view.controller.stub(:template_exists?).and_return false
|
|
21
|
+
render
|
|
22
|
+
view.should render_template(:partial => "_custom", :count => 0)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe "/tim/provider_images/_provider_image" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
Tim::TargetImage.any_instance
|
|
7
|
+
.stub(:create_factory_target_image)
|
|
8
|
+
Tim::TargetImage.any_instance.stub(:template)
|
|
9
|
+
.and_return FactoryGirl.build(:template)
|
|
10
|
+
|
|
11
|
+
view.stub(:provider_image).and_return FactoryGirl.build(:provider_image)
|
|
12
|
+
[:provider_image_url, :target_image_url].each do |method|
|
|
13
|
+
view.stub(method)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should render custom content partial when it is defined" do
|
|
18
|
+
render
|
|
19
|
+
view.should render_template(:partial => "_custom", :count => 1)
|
|
20
|
+
Hash.from_xml(rendered)["provider_image"].keys.include?("custom_content")
|
|
21
|
+
.should == true
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should not fail to render when a content partial is not defined" do
|
|
25
|
+
view.controller.stub(:template_exists?).and_return false
|
|
26
|
+
render
|
|
27
|
+
view.should render_template(:partial => "_custom", :count => 0)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe "/tim/target_images/_target_image" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
view.stub(:target_image).and_return FactoryGirl.build(:target_image)
|
|
7
|
+
[:target_image_url, :image_version_url].each do |method|
|
|
8
|
+
view.stub(method)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should render custom content partial when it is defined" do
|
|
13
|
+
render
|
|
14
|
+
view.should render_template(:partial => "_custom", :count => 1)
|
|
15
|
+
Hash.from_xml(rendered)["target_image"].keys.include?("custom_content")
|
|
16
|
+
.should == true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should not fail to render when a content partial is not defined" do
|
|
20
|
+
view.controller.stub(:template_exists?).and_return false
|
|
21
|
+
render
|
|
22
|
+
view.should render_template(:partial => "_custom", :count => 0)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Tim
|
|
4
|
+
describe "/tim/templates/_template" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
view.stub(:template).and_return FactoryGirl.create(:template)
|
|
7
|
+
[:template_url, :base_image].each do |method|
|
|
8
|
+
view.stub(method)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should render custom content partial when it is defined" do
|
|
13
|
+
render
|
|
14
|
+
view.should render_template(:partial => "_custom", :count => 1)
|
|
15
|
+
Hash.from_xml(rendered)["template"].keys.include?("custom_content").should == true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should not fail to render when a content partial is not defined" do
|
|
19
|
+
view.controller.stub(:template_exists?).and_return false
|
|
20
|
+
render
|
|
21
|
+
view.should render_template(:partial => "_custom", :count => 0)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
4
|
+
|
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
|
6
|
+
|
|
7
|
+
Dummy::Application.load_tasks
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// the compiled file.
|
|
9
|
+
//
|
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
|
12
|
+
//
|
|
13
|
+
//= require jquery
|
|
14
|
+
//= require jquery_ujs
|
|
15
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%custom_content= "custom"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%custom_content= "custom"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%custom_content= "custom"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%custom_content= "custom"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%custom_content= "custom"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
Bundler.require
|
|
6
|
+
require "tim"
|
|
7
|
+
|
|
8
|
+
module Dummy
|
|
9
|
+
class Application < Rails::Application
|
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
11
|
+
# Application configuration should go into files in config/initializers
|
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
13
|
+
|
|
14
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
16
|
+
|
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
20
|
+
|
|
21
|
+
# Activate observers that should always be running.
|
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
23
|
+
|
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
27
|
+
|
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
30
|
+
# config.i18n.default_locale = :de
|
|
31
|
+
|
|
32
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
33
|
+
config.encoding = "utf-8"
|
|
34
|
+
|
|
35
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
36
|
+
config.filter_parameters += [:password]
|
|
37
|
+
|
|
38
|
+
# Enable escaping HTML in JSON.
|
|
39
|
+
config.active_support.escape_html_entities_in_json = true
|
|
40
|
+
|
|
41
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
|
42
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|
43
|
+
# like if you have constraints or database-specific column types
|
|
44
|
+
# config.active_record.schema_format = :sql
|
|
45
|
+
|
|
46
|
+
# Enforce whitelist mode for mass assignment.
|
|
47
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
|
48
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
|
49
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
|
50
|
+
config.active_record.whitelist_attributes = true
|
|
51
|
+
|
|
52
|
+
# Enable the asset pipeline
|
|
53
|
+
config.assets.enabled = true
|
|
54
|
+
|
|
55
|
+
# Version of your assets, change this if you want to expire all your assets
|
|
56
|
+
config.assets.version = '1.0'
|
|
57
|
+
end
|
|
58
|
+
end
|