chosen_template 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +0 -2
  4. data/README.md +26 -1
  5. data/Rakefile +0 -2
  6. data/chosen_template.gemspec +4 -3
  7. data/lib/chosen_template.rb +4 -26
  8. data/lib/chosen_template/action_controller_extensions.rb +13 -0
  9. data/lib/chosen_template/active_record_extensions.rb +30 -0
  10. data/lib/chosen_template/choosable_template_controller.rb +23 -0
  11. data/lib/chosen_template/version.rb +1 -1
  12. data/spec/controllers/styles_controller_spec.rb +31 -0
  13. data/spec/dummy/Rakefile +7 -0
  14. data/spec/dummy/app/assets/javascripts/application.js +2 -0
  15. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  16. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  17. data/spec/dummy/app/controllers/styles_controller.rb +6 -0
  18. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  19. data/spec/dummy/app/mailers/.gitkeep +0 -0
  20. data/spec/{support/models/body_styles.rb → dummy/app/models/body_style.rb} +0 -0
  21. data/spec/{support → dummy/app}/models/page.rb +0 -0
  22. data/spec/{support → dummy/app}/models/page_template.rb +0 -0
  23. data/spec/{support → dummy/app}/models/style.rb +0 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  25. data/spec/dummy/config.ru +4 -0
  26. data/spec/dummy/config/application.rb +44 -0
  27. data/spec/dummy/config/boot.rb +10 -0
  28. data/{db/config.yml → spec/dummy/config/database.yml} +1 -0
  29. data/spec/dummy/config/environment.rb +5 -0
  30. data/spec/dummy/config/environments/development.rb +30 -0
  31. data/spec/dummy/config/environments/production.rb +60 -0
  32. data/spec/dummy/config/environments/test.rb +39 -0
  33. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  34. data/spec/dummy/config/initializers/inflections.rb +10 -0
  35. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  36. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  37. data/spec/dummy/config/initializers/session_store.rb +8 -0
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  39. data/spec/dummy/config/locales/en.yml +5 -0
  40. data/spec/dummy/config/routes.rb +11 -0
  41. data/{db → spec/dummy/db}/migrate/20130526013748_create_pages.rb +0 -0
  42. data/{db → spec/dummy/db}/migrate/20130526014011_create_page_templates.rb +0 -0
  43. data/{db → spec/dummy/db}/migrate/20130526024132_create_styles.rb +0 -0
  44. data/{db → spec/dummy/db}/migrate/20130526033402_create_body_styles.rb +0 -0
  45. data/{db → spec/dummy/db}/schema.rb +0 -0
  46. data/spec/dummy/db/seeds.rb +15 -0
  47. data/spec/dummy/lib/assets/.gitkeep +0 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +26 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/script/rails +6 -0
  53. data/spec/{page_spec.rb → models/page_spec.rb} +0 -0
  54. data/spec/{page_template_spec.rb → models/page_template_spec.rb} +0 -0
  55. data/spec/spec_helper.rb +7 -5
  56. metadata +116 -33
  57. data/spec/support/active_record.rb +0 -5
  58. data/spec/support/loader.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bd2af944e89c815d3deb3b3f222c7cc804e390d
4
- data.tar.gz: 6cc2961f080696772814efdcff3d4b33b5a61cf9
3
+ metadata.gz: 96b0a6dd651209a42b4ee3fe1e841a6f9cded28f
4
+ data.tar.gz: 665535bfce3cf4ccb450ae556b487db5d36395ce
5
5
  SHA512:
