change bad coverall setup + improve codeclimate score for csrf.rb and stack.rb files
did
committed Feb 03, 2015
commit 9767c29213e112a2319b737ec68c7f34bb6d6743
Showing 7
changed files with
36 additions
and 51 deletions
Rakefile
+6
-0
| @@ | @@ -5,6 +5,12 @@ require 'bundler/gem_tasks' |
| require 'rake' | |
| require 'rspec' | |
| + | # === Gems install tasks === |
| + | Bundler::GemHelper.install_tasks |
| + | |
| + | require 'coveralls/rake/task' |
| + | Coveralls::RakeTask.new |
| + | |
| require_relative 'lib/locomotive/steam' | |
| require 'rspec/core/rake_task' | |
locomotive/steam/liquid/tags/csrf.rb b/lib/locomotive/steam/liquid/tags/csrf.rb
+14
-17
| @@ | @@ -4,35 +4,32 @@ module Locomotive |
| module Tags | |
| module Csrf | |
| - | class Param < ::Liquid::Tag |
| - | |
| + | class Base < ::Liquid::Tag |
| def render(context) | |
| service = context.registers[:services].csrf_protection | |
| if service.enabled? | |
| - | %(<input type="hidden" name="#{service.field}" value="#{service.token}" />) |
| + | render_csrf(service) |
| + | |
| else | |
| '' | |
| end | |
| end | |
| - | |
| end | |
| - | class Meta < ::Liquid::Tag |
| - | |
| - | def render(context) |
| - | service = context.registers[:services].csrf_protection |
| - | |
| - | if service.enabled? |
| - | %{ |
| - | <meta name="csrf-param" content="#{service.field}" /> |
| - | <meta name="csrf-token" content="#{service.token}" /> |
| - | } |
| - | else |
| - | '' |
| - | end |
| + | class Param < Base |
| + | def render_csrf(service) |
| + | %(<input type="hidden" name="#{service.field}" value="#{service.token}" />) |
| end | |
| + | end |
| + | class Meta < Base |
| + | def render_csrf(service) |
| + | %{ |
| + | <meta name="csrf-param" content="#{service.field}" /> |
| + | <meta name="csrf-token" content="#{service.token}" /> |
| + | } |
| + | end |
| end | |
| end | |
locomotive/steam/liquid/tags/javascript.rb b/lib/locomotive/steam/liquid/tags/javascript.rb
+0
-21
| @@ | @@ -1,21 +0,0 @@ |
| - | module Locomotive |
| - | module Steam |
| - | module Liquid |
| - | module Tags |
| - | class Javascript < ::Liquid::Block |
| - | |
| - | # TODO |
| - | # include ActionView::Helpers::JavaScriptHelper |
| - | # include ActionView::Helpers::TagHelper |
| - | |
| - | def render(context) |
| - | javascript_tag super |
| - | end |
| - | end |
| - | |
| - | ::Liquid::Template.register_tag('javascript', Javascript) |
| - | |
| - | end |
| - | end |
| - | end |
| - | end |
locomotive/steam/liquid/tags/link_to.rb b/lib/locomotive/steam/liquid/tags/link_to.rb
+1
-2
| @@ | @@ -5,7 +5,6 @@ module Locomotive |
| class LinkTo < Hybrid | |
| include PathHelper | |
| - | # include ActionView::Helpers::UrlHelper |
| def render(context) | |
| render_path(context) do |page, path| | |
| @@ | @@ -16,7 +15,7 @@ module Locomotive |
| label = super.html_safe | |
| end | |
| - | link_to label, path |
| + | %{<a href="#{path}">#{label}</a>} |
| end | |
| end | |
locomotive/steam/middlewares/stack.rb b/lib/locomotive/steam/middlewares/stack.rb
+10
-4
| @@ | @@ -38,6 +38,16 @@ module Locomotive |
| use Rack::Session::Moneta, options[:moneta] | |
| + | use_steam_middlewares(self) |
| + | |
| + | run Middlewares::Renderer.new |
| + | end |
| + | end |
| + | |
| + | protected |
| + | |
| + | def use_steam_middlewares(builder) |
| + | builder.instance_eval do |
| use Middlewares::Logging | |
| use Middlewares::EntrySubmission | |
| @@ | @@ -48,13 +58,9 @@ module Locomotive |
| use Middlewares::Page | |
| use Middlewares::TemplatizedPage | |
| - | |
| - | run Middlewares::Renderer.new |
| end | |
| end | |
| - | protected |
| - | |
| def prepare_options(options) | |
| { | |
| serve_assets: false, | |
locomotivecms_steam.gemspec
+1
-1
| @@ | @@ -42,7 +42,7 @@ Gem::Specification.new do |spec| |
| # spec.add_dependency 'locomotivecms_models', '~> 0.0.1.pre.alpha' | |
| spec.add_dependency 'locomotivecms-solid', '~> 4.0.0.alpha1' | |
| - | spec.add_dependency 'locomotivecms_common', '~> 0.0.2' |
| + | spec.add_dependency 'locomotivecms_common', '~> 0.0.2' |
| # spec.required_ruby_version = '~> 2.0' | |
| end | |
spec/spec_helper.rb
+4
-6
| @@ | @@ -2,7 +2,9 @@ require 'rubygems' |
| require 'bundler/setup' | |
| require 'i18n-spec' | |
| + | |
| require 'coveralls' | |
| + | Coveralls.wear! |
| begin | |
| require 'pry' | |
| @@ | @@ -12,7 +14,6 @@ end |
| require_relative '../lib/locomotive/steam' | |
| require_relative 'support' | |
| - | Coveralls.wear! |
| Locomotive::Steam.configure do |config| | |
| config.mode = :test | |
| @@ | @@ -25,10 +26,7 @@ RSpec.configure do |config| |
| config.run_all_when_everything_filtered = true | |
| config.before(:all) { remove_logs } | |
| - | config.before do |
| - | reset! |
| - | end |
| - | config.after { reset! |
| - | } |
| + | config.before { reset! } |
| + | config.after { reset! } |
| config.order = 'random' | |
| end | |