Skip to content
Browse files

Fix symfony:assets:update_version, add sh tests. Fixes #282

  • Loading branch information...
1 parent d899165 commit 4a2d5232c5480f45ffe4b4c5fe97ac02952b342b @willdurand willdurand committed
Showing with 95 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +6 −1 .travis.yml
  3. +1 −1 lib/symfony2/symfony.rb
  4. +70 −0 tests/capifony-symfony2-test.sh
  5. +16 −0 tests/fixtures/config.yml
View
2 .gitignore
@@ -1,3 +1,5 @@
README
*.gem
.gemfile.lock
+tests/roundup
+tests/tests
View
7 .travis.yml
@@ -3,7 +3,12 @@ language: ruby
rvm:
- 1.9.3
+before_script:
+ - wget --no-check-certificate -O tests/roundup https://raw.github.com/bmizerany/roundup/a8a175a7fba9bbfb14d1025951c4b46a65e875a6/roundup.sh
+ - chmod +x tests/roundup
+
script:
- - "rake spec"
+ - rake spec
+ - cd tests && ./roundup capifony-symfony2-test.sh
gemfile: .gemfile
View
2 lib/symfony2/symfony.rb
@@ -25,7 +25,7 @@
namespace :assets do
desc "Updates assets version (in config.yml)"
task :update_version, :roles => :app, :except => { :no_release => true } do
- run "#{try_sudo} sed -i 's/\\(assets_version: \\)\\([a-zA-Z0-9_]*\\)\\(.*\\)$/\\1 \"#{real_revision[0,7]}\"\\3/g' #{latest_release}/#{app_config_path}/config.yml"
+ run "#{try_sudo} sed -i 's/\\(assets_version:[ ]*\\)\\([a-zA-Z0-9_]*\\)\\(.*\\)$/\\1#{real_revision[0,7]}\\3/g' #{latest_release}/#{app_config_path}/config.yml"
end
desc "Installs bundle's assets"
View
70 tests/capifony-symfony2-test.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env roundup
+#
+# capifony-symfony2-test.sh | William Durand <william.durand1@gmail.com>
+
+describe "Capifony::Symfony2"
+
+TESTS_DIR="tests"
+FIXTURES_YAML_CONFIG="fixtures/config.yml"
+
+before() {
+ mkdir $TESTS_DIR
+ cp $FIXTURES_YAML_CONFIG "$TESTS_DIR/test"
+}
+
+after() {
+ rm -rf $TESTS_DIR
+}
+
+it_replaces_asset_version() {
+ expected_content=$(cat <<EOF
+framework:
+ esi: { enabled: true }
+ translator: { fallback: %locale% }
+ secret: %secret%
+ router:
+ resource: "%kernel.root_dir%/config/routing.yml"
+ strict_requirements: %kernel.debug%
+ form: true
+ csrf_protection: true
+ validation: { enable_annotations: true }
+ templating: { engines: ['twig'] } # assets_version: d7cedcc
+ default_locale: %locale%
+ trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
+ session: ~
+ templating:
+ assets_version: d7cedcc
+EOF)
+
+ sed -i -e 's/\(assets_version:[ ]*\)\([a-zA-Z0-9_]*\)\(.*\)$/\1d7cedcc\3/g' "$TESTS_DIR/test"
+
+ result=`cat $TESTS_DIR/test`
+ test "$expected_content" "=" "$result"
+}
+
+it_replaces_asset_version_with_quotes() {
+ expected_content=$(cat <<EOF
+framework:
+ esi: { enabled: true }
+ translator: { fallback: %locale% }
+ secret: %secret%
+ router:
+ resource: "%kernel.root_dir%/config/routing.yml"
+ strict_requirements: %kernel.debug%
+ form: true
+ csrf_protection: true
+ validation: { enable_annotations: true }
+ templating: { engines: ['twig'] } # assets_version: foobar
+ default_locale: %locale%
+ trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
+ session: ~
+ templating:
+ assets_version: foobar
+EOF)
+
+ sed -i -e 's/\(assets_version:[ ]*\)\([a-zA-Z0-9_]*\)\(.*\)$/\1d7cedcc\3/g' "$TESTS_DIR/test"
+ sed -i -e 's/\(assets_version:[ ]*\)\([a-zA-Z0-9_]*\)\(.*\)$/\1foobar\3/g' "$TESTS_DIR/test"
+
+ result=`cat $TESTS_DIR/test`
+ test "$expected_content" "=" "$result"
+}
View
16 tests/fixtures/config.yml
@@ -0,0 +1,16 @@
+framework:
+ esi: { enabled: true }
+ translator: { fallback: %locale% }
+ secret: %secret%
+ router:
+ resource: "%kernel.root_dir%/config/routing.yml"
+ strict_requirements: %kernel.debug%
+ form: true
+ csrf_protection: true
+ validation: { enable_annotations: true }
+ templating: { engines: ['twig'] } # assets_version: 1
+ default_locale: %locale%
+ trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
+ session: ~
+ templating:
+ assets_version: 1

0 comments on commit 4a2d523

Please sign in to comment.
Something went wrong with that request. Please try again.