6
- metadata.gz: 7de56b38e4ba3053e6362507b168249b234b930931c46a0530911df2f7cfdd9fc873edbd5765a456198bb6fadbd6465bfbdd7845426e37db825ee5811582766f
7
- data.tar.gz: ba1de32277dbff9fad3a34200cce1b2b1540ea079cbd8a7094587f3db8fe922568293c9ee60f0527af9f6fb6370f5c6b8fa97c485f91742abbf6fd3b90fd6707
6
+ metadata.gz: 3df17c7eb744b14b05b0cd1a10af32538d09f006a823f9bd79dcfb7d5052ef9ac647f7f6b41126b5483c8099c230e0a4c51becb60f3c09e045359cd25ccf4d27
7
+ data.tar.gz: ea03bd86b44c1d64c36bdd7171420831b567b6bb461d5687d06bc229a2a77d4ea5902a0411141caffcb82b79902433f7d14e69e45cbbd72582a97b0c37855530
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- db/*.sqlite3
18
+ spec/dummy/db/*.sqlite3
19
+ spec/dummy/log/*
data/Gemfile CHANGED
@@ -4,7 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'database_cleaner'
8
- gem 'timecop'
9
7
  gem 'pry'
10
8
  end
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ ### Models
24
+
23
25
  The item that can be preview and published:
24
26
 
25
27
  class PageTemplate < ActiveRecord::Base
@@ -64,12 +66,35 @@ Other useful scopes that can be called on the collection of templates:
64
66
  - `by_template_published_at` returns templates ordered by the date they were published, from most newest to oldest
65
67
  - `by_template_previewed_at` returns templates ordered by the date they were previewed, from most newest to oldest
66
68
 
69
+ ### Controllers
70
+
71
+ If you want to have specific actions on your controllers to preview and publish, do the following:
72
+
73
+ class PageTemplateController < ApplicationController
74
+ choosable_templates
75
+ end
76
+
77
+ That gives you the following actions:
78
+
79
+ - PUT #preview_template
80
+ - PUT #publish_template
81
+
82
+ Remember, to get this to work you still have to add the route:
83
+
84
+ resources :page_templates do
85
+ member do
86
+ put :preview_template
87
+ put :publish_template
88
+ end
89
+ end
90
+
67
91
  ## Running Specs
68
92
 
69
93
  In the root folder:
70
94
 
71
95
  bundle install
72
- rake db:migrate DB=test
96
+ cd spec/dummy
97
+ rake db:migrate db:test:prepare
73
98
  rspec spec
74
99
 
75
100
  ## Contributing
data/Rakefile CHANGED
@@ -1,3 +1 @@
1
1
  require "bundler/gem_tasks"
2
- require 'standalone_migrations'
3
- StandaloneMigrations::Tasks.load_tasks
@@ -21,9 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec", ">= 2.13.0"
24
+ spec.add_development_dependency "rspec-rails", ">= 2.13.0"
24
25
  spec.add_development_dependency "factory_girl", "~> 4.2.0"
25
26
  spec.add_development_dependency 'sqlite3'
26
- spec.add_development_dependency 'standalone_migrations', '~> 2.1.1'
27
- spec.add_dependency "activerecord", ">= 3.0.0"
28
- spec.add_dependency "activesupport", ">= 3.0.0"
27
+ spec.add_development_dependency 'timecop'
28
+ spec.add_development_dependency 'database_cleaner'
29
+ spec.add_dependency "rails", ">= 3.0.0"
29
30
  end
@@ -4,32 +4,10 @@ require 'active_support/inflector'
4
4
  require "chosen_template/version"
5
5
  require 'chosen_template/chooser'
6
6
  require 'chosen_template/chosen'
7
+ require 'chosen_template/choosable_template_controller'
7
8
 
8
- module ChosenTemplate
9
- CHOOSABLE_REQUIRED_COLUMNS = [:template_published_at, :template_previewed_at]
10
-
11
- extend ActiveSupport::Concern
12
-
13
- module ClassMethods
14
- def chooses_templates(*template_choices)
15
- cattr_accessor :template_choices
16
- self.template_choices = template_choices
17
- include Chooser
18
- end
19
-
20
- def choosable_template(options={})
21
- cattr_accessor :chosen_by
22
- self.chosen_by = options[:by]
23
-
24
- CHOOSABLE_REQUIRED_COLUMNS.each do |column_name|
25
- unless self.column_names.include?(column_name.to_s)
26
- raise ArgumentError, "`#{self.table_name}` requires the `#{column_name}` column"
27
- end
28
- end
29
- include Chosen
30
- end
31
- end
9
+ require 'chosen_template/active_record_extensions'
10
+ require 'chosen_template/action_controller_extensions'
32
11
 
12
+ module ChosenTemplate
33
13
  end
34
-
35
- ActiveRecord::Base.send :include, ChosenTemplate
@@ -0,0 +1,13 @@
1
+ module ChosenTemplate
2
+ module ActionControllerExtensions
3
+
4
+ extend ActiveSupport::Concern
5
+
6
+ def choosable_templates
7
+ include ChosenTemplate::ChoosableTemplateController
8
+ end
9
+
10
+ end
11
+ end
12
+
13
+ ActionController::Base.extend ChosenTemplate::ActionControllerExtensions
@@ -0,0 +1,30 @@
1
+ module ChosenTemplate
2
+ module ActiveRecordExtensions
3
+
4
+ CHOOSABLE_REQUIRED_COLUMNS = [:template_published_at, :template_previewed_at]
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ def chooses_templates(*template_choices)
9
+ cattr_accessor :template_choices
10
+ self.template_choices = template_choices
11
+ include Chooser
12
+ end
13
+
14
+ def choosable_template(options={})
15
+ cattr_accessor :chosen_by
16
+ self.chosen_by = options[:by]
17
+
18
+ CHOOSABLE_REQUIRED_COLUMNS.each do |column_name|
19
+ unless self.column_names.include?(column_name.to_s)
20
+ raise ArgumentError, "`#{self.table_name}` requires the `#{column_name}` column"
21
+ end
22
+ end
23
+ include Chosen
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+
30
+ ActiveRecord::Base.send :include, ChosenTemplate::ActiveRecordExtensions
@@ -0,0 +1,23 @@
1
+ module ChosenTemplate
2
+ module ChoosableTemplateController
3
+
4
+ def preview_template
5
+ template = template_model_class.find(params[:id])
6
+ template.update_attributes(template_previewed_at: Time.now)
7
+ respond_with template, params.slice(:location)
8
+ end
9
+
10
+ def publish_template
11
+ template = template_model_class.find(params[:id])
12
+ template.update_attributes(template_published_at: Time.now)
13
+ respond_with template, params.slice(:location)
14
+ end
15
+
16
+ protected
17
+
18
+ def template_model_class
19
+ @template_model_class ||= self.controller_name.classify.constantize
20
+ end
21
+
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module ChosenTemplate
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe StylesController, type: :controller do
4
+
5
+ describe 'PUT #preview_template' do
6
+ it 'should update the style#template_previewed_at to now' do
7
+ Timecop.freeze
8
+ style = build_stubbed(:style)
9
+ Style.stub(:find).with(style.id.to_s) { style }
10
+ style.should_receive(:update_attributes).
11
+ with(template_previewed_at: Time.now)
12
+ location = "http:://somewhereelse.com"
13
+ put :preview_template, id: style.id, location: location
14
+ response.should redirect_to(location)
15
+ end
16
+ end
17
+
18
+ describe 'PUT #publish_template' do
19
+ it 'should update the style#template_published_at to now' do
20
+ Timecop.freeze
21
+ style = build_stubbed(:style)
22
+ Style.stub(:find).with(style.id.to_s) { style }
23
+ style.should_receive(:update_attributes).
24
+ with(template_published_at: Time.now)
25
+ location = "http:://somewhereelse.com"
26
+ put :publish_template, id: style.id, location: location
27
+ response.should redirect_to(location)
28
+ end
29
+ end
30
+
31
+ end
@@ -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,2 @@
1
+ // Place your application-specific JavaScript functions and classes here
2
+ // This file is automatically included by javascript_include_tag :defaults
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,6 @@
1
+ class StylesController < ApplicationController
2
+ respond_to :html
3
+
4
+ choosable_templates
5
+
6
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag 'application' %>
7
+ <%= csrf_meta_tag %>
8
+ <%= yield :header %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+
7
+ module Dummy
8
+ class Application < Rails::Application
9
+ # Settings in config/environments/* take precedence over those specified here.
10
+ # Application configuration should go into files in config/initializers
11
+ # -- all .rb files in that directory are automatically loaded.
12
+
13
+ # Custom directories with classes and modules you want to be autoloadable.
14
+ # config.autoload_paths += %W(#{config.root}/extras)
15
+
16
+ # Only load the plugins named here, in the order given (default is alphabetical).
17
+ # :all can be used as a placeholder for all plugins not explicitly named.
18
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
19
+
20
+ # Activate observers that should always be running.
21
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
22
+
23
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
24
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
25
+ # config.time_zone = 'Central Time (US & Canada)'
26
+
27
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
28
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
29
+ # config.i18n.default_locale = :de
30
+
31
+ # Configure the default encoding used in templates for Ruby 1.9.
32
+ config.encoding = "utf-8"
33
+
34
+ # Configure sensitive parameters which will be filtered from the log file.
35
+ config.filter_parameters += [:password]
36
+
37
+ # Enable the asset pipeline
38
+ config.assets.enabled = true
39
+
40
+ # Version of your assets, change this if you want to expire all your assets
41
+ config.assets.version = '1.0'
42
+ end
43
+ end
44
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -9,3 +9,4 @@ test: &test
9
9
  database: db/test.sqlite3
10
10
  pool: 5
11
11
  timeout: 5000
12
+
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,30 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = true
30
+ end
@@ -0,0 +1,60 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to Rails.root.join("public/assets")
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Use a different logger for distributed setups
37
+ # config.logger = SyslogLogger.new
38
+
39
+ # Use a different cache store in production
40
+ # config.cache_store = :mem_cache_store
41
+
42
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
+ # config.action_controller.asset_host = "http://assets.example.com"
44
+
45
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
+ # config.assets.precompile += %w( search.js )
47
+
48
+ # Disable delivery errors, bad email addresses will be ignored
49
+ # config.action_mailer.raise_delivery_errors = false
50
+
51
+ # Enable threaded mode
52
+ # config.threadsafe!
53
+
54
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
+ # the I18n.default_locale when a translation can not be found)
56
+ config.i18n.fallbacks = true
57
+
58
+ # Send deprecation notices to registered listeners
59
+ config.active_support.deprecation = :notify
60
+ end
@@ -0,0 +1,39 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
33
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
34
+ # like if you have constraints or database-specific column types
35
+ # config.active_record.schema_format = :sql
36
+
37
+ # Print deprecation notices to the stderr
38
+ config.active_support.deprecation = :stderr
39
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = '8e022862346d535cb24318751060f3deb41ae4de345e0ee5a827fe9108d13f4927b2b4b51e22e7dd74d68646202b378b97f521b565620822157aa3455764b235'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters :format => [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,11 @@
1
+ Rails.application.routes.draw do
2
+ resources :pages
3
+ resources :page_templates
4
+ resources :styles do
5
+ member do
6
+ put :preview_template
7
+ put :publish_template
8
+ end
9
+ end
10
+ resources :body_styles
11
+ end
File without changes
@@ -0,0 +1,15 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
8
+
9
+ require '../../spec/blueprints'
10
+
11
+ Factory :page, :name => "Home"
12
+ Factory :page, :name => "About"
13
+
14
+ Factory :category, :name => "Cars"
15
+ Factory :category, :name => "Animals"
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
File without changes
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,13 @@
1
+ ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2
+ SPEC_DIR = File.expand_path(File.dirname(__FILE__))
3
+
4
+ require File.join(SPEC_DIR, 'dummy', 'config', 'environment')
1
5
  require 'rspec'
6
+ require 'rspec/rails'
2
7
  require 'bundler/setup'
3
- require 'active_record'
4
8
  require 'chosen_template'
5
9
 
6
- ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
7
- SPEC_DIR = File.expand_path(File.dirname(__FILE__))
8
-
9
- Bundler.require(:test)
10
+ Bundler.require(:test, :development)
10
11
 
11
12
  Dir[File.join(SPEC_DIR, 'support', "**/*.rb")].each do |f|
