push commands: snippets and translations + refactoring
did
committed Apr 15, 2015
commit bee73a42ab299637016810a95fe1ce1647d8d781
Showing 7
changed files with
344 additions
and 66 deletions
Gemfile
+4
-4
| @@ | @@ -13,12 +13,12 @@ gem 'rb-fsevent', '~> 0.9.1' |
| gem 'therubyracer' | |
| - | gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'b2de77e', require: false |
| - | gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: '32b2844', require: false |
| + | # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'b2de77e', require: false |
| + | # gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: '32b2844', require: false |
| gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '1895573', require: false | |
| - | # gem 'locomotivecms_coal', path: '../in_progress/coal', require: false |
| - | # gem 'locomotivecms_steam', path: '../in_progress/steam', require: false |
| + | gem 'locomotivecms_coal', path: '../in_progress/coal', require: false |
| + | gem 'locomotivecms_steam', path: '../in_progress/steam', require: false |
| # gem 'locomotivecms_common', path: '../in_progress/common', require: false | |
| group :test do | |
locomotive/wagon/commands/concerns/api_concern.rb b/lib/locomotive/wagon/commands/concerns/api_concern.rb
+7
-2
| @@ | @@ -10,8 +10,13 @@ module Locomotive::Wagon |
| end | |
| # Instance of the API client to request resources of a site: pages, theme_assets, ...etc. | |
| - | def api_site_client(site) |
| - | @api_site_client = api_client.scope_by(site) |
| + | def api_site_client(connection) |
| + | return @api_site_client if @api_site_client |
| + | |
| + | _host, _credentials = connection['host'], connection.slice('email', 'api_key', 'password') |
| + | _options = connection.slice('ssl', 'handle') |
| + | |
| + | @api_site_client = Locomotive::Coal::Client.new(_host, _credentials, _options) |
| end | |
| # Host (+ port) extracted from the platform_url instance variable. | |
locomotive/wagon/commands/push_command.rb b/lib/locomotive/wagon/commands/push_command.rb
+16
-11
| @@ | @@ -4,7 +4,15 @@ require_relative 'concerns/api_concern' |
| require_relative 'concerns/netrc_concern' | |
| require_relative 'concerns/deploy_file_concern' | |
| require_relative 'concerns/steam_concern' | |
| + | |
| + | require_relative '../decorators/concerns/to_hash_concern' |
| require_relative '../decorators/site_decorator' | |
| + | require_relative '../decorators/snippet_decorator' |
| + | require_relative '../decorators/translation_decorator' |
| + | |
| + | require_relative 'push_sub_commands/push_base_command' |
| + | require_relative 'push_sub_commands/push_snippets_command' |
| + | require_relative 'push_sub_commands/push_translations_command' |
| module Locomotive::Wagon | |
| @@ | @@ -22,10 +30,16 @@ module Locomotive::Wagon |
| end | |
| def push | |
| - | puts connection_information.inspect |
| + | api_client = api_site_client(connection_information) |
| + | |
| + | PushSnippetsCommand.push(api_client, steam_services) |
| + | PushTranslationsCommand.push(api_client, steam_services) |
| + | |
| true | |
| end | |
| + | private |
| + | |
| def connection_information | |
| if information = read_deploy_settings(self.env, self.path) | |
| # the deployment env exists and contains all the information we need to move on | |
| @@ | @@ -47,13 +61,11 @@ module Locomotive::Wagon |
| end | |
| end | |
| - | private |
| - | |
| def create_remote_site | |
| # get an instance of the Steam services in order to load the information about the site (SiteRepository) | |
| steam_services.current_site.tap do |site| | |
| # ask for a handle if not found (blank: random one) | |
| - | site[:handle] ||= ask_for_the_site_handle |
| + | site[:handle] ||= shell.ask "What is the handle of your site?" |
| # create the site | |
| attributes = SiteDecorator.new(site).to_hash | |
| @@ | @@ -80,13 +92,6 @@ module Locomotive::Wagon |
| self.platform_url = url.blank? ? default : url | |
| end | |
| - | def ask_for_the_site_handle |
| - | handle = nil |
| - | while handle.nil? |
| - | handle = shell.ask "What is the handle of your site?" |
| - | end |
| - | end |
| - | |
| def shell | |
| options[:shell] | |
| end | |
locomotive/wagon/decorators/site_decorator.rb b/lib/locomotive/wagon/decorators/site_decorator.rb
+8
-12
| @@ | @@ -3,22 +3,18 @@ module Locomotive |
| class SiteDecorator < SimpleDelegator | |
| + | include ToHashConcern |
| + | |
| def domains | |
| (__getobj__.domains || []) - ['localhost'] | |
| end | |
| - | def to_hash |
| - | {}.tap do |hash| |
| - | %i(name handle robots_txt locales domains timezone seo_title meta_keywords meta_description).each do |name| |
| - | if value = self[name] |
| - | if value.respond_to?(:translations) |
| - | hash[name] = value.translations unless value.translations.empty? |
| - | else |
| - | hash[name] = value |
| - | end |
| - | end |
| - | end |
| - | end |
| + | def robots_txt |
| + | self[:robots_txt] |
| + | end |
| + | |
| + | def __attributes__ |
| + | %i(name handle robots_txt locales domains timezone seo_title meta_keywords meta_description) |
| end | |
| end | |
spec/fixtures/cassettes/push.yml
+285
-21
| @@ | @@ -2,7 +2,7 @@ |
| http_interactions: | |
| - request: | |
| method: post | |
| - | uri: http://localhost:3000/locomotive/api/v3/tokens.json?api_key=d49cd50f6f0d2b163f48fc73cb249f0244c37074&email=admin@locomotivecms.com&url=http://localhost:3000 |
| + | uri: http://localhost:3000/locomotive/api/v3/tokens.json?api_key=d49cd50f6f0d2b163f48fc73cb249f0244c37074&email=admin@locomotivecms.com |
| body: | |
| encoding: UTF-8 | |
| string: '' | |
| @@ | @@ -25,25 +25,25 @@ http_interactions: |
| Content-Length: | |
| - '32' | |
| Etag: | |
| - | - W/"1fe908e55e46275a5704935dac02818a" |
| + | - W/"04802fe17c8589a5daf2c9a0c66e371e" |
| Cache-Control: | |
| - max-age=0, private, must-revalidate | |
| X-Request-Id: | |
| - | - 0a49ccde-4b0c-4982-8355-7b458011889c |
| + | - e396cc42-ea4a-43f3-88a3-69720e4a4ed1 |
| X-Runtime: | |
| - | - '0.017965' |
| + | - '0.031962' |
| Connection: | |
| - keep-alive | |
| Server: | |
| - thin | |
| body: | |
| encoding: UTF-8 | |
| - | string: '{"token":"i3Pws38yeUQ4Cp58xjSk"}' |
| + | string: '{"token":"mJ7qvyLaD_dyMuA6NxQC"}' |
| http_version: | |
| - | recorded_at: Mon, 13 Apr 2015 09:15:18 GMT |
| + | recorded_at: Wed, 15 Apr 2015 21:18:07 GMT |
| - request: | |
| method: post | |
| - | uri: http://localhost:3000/locomotive/api/v3/sites.json?auth_token=i3Pws38yeUQ4Cp58xjSk&site%5Bdomains%5D%5B0%5D=wagon.example.com&site%5Bdomains%5D%5B1%5D=localhost&site%5Blocales%5D%5B0%5D=en&site%5Blocales%5D%5B1%5D=fr&site%5Blocales%5D%5B2%5D=nb&site%5Bmeta_keywords%5D%5Ben%5D=some%20meta%20keywords&site%5Bmeta_keywords%5D%5Bfr%5D=quelques%20mots%20cles&site%5Bname%5D=Sample%20website&site%5Bseo_title%5D%5Ben%5D=A%20simple%20LocomotiveCMS%20website&site%5Bseo_title%5D%5Bfr%5D=Un%20simple%20LocomotiveCMS%20site%20web |
| + | uri: http://localhost:3000/locomotive/api/v3/sites.json?auth_token=mJ7qvyLaD_dyMuA6NxQC&site%5Bdomains%5D%5B0%5D=wagon.example.com&site%5Bhandle%5D=&site%5Blocales%5D%5B0%5D=en&site%5Blocales%5D%5B1%5D=fr&site%5Blocales%5D%5B2%5D=nb&site%5Bmeta_keywords%5D%5Ben%5D=some%20meta%20keywords&site%5Bmeta_keywords%5D%5Bfr%5D=quelques%20mots%20cles&site%5Bname%5D=Sample%20website&site%5Bseo_title%5D%5Ben%5D=A%20simple%20LocomotiveCMS%20website&site%5Bseo_title%5D%5Bfr%5D=Un%20simple%20LocomotiveCMS%20site%20web&site%5Btimezone%5D=(GMT%2B00:00)%20UTC |
| body: | |
| encoding: UTF-8 | |
| string: '' | |
| @@ | @@ -53,7 +53,7 @@ http_interactions: |
| X-Locomotive-Account-Email: | |
| - admin@locomotivecms.com | |
| X-Locomotive-Account-Token: | |
| - | - i3Pws38yeUQ4Cp58xjSk |
| + | - mJ7qvyLaD_dyMuA6NxQC |
| Content-Length: | |
| - '0' | |
| Accept-Encoding: | |
| @@ | @@ -68,26 +68,26 @@ http_interactions: |
| Content-Type: | |
| - application/json | |
| Content-Length: | |
| - | - '589' |
| + | - '581' |
| Etag: | |
| - | - W/"32617c88a703d2c4b6bc7a1710ea7181" |
| + | - W/"c43fb5c17c4b2bb2bbab2396ca8df9c8" |
| Cache-Control: | |
| - max-age=0, private, must-revalidate | |
| X-Request-Id: | |
| - | - d2366b32-e8df-4c1c-89cf-047b2f64a1ba |
| + | - b7f1a956-a7d4-400c-8995-f320635f9111 |
| X-Runtime: | |
| - | - '0.050050' |
| + | - '0.139256' |
| Connection: | |
| - keep-alive | |
| Server: | |
| - thin | |
| body: | |
| encoding: UTF-8 | |
| - | string: '{"_id":"552b892764696406eb110000","created_at":"2015-04-13T09:15:19Z","updated_at":"2015-04-13T09:15:19Z","name":"Sample |
| - | website","handle":"warm-leaves-4626","seo_title":"A simple LocomotiveCMS website","meta_keywords":"some |
| - | meta keywords","meta_description":null,"robots_txt":null,"locales":["en","fr","nb"],"domains":["wagon.example.com","localhost"],"memberships":[{"_id":"552b892764696406eb120000","created_at":null,"updated_at":null,"role":"admin","account_id":"552b88fe64696412ec000000","name":"Admin","role_name":"Administrator","email":"admin@locomotivecms.com"}],"timezone":"UTC"}' |
| + | string: '{"_id":"552ed58f64696406eb560000","created_at":"2015-04-15T21:18:07Z","updated_at":"2015-04-15T21:18:07Z","name":"Sample |
| + | website","handle":"spacial-shelter-2890","seo_title":"A simple LocomotiveCMS |
| + | website","meta_keywords":"some meta keywords","meta_description":null,"robots_txt":null,"locales":["en","fr","nb"],"domains":["wagon.example.com"],"memberships":[{"_id":"552ed58f64696406eb570000","created_at":null,"updated_at":null,"role":"admin","account_id":"552ed57e64696466f5000000","name":"Admin","role_name":"Administrator","email":"admin@locomotivecms.com"}],"timezone":"UTC"}' |
| http_version: | |
| - | recorded_at: Mon, 13 Apr 2015 09:15:19 GMT |
| + | recorded_at: Wed, 15 Apr 2015 21:18:07 GMT |
| - request: | |
| method: post | |
| uri: http://localhost:3000/locomotive/api/v3/tokens.json?api_key=d49cd50f6f0d2b163f48fc73cb249f0244c37074&email=admin@locomotivecms.com | |
| @@ | @@ -113,20 +113,284 @@ http_interactions: |
| Content-Length: | |
| - '32' | |
| Etag: | |
| - | - W/"1fe908e55e46275a5704935dac02818a" |
| + | - W/"04802fe17c8589a5daf2c9a0c66e371e" |
| Cache-Control: | |
| - max-age=0, private, must-revalidate | |
| X-Request-Id: | |
| - | - d781ed41-6dc7-4706-a1b2-24155fbe9f0e |
| + | - ad1b31c4-acae-4b8f-b293-ea82ac18b98c |
| X-Runtime: | |
| - | - '0.118848' |
| + | - '0.022941' |
| Connection: | |
| - keep-alive | |
| Server: | |
| - thin | |
| body: | |
| encoding: UTF-8 | |
| - | string: '{"token":"i3Pws38yeUQ4Cp58xjSk"}' |
| + | string: '{"token":"mJ7qvyLaD_dyMuA6NxQC"}' |
| + | http_version: |
| + | recorded_at: Wed, 15 Apr 2015 21:18:07 GMT |
| + | - request: |
| + | method: put |
| + | uri: http://localhost:3000/locomotive/api/v3/snippets/song.json?auth_token=mJ7qvyLaD_dyMuA6NxQC&snippet%5Bname%5D=Song&snippet%5Bslug%5D=song&snippet%5Btemplate%5D%5Ben%5D=%3Cli%3E%0A%20%20%3Ch3%3E%3Ca%20href=%22/songs/%7B%7B%20song._permalink%20%7D%7D%22%3E%7B%7B%20song.title%20%7D%7D%3C/a%3E%3C/h3%3E%0A%20%20%3Cdiv%20class=%22cover%22%3E%7B%7B%20song.cover.url%20%7C%20image_tag%20%7D%7D%3C/div%3E%0A%20%20%3Cdiv%20class=%22info%22%3E%0A%20%20%20%20%7B%7B%20song.short_description%20%7D%7D%0A%20%20%20%20%3Cp%20class=%22listen%22%3E%0A%20%20%20%20%20%20%3Ca%20href=%22%7B%7B%20song.audio_url%20%7D%7D%22%3E%26rarr%3B%20Listen%20(%7B%7B%20song.duration%20%7D%7D%20min)%3C/a%3E%0A%20%20%20%20%3C/p%3E%0A%20%20%20%20%3Cp%3E%C3%A9couter%20en%20Francais%3C/p%3E%0A%20%20%3C/div%3E%0A%20%20%3Cdiv%20class=%22clear%22%3E%3C/div%3E%0A%3C/li%3E&snippet%5Btemplate%5D%5Bfr%5D=%3Cli%3E%0A%20%20%3Ch3%3E%7B%25%20link_to%20song,%20with:%20a-song-template%20%25%7D%3C/h3%3E%0A%20%20%3Cdiv%20class='cover'%3E%7B%7B%20song.cover.url%20%7C%20image_tag%20%7D%7D%3C/div%3E%0A%20%20%3Cdiv%20class='info'%3E%0A%20%20%20%20%7B%7B%20song.short_description%20%7D%7D%0A%20%20%20%20%3Cp%20class='listen'%3E%0A%20%20%20%20%20%20%3Ca%20href='%7B%7B%20song.audio_url%20%7D%7D'%3E%26rarr%3B%20%C3%A9couter%20(%7B%7B%20song.duration%20%7D%7D%20min)%3C/a%3E%0A%20%20%20%20%3C/p%3E%0A%20%20%3C/div%3E%0A%20%20%3Cdiv%20class='clear'%3E%3C/div%3E%0A%3C/li%3E%0A&snippet%5Btemplate%5D%5Bnb%5D=%3Cli%3E%0A%20%20%3Ch3%3E%3Ca%20href=%22/songs/%7B%7B%20song._permalink%20%7D%7D%22%3E%7B%7B%20song.title%20%7D%7D%3C/a%3E%3C/h3%3E%0A%20%20%3Cdiv%20class=%22cover%22%3E%7B%7B%20song.cover.url%20%7C%20image_tag%20%7D%7D%3C/div%3E%0A%20%20%3Cdiv%20class=%22info%22%3E%0A%20%20%20%20%7B%7B%20song.short_description%20%7D%7D%0A%20%20%20%20%3Cp%20class=%22listen%22%3E%0A%20%20%20%20%20%20%3Ca%20href=%22%7B%7B%20song.audio_url%20%7D%7D%22%3E%26rarr%3B%20Listen%20(%7B%7B%20song.duration%20%7D%7D%20min)%3C/a%3E%0A%20%20%20%20%3C/p%3E%0A%20%20%20%20%3Cp%3E%C3%A9couter%20en%20Francais%3C/p%3E%0A%20%20%3C/div%3E%0A%20%20%3Cdiv%20class=%22clear%22%3E%3C/div%3E%0A%3C/li%3E |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '' |
| + | headers: |
| + | Accept: |
| + | - application/json |
| + | X-Locomotive-Account-Email: |
| + | - admin@locomotivecms.com |
| + | X-Locomotive-Account-Token: |
| + | - mJ7qvyLaD_dyMuA6NxQC |
| + | X-Locomotive-Site-Handle: |
| + | - spacial-shelter-2890 |
| + | Content-Length: |
| + | - '0' |
| + | Accept-Encoding: |
| + | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 |
| + | User-Agent: |
| + | - Ruby |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: OK |
| + | headers: |
| + | Content-Type: |
| + | - application/json |
| + | Content-Length: |
| + | - '733' |
| + | Etag: |
| + | - W/"ab02024a8c0b3c9c957e3336754aad22" |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - 43724372-d795-40ac-93e1-baa3f0d90f34 |
| + | X-Runtime: |
| + | - '0.063829' |
| + | Connection: |
| + | - keep-alive |
| + | Server: |
| + | - thin |
| + | body: |
| + | encoding: ASCII-8BIT |
| + | string: !binary |- |
| + | eyJfaWQiOiI1NTJlZDU4ZjY0Njk2NDA2ZWI1YTAwMDAiLCJjcmVhdGVkX2F0 |
| + | IjoiMjAxNS0wNC0xNVQyMToxODowN1oiLCJ1cGRhdGVkX2F0IjoiMjAxNS0w |
| + | NC0xNVQyMToxODowN1oiLCJuYW1lIjoiU29uZyIsInNsdWciOiJzb25nIiwi |
| + | dGVtcGxhdGUiOiJcdTAwM2NsaVx1MDAzZVxuICBcdTAwM2NoM1x1MDAzZVx1 |
| + | MDAzY2EgaHJlZj1cIi9zb25ncy97eyBzb25nLl9wZXJtYWxpbmsgfX1cIlx1 |
| + | MDAzZXt7IHNvbmcudGl0bGUgfX1cdTAwM2MvYVx1MDAzZVx1MDAzYy9oM1x1 |
| + | MDAzZVxuICBcdTAwM2NkaXYgY2xhc3M9XCJjb3ZlclwiXHUwMDNle3sgc29u |
| + | Zy5jb3Zlci51cmwgfCBpbWFnZV90YWcgfX1cdTAwM2MvZGl2XHUwMDNlXG4g |
| + | IFx1MDAzY2RpdiBjbGFzcz1cImluZm9cIlx1MDAzZVxuICAgIHt7IHNvbmcu |
| + | c2hvcnRfZGVzY3JpcHRpb24gfX1cbiAgICBcdTAwM2NwIGNsYXNzPVwibGlz |
| + | dGVuXCJcdTAwM2VcbiAgICAgIFx1MDAzY2EgaHJlZj1cInt7IHNvbmcuYXVk |
| + | aW9fdXJsIH19XCJcdTAwM2VcdTAwMjZyYXJyOyBMaXN0ZW4gKHt7IHNvbmcu |
| + | ZHVyYXRpb24gfX0gbWluKVx1MDAzYy9hXHUwMDNlXG4gICAgXHUwMDNjL3Bc |
| + | dTAwM2VcbiAgICBcdTAwM2NwXHUwMDNlw6ljb3V0ZXIgZW4gRnJhbmNhaXNc |
| + | dTAwM2MvcFx1MDAzZVxuICBcdTAwM2MvZGl2XHUwMDNlXG4gIFx1MDAzY2Rp |
| + | diBjbGFzcz1cImNsZWFyXCJcdTAwM2VcdTAwM2MvZGl2XHUwMDNlXG5cdTAw |
| + | M2MvbGlcdTAwM2UifQ== |
| + | http_version: |
| + | recorded_at: Wed, 15 Apr 2015 21:18:07 GMT |
| + | - request: |
| + | method: put |
| + | uri: http://localhost:3000/locomotive/api/v3/snippets/a_complicated-one.json?auth_token=mJ7qvyLaD_dyMuA6NxQC&snippet%5Bname%5D=A%20complicated-one&snippet%5Bslug%5D=a_complicated-one&snippet%5Btemplate%5D%5Ben%5D=%3Cp%3EA%20complicated%20one%20name%20indeed.%3C/p%3E%0A&snippet%5Btemplate%5D%5Bfr%5D=%3Cp%3EA%20complicated%20one%20name%20indeed.%3C/p%3E%0A&snippet%5Btemplate%5D%5Bnb%5D=%3Cp%3EA%20complicated%20one%20name%20indeed.%3C/p%3E%0A |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '' |
| + | headers: |
| + | Accept: |
| + | - application/json |
| + | X-Locomotive-Account-Email: |
| + | - admin@locomotivecms.com |
| + | X-Locomotive-Account-Token: |
| + | - mJ7qvyLaD_dyMuA6NxQC |
| + | X-Locomotive-Site-Handle: |
| + | - spacial-shelter-2890 |
| + | Content-Length: |
| + | - '0' |
| + | Accept-Encoding: |
| + | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 |
| + | User-Agent: |
| + | - Ruby |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: OK |
| + | headers: |
| + | Content-Type: |
| + | - application/json |
| + | Content-Length: |
| + | - '233' |
| + | Etag: |
| + | - W/"0c06bacfa283c3eb51dd1c0ff0f0a776" |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - 95918dfc-ec4c-46a9-83c5-3562ad9df2fb |
| + | X-Runtime: |
| + | - '0.040647' |
| + | Connection: |
| + | - keep-alive |
| + | Server: |
| + | - thin |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '{"_id":"552ed58f64696406eb5b0000","created_at":"2015-04-15T21:18:07Z","updated_at":"2015-04-15T21:18:07Z","name":"A |
| + | complicated-one","slug":"a_complicated-one","template":"\u003cp\u003eA complicated |
| + | one name indeed.\u003c/p\u003e\n"}' |
| + | http_version: |
| + | recorded_at: Wed, 15 Apr 2015 21:18:07 GMT |
| + | - request: |
| + | method: put |
| + | uri: http://localhost:3000/locomotive/api/v3/snippets/footer.json?auth_token=mJ7qvyLaD_dyMuA6NxQC&snippet%5Bname%5D=Footer&snippet%5Bslug%5D=footer&snippet%5Btemplate%5D%5Ben%5D=%3Cp%3E%7B%25%20locale_switcher%20%25%7D%3C/p%3E%0A%3Cp%3E%0A%20%20%7B%7B%20'powered_by'%20%7C%20translate%20%7D%7D%20%3Ca%20href=%22http://www.locomotivecms.com%22%3ELocomotiveCMS%3C/a%3E.%20Designed%20by%20%3Ca%20href=%22http://www.sachagreif.com%22%3ESacha%20Greif%3C/a%3E.%0A%3C/p%3E%0A%3Cp%3E%0A%20%20All%20photos%20are%20licensed%20under%20Creative%20Commons.%20(see%20original%20ones%20%3Ca%20href='http://www.flickr.com/photos/38687875@N00/3391588262/'%3Ehere%3C/a%3E%20or%20%3Ca%20href='http://www.flickr.com/photos/cool_dry_place/55454498/'%3Ehere%3C/a%3E).%0A%3C/p%3E%0A&snippet%5Btemplate%5D%5Bfr%5D=%3Cp%3E%7B%25%20locale_switcher%20%25%7D%3C/p%3E%0A%3Cp%3E%0A%20%20%7B%7B%20'powered_by'%20%7C%20translate%20%7D%7D%20%3Ca%20href=%22http://www.locomotivecms.com%22%3ELocomotiveCMS%3C/a%3E.%20Designed%20by%20%3Ca%20href=%22http://www.sachagreif.com%22%3ESacha%20Greif%3C/a%3E.%0A%3C/p%3E%0A%3Cp%3E%0A%20%20All%20photos%20are%20licensed%20under%20Creative%20Commons.%20(see%20original%20ones%20%3Ca%20href='http://www.flickr.com/photos/38687875@N00/3391588262/'%3Ehere%3C/a%3E%20or%20%3Ca%20href='http://www.flickr.com/photos/cool_dry_place/55454498/'%3Ehere%3C/a%3E).%0A%3C/p%3E%0A&snippet%5Btemplate%5D%5Bnb%5D=%3Cp%3E%7B%25%20locale_switcher%20%25%7D%3C/p%3E%0A%3Cp%3E%0A%20%20%7B%7B%20'powered_by'%20%7C%20translate%20%7D%7D%20%3Ca%20href=%22http://www.locomotivecms.com%22%3ELocomotiveCMS%3C/a%3E.%20Designed%20by%20%3Ca%20href=%22http://www.sachagreif.com%22%3ESacha%20Greif%3C/a%3E.%0A%3C/p%3E%0A%3Cp%3E%0A%20%20All%20photos%20are%20licensed%20under%20Creative%20Commons.%20(see%20original%20ones%20%3Ca%20href='http://www.flickr.com/photos/38687875@N00/3391588262/'%3Ehere%3C/a%3E%20or%20%3Ca%20href='http://www.flickr.com/photos/cool_dry_place/55454498/'%3Ehere%3C/a%3E).%0A%3C/p%3E%0A |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '' |
| + | headers: |
| + | Accept: |
| + | - application/json |
| + | X-Locomotive-Account-Email: |
| + | - admin@locomotivecms.com |
| + | X-Locomotive-Account-Token: |
| + | - mJ7qvyLaD_dyMuA6NxQC |
| + | X-Locomotive-Site-Handle: |
| + | - spacial-shelter-2890 |
| + | Content-Length: |
| + | - '0' |
| + | Accept-Encoding: |
| + | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 |
| + | User-Agent: |
| + | - Ruby |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: OK |
| + | headers: |
| + | Content-Type: |
| + | - application/json |
| + | Content-Length: |
| + | - '726' |
| + | Etag: |
| + | - W/"73dfa82c02b5c2212614ff9645e9d8e0" |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - be496f25-be77-4123-8675-5e97f8e68cab |
| + | X-Runtime: |
| + | - '0.036406' |
| + | Connection: |
| + | - keep-alive |
| + | Server: |
| + | - thin |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '{"_id":"552ed58f64696406eb5c0000","created_at":"2015-04-15T21:18:07Z","updated_at":"2015-04-15T21:18:07Z","name":"Footer","slug":"footer","template":"\u003cp\u003e{% |
| + | locale_switcher %}\u003c/p\u003e\n\u003cp\u003e\n {{ ''powered_by'' | translate |
| + | }} \u003ca href=\"http://www.locomotivecms.com\"\u003eLocomotiveCMS\u003c/a\u003e. |
| + | Designed by \u003ca href=\"http://www.sachagreif.com\"\u003eSacha Greif\u003c/a\u003e.\n\u003c/p\u003e\n\u003cp\u003e\n All |
| + | photos are licensed under Creative Commons. (see original ones \u003ca href=''http://www.flickr.com/photos/38687875@N00/3391588262/''\u003ehere\u003c/a\u003e |
| + | or \u003ca href=''http://www.flickr.com/photos/cool_dry_place/55454498/''\u003ehere\u003c/a\u003e).\n\u003c/p\u003e\n"}' |
| + | http_version: |
| + | recorded_at: Wed, 15 Apr 2015 21:18:07 GMT |
| + | - request: |
| + | method: put |
| + | uri: http://localhost:3000/locomotive/api/v3/snippets/header.json?auth_token=mJ7qvyLaD_dyMuA6NxQC&snippet%5Bname%5D=Header&snippet%5Bslug%5D=header&snippet%5Btemplate%5D%5Ben%5D=%3Ch1%3E%7B%7B%20site.name%20%7D%7D%3C/h1%3E%0A&snippet%5Btemplate%5D%5Bfr%5D=%3Ch1%3E%7B%7B%20site.name%20%7D%7D%3C/h1%3E%0A&snippet%5Btemplate%5D%5Bnb%5D=%3Ch1%3E%7B%7B%20site.name%20%7D%7D%3C/h1%3E%0A |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '' |
| + | headers: |
| + | Accept: |
| + | - application/json |
| + | X-Locomotive-Account-Email: |
| + | - admin@locomotivecms.com |
| + | X-Locomotive-Account-Token: |
| + | - mJ7qvyLaD_dyMuA6NxQC |
| + | X-Locomotive-Site-Handle: |
| + | - spacial-shelter-2890 |
| + | Content-Length: |
| + | - '0' |
| + | Accept-Encoding: |
| + | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 |
| + | User-Agent: |
| + | - Ruby |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: OK |
| + | headers: |
| + | Content-Type: |
| + | - application/json |
| + | Content-Length: |
| + | - '198' |
| + | Etag: |
| + | - W/"9fd3a739256c9c1bd04ed41889551fac" |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - f5905669-1d4e-471c-bdae-dbc31a745d6a |
| + | X-Runtime: |
| + | - '0.036641' |
| + | Connection: |
| + | - keep-alive |
| + | Server: |
| + | - thin |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '{"_id":"552ed59064696406eb5d0000","created_at":"2015-04-15T21:18:08Z","updated_at":"2015-04-15T21:18:08Z","name":"Header","slug":"header","template":"\u003ch1\u003e{{ |
| + | site.name }}\u003c/h1\u003e\n"}' |
| + | http_version: |
| + | recorded_at: Wed, 15 Apr 2015 21:18:08 GMT |
| + | - request: |
| + | method: put |
| + | uri: http://localhost:3000/locomotive/api/v3/translations/powered_by.json?auth_token=mJ7qvyLaD_dyMuA6NxQC&translation%5Bkey%5D=powered_by&translation%5Bvalues%5D%5Ben%5D=Powered%20by&translation%5Bvalues%5D%5Bfr%5D=Propuls%C3%A9%20par |
| + | body: |
| + | encoding: UTF-8 |
| + | string: '' |
| + | headers: |
| + | Accept: |
| + | - application/json |
| + | X-Locomotive-Account-Email: |
| + | - admin@locomotivecms.com |
| + | X-Locomotive-Account-Token: |
| + | - mJ7qvyLaD_dyMuA6NxQC |
| + | X-Locomotive-Site-Handle: |
| + | - spacial-shelter-2890 |
| + | Content-Length: |
| + | - '0' |
| + | Accept-Encoding: |
| + | - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 |
| + | User-Agent: |
| + | - Ruby |
| + | response: |
| + | status: |
| + | code: 200 |
| + | message: OK |
| + | headers: |
| + | Content-Type: |
| + | - application/json |
| + | Content-Length: |
| + | - '175' |
| + | Etag: |
| + | - W/"21fddf3b11a62394bc5839a0d7a685f8" |
| + | Cache-Control: |
| + | - max-age=0, private, must-revalidate |
| + | X-Request-Id: |
| + | - edb4ba5b-8c78-463b-91f2-a7d7d5ec0982 |
| + | X-Runtime: |
| + | - '0.022785' |
| + | Connection: |
| + | - keep-alive |
| + | Server: |
| + | - thin |
| + | body: |
| + | encoding: ASCII-8BIT |
| + | string: !binary |- |
| + | eyJfaWQiOiI1NTJlZGQ2ZDY0Njk2NDA2ZWI2MDAwMDAiLCJjcmVhdGVkX2F0 |
| + | IjoiMjAxNS0wNC0xNVQyMTo1MTo0MVoiLCJ1cGRhdGVkX2F0IjoiMjAxNS0w |
| + | NC0xNVQyMTo1MTo0MVoiLCJrZXkiOiJwb3dlcmVkX2J5IiwidmFsdWVzIjp7 |
| + | ImVuIjoiUG93ZXJlZCBieSIsImZyIjoiUHJvcHVsc8OpIHBhciJ9fQ== |
| http_version: | |
| - | recorded_at: Mon, 13 Apr 2015 11:44:53 GMT |
| + | recorded_at: Wed, 15 Apr 2015 21:51:41 GMT |
| recorded_with: VCR 2.9.3 | |
spec/integration/commands/push_command_spec.rb
+10
-2
| @@ | @@ -26,12 +26,20 @@ describe Locomotive::Wagon::PushCommand do |
| before do | |
| allow(Netrc).to receive(:read).and_return(TEST_PLATFORM_ALT_URL => credentials) | |
| - | allow(Thor::LineEditor).to receive(:readline).and_return(TEST_PLATFORM_URL.dup, 'acme') |
| + | allow(Thor::LineEditor).to receive(:readline).and_return(TEST_PLATFORM_URL.dup, '') |
| end | |
| after { restore_deploy_file(default_site_path) } | |
| - | it { is_expected.to eq true } |
| + | it 'creates a site and push the site' do |
| + | resources = [] |
| + | ActiveSupport::Notifications.subscribe('wagon.push') do |name, start, finish, id, payload| |
| + | puts "Pushing #{payload[:resource]}, done in #{(finish - start)}ms" |
| + | resources << payload[:resource] |
| + | end |
| + | is_expected.to eq true |
| + | expect(resources).to eq %i(snippets translations) |
| + | end |
| context 'no previous authentication' do | |
spec/support/helpers.rb
+14
-14
| @@ | @@ -23,23 +23,23 @@ module Spec |
| # end | |
| # end | |
| - | def working_copy_of_site(name) |
| - | tmp_path = File.expand_path('../../tmp', __FILE__) |
| - | tmp_path = FileUtils.mkdir_p(tmp_path) |
| - | File.join(tmp_path, name.to_s) |
| - | end |
| + | # def working_copy_of_site(name) |
| + | # tmp_path = File.expand_path('../../tmp', __FILE__) |
| + | # tmp_path = FileUtils.mkdir_p(tmp_path) |
| + | # File.join(tmp_path, name.to_s) |
| + | # end |
| - | def make_working_copy_of_site(name) |
| - | source = File.join(File.expand_path('../../fixtures', __FILE__), name.to_s) |
| - | target = working_copy_of_site(name) |
| + | # def make_working_copy_of_site(name) |
| + | # source = File.join(File.expand_path('../../fixtures', __FILE__), name.to_s) |
| + | # target = working_copy_of_site(name) |
| - | FileUtils.cp_r(source, target) |
| - | end |
| + | # FileUtils.cp_r(source, target) |
| + | # end |
| - | def remove_working_copy_of_site(name) |
| - | path = working_copy_of_site(name) |
| - | FileUtils.rm_rf(path) |
| - | end |
| + | # def remove_working_copy_of_site(name) |
| + | # path = working_copy_of_site(name) |
| + | # FileUtils.rm_rf(path) |
| + | # end |
| end | |
| end | |