12
13
  require f
@@ -28,6 +29,7 @@ RSpec.configure do |config|
28
29
 
29
30
  config.after do
30
31
  DatabaseCleaner.clean
32
+ Timecop.return
31
33
  end
32
34
 
33
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chosen_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: factory_girl
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,35 +95,35 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: standalone_migrations
98
+ name: timecop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ~>
101
+ - - '>='
88
102
  - !ruby/object:Gem::Version
89
- version: 2.1.1
103
+ version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ~>
108
+ - - '>='
95
109
  - !ruby/object:Gem::Version
96
- version: 2.1.1
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: activerecord
112
+ name: database_cleaner
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - '>='
102
116
  - !ruby/object:Gem::Version
103
- version: 3.0.0
104
- type: :runtime
117
+ version: '0'
118
+ type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - '>='
109
123
  - !ruby/object:Gem::Version
110
- version: 3.0.0
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: activesupport
126
+ name: rails
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - '>='
@@ -135,28 +149,61 @@ files:
135
149
  - README.md
136
150
  - Rakefile
137
151
  - chosen_template.gemspec
138
- - db/config.yml
139
- - db/migrate/20130526013748_create_pages.rb
140
- - db/migrate/20130526014011_create_page_templates.rb
141
- - db/migrate/20130526024132_create_styles.rb
142
- - db/migrate/20130526033402_create_body_styles.rb
143
- - db/schema.rb
144
152
  - lib/chosen_template.rb
153
+ - lib/chosen_template/action_controller_extensions.rb
154
+ - lib/chosen_template/active_record_extensions.rb
155
+ - lib/chosen_template/choosable_template_controller.rb
145
156
  - lib/chosen_template/chooser.rb
146
157
  - lib/chosen_template/chosen.rb
147
158
  - lib/chosen_template/version.rb
148
159
  - spec/chosen_template_spec.rb
160
+ - spec/controllers/styles_controller_spec.rb
161
+ - spec/dummy/Rakefile
162
+ - spec/dummy/app/assets/javascripts/application.js
163
+ - spec/dummy/app/assets/stylesheets/application.css
164
+ - spec/dummy/app/controllers/application_controller.rb
165
+ - spec/dummy/app/controllers/styles_controller.rb
166
+ - spec/dummy/app/helpers/application_helper.rb
167
+ - spec/dummy/app/mailers/.gitkeep
168
+ - spec/dummy/app/models/body_style.rb
169
+ - spec/dummy/app/models/page.rb
170
+ - spec/dummy/app/models/page_template.rb
171
+ - spec/dummy/app/models/style.rb
172
+ - spec/dummy/app/views/layouts/application.html.erb
173
+ - spec/dummy/config.ru
174
+ - spec/dummy/config/application.rb
175
+ - spec/dummy/config/boot.rb
176
+ - spec/dummy/config/database.yml
177
+ - spec/dummy/config/environment.rb
178
+ - spec/dummy/config/environments/development.rb
179
+ - spec/dummy/config/environments/production.rb
180
+ - spec/dummy/config/environments/test.rb
181
+ - spec/dummy/config/initializers/backtrace_silencers.rb
182
+ - spec/dummy/config/initializers/inflections.rb
183
+ - spec/dummy/config/initializers/mime_types.rb
184
+ - spec/dummy/config/initializers/secret_token.rb
185
+ - spec/dummy/config/initializers/session_store.rb
186
+ - spec/dummy/config/initializers/wrap_parameters.rb
187
+ - spec/dummy/config/locales/en.yml
188
+ - spec/dummy/config/routes.rb
189
+ - spec/dummy/db/migrate/20130526013748_create_pages.rb
190
+ - spec/dummy/db/migrate/20130526014011_create_page_templates.rb
191
+ - spec/dummy/db/migrate/20130526024132_create_styles.rb
192
+ - spec/dummy/db/migrate/20130526033402_create_body_styles.rb
193
+ - spec/dummy/db/schema.rb
194
+ - spec/dummy/db/seeds.rb
195
+ - spec/dummy/lib/assets/.gitkeep
196
+ - spec/dummy/log/.gitkeep
197
+ - spec/dummy/public/404.html
198
+ - spec/dummy/public/422.html
199
+ - spec/dummy/public/500.html
200
+ - spec/dummy/public/favicon.ico
201
+ - spec/dummy/script/rails
149
202
  - spec/factories/all.rb
150
- - spec/page_spec.rb
151
- - spec/page_template_spec.rb
203
+ - spec/models/page_spec.rb
204
+ - spec/models/page_template_spec.rb
152
205
  - spec/spec_helper.rb
153
- - spec/support/active_record.rb
154
206
  - spec/support/factory_girl.rb
155
- - spec/support/loader.rb
156
- - spec/support/models/body_styles.rb
157
- - spec/support/models/page.rb
158
- - spec/support/models/page_template.rb
159
- - spec/support/models/style.rb
160
207
  homepage: ''
161
208
  licenses:
162
209
  - MIT
@@ -184,14 +231,50 @@ summary: Manage the preview and publish tasks of templates. See the readme for a
184
231
  as I don't know how else to describe it!
185
232
  test_files:
186
233
  - spec/chosen_template_spec.rb
234
+ - spec/controllers/styles_controller_spec.rb
235
+ - spec/dummy/Rakefile
236
+ - spec/dummy/app/assets/javascripts/application.js
237
+ - spec/dummy/app/assets/stylesheets/application.css
238
+ - spec/dummy/app/controllers/application_controller.rb
239
+ - spec/dummy/app/controllers/styles_controller.rb
240
+ - spec/dummy/app/helpers/application_helper.rb
241
+ - spec/dummy/app/mailers/.gitkeep
242
+ - spec/dummy/app/models/body_style.rb
243
+ - spec/dummy/app/models/page.rb
244
+ - spec/dummy/app/models/page_template.rb
245
+ - spec/dummy/app/models/style.rb
246
+ - spec/dummy/app/views/layouts/application.html.erb
247
+ - spec/dummy/config.ru
248
+ - spec/dummy/config/application.rb
249
+ - spec/dummy/config/boot.rb
250
+ - spec/dummy/config/database.yml
251
+ - spec/dummy/config/environment.rb
252
+ - spec/dummy/config/environments/development.rb
253
+ - spec/dummy/config/environments/production.rb
254
+ - spec/dummy/config/environments/test.rb
255
+ - spec/dummy/config/initializers/backtrace_silencers.rb
256
+ - spec/dummy/config/initializers/inflections.rb
257
+ - spec/dummy/config/initializers/mime_types.rb
258
+ - spec/dummy/config/initializers/secret_token.rb
259
+ - spec/dummy/config/initializers/session_store.rb
260
+ - spec/dummy/config/initializers/wrap_parameters.rb
261
+ - spec/dummy/config/locales/en.yml
262
+ - spec/dummy/config/routes.rb
263
+ - spec/dummy/db/migrate/20130526013748_create_pages.rb
264
+ - spec/dummy/db/migrate/20130526014011_create_page_templates.rb
265
+ - spec/dummy/db/migrate/20130526024132_create_styles.rb
266
+ - spec/dummy/db/migrate/20130526033402_create_body_styles.rb
267
+ - spec/dummy/db/schema.rb
268
+ - spec/dummy/db/seeds.rb
269
+ - spec/dummy/lib/assets/.gitkeep
270
+ - spec/dummy/log/.gitkeep
271
+ - spec/dummy/public/404.html
272
+ - spec/dummy/public/422.html
273
+ - spec/dummy/public/500.html
274
+ - spec/dummy/public/favicon.ico
275
+ - spec/dummy/script/rails
187
276
  - spec/factories/all.rb
188
- - spec/page_spec.rb
189
- - spec/page_template_spec.rb
277
+ - spec/models/page_spec.rb
278
+ - spec/models/page_template_spec.rb
190
279
  - spec/spec_helper.rb
191
- - spec/support/active_record.rb
192
280
  - spec/support/factory_girl.rb
193
- - spec/support/loader.rb
194
- - spec/support/models/body_styles.rb
195
- - spec/support/models/page.rb
196
- - spec/support/models/page_template.rb
197
- - spec/support/models/style.rb
@@ -1,5 +0,0 @@
1
- require 'active_support/core_ext/hash/indifferent_access'
2
-
3
- database_yml = File.join(ROOT_DIR, 'db', 'config.yml')
4
- db_config = YAML.load_file(database_yml).with_indifferent_access
5
- ActiveRecord::Base.establish_connection(db_config[:test])
@@ -1,3 +0,0 @@
1
- Dir.glob(File.join(SPEC_DIR, 'models', '**', '*.rb')).each do |f|
2
- require f
3
- end