landable 1.7.0
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.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +15 -0
- data/MIT-LICENSE +20 -0
- data/README.md +56 -0
- data/Rakefile +22 -0
- data/app/controllers/concerns/landable/variables_concern.rb +38 -0
- data/app/controllers/landable/api/access_tokens_controller.rb +48 -0
- data/app/controllers/landable/api/assets_controller.rb +55 -0
- data/app/controllers/landable/api/categories_controller.rb +13 -0
- data/app/controllers/landable/api/directories_controller.rb +19 -0
- data/app/controllers/landable/api/page_revisions_controller.rb +38 -0
- data/app/controllers/landable/api/pages_controller.rb +96 -0
- data/app/controllers/landable/api/templates_controller.rb +33 -0
- data/app/controllers/landable/api/themes_controller.rb +57 -0
- data/app/controllers/landable/api_controller.rb +75 -0
- data/app/controllers/landable/application_controller.rb +4 -0
- data/app/controllers/landable/public/pages_controller.rb +25 -0
- data/app/controllers/landable/public/preview/page_revisions_controller.rb +16 -0
- data/app/controllers/landable/public/preview/pages_controller.rb +16 -0
- data/app/controllers/landable/public/sitemap_controller.rb +18 -0
- data/app/decorators/landable/null_page_decorator.rb +26 -0
- data/app/decorators/landable/page_decorator.rb +40 -0
- data/app/helpers/landable/application_helper.rb +13 -0
- data/app/helpers/landable/pages_helper.rb +20 -0
- data/app/models/concerns/landable/has_assets.rb +74 -0
- data/app/models/concerns/landable/table_name.rb +12 -0
- data/app/models/concerns/landable/traffic/table_name.rb +14 -0
- data/app/models/landable/access_token.rb +20 -0
- data/app/models/landable/asset.rb +63 -0
- data/app/models/landable/asset_search_engine.rb +20 -0
- data/app/models/landable/author.rb +12 -0
- data/app/models/landable/category.rb +27 -0
- data/app/models/landable/directory.rb +23 -0
- data/app/models/landable/page.rb +259 -0
- data/app/models/landable/page_revision.rb +74 -0
- data/app/models/landable/page_search_engine.rb +20 -0
- data/app/models/landable/search_engine.rb +39 -0
- data/app/models/landable/template.rb +24 -0
- data/app/models/landable/theme.rb +20 -0
- data/app/models/landable/traffic/access.rb +11 -0
- data/app/models/landable/traffic/ad_group.rb +11 -0
- data/app/models/landable/traffic/ad_type.rb +11 -0
- data/app/models/landable/traffic/attribution.rb +38 -0
- data/app/models/landable/traffic/bid_match_type.rb +11 -0
- data/app/models/landable/traffic/browser.rb +11 -0
- data/app/models/landable/traffic/campaign.rb +11 -0
- data/app/models/landable/traffic/city.rb +11 -0
- data/app/models/landable/traffic/content.rb +11 -0
- data/app/models/landable/traffic/cookie.rb +16 -0
- data/app/models/landable/traffic/country.rb +11 -0
- data/app/models/landable/traffic/creative.rb +11 -0
- data/app/models/landable/traffic/device.rb +11 -0
- data/app/models/landable/traffic/device_type.rb +11 -0
- data/app/models/landable/traffic/domain.rb +12 -0
- data/app/models/landable/traffic/event.rb +12 -0
- data/app/models/landable/traffic/event_type.rb +11 -0
- data/app/models/landable/traffic/experiment.rb +11 -0
- data/app/models/landable/traffic/http_method.rb +11 -0
- data/app/models/landable/traffic/ip_address.rb +11 -0
- data/app/models/landable/traffic/ip_lookup.rb +12 -0
- data/app/models/landable/traffic/keyword.rb +11 -0
- data/app/models/landable/traffic/location.rb +11 -0
- data/app/models/landable/traffic/match_type.rb +11 -0
- data/app/models/landable/traffic/medium.rb +11 -0
- data/app/models/landable/traffic/mime_type.rb +11 -0
- data/app/models/landable/traffic/network.rb +11 -0
- data/app/models/landable/traffic/owner.rb +10 -0
- data/app/models/landable/traffic/ownership.rb +10 -0
- data/app/models/landable/traffic/page_view.rb +24 -0
- data/app/models/landable/traffic/path.rb +13 -0
- data/app/models/landable/traffic/placement.rb +11 -0
- data/app/models/landable/traffic/platform.rb +11 -0
- data/app/models/landable/traffic/position.rb +11 -0
- data/app/models/landable/traffic/query_string.rb +12 -0
- data/app/models/landable/traffic/referer.rb +11 -0
- data/app/models/landable/traffic/region.rb +11 -0
- data/app/models/landable/traffic/search_term.rb +11 -0
- data/app/models/landable/traffic/source.rb +11 -0
- data/app/models/landable/traffic/target.rb +11 -0
- data/app/models/landable/traffic/user_agent.rb +28 -0
- data/app/models/landable/traffic/user_agent_type.rb +11 -0
- data/app/models/landable/traffic/visit.rb +15 -0
- data/app/models/landable/traffic/visitor.rb +13 -0
- data/app/responders/landable/api_responder.rb +76 -0
- data/app/responders/landable/page_render_responder.rb +15 -0
- data/app/serializers/landable/access_token_serializer.rb +6 -0
- data/app/serializers/landable/asset_serializer.rb +14 -0
- data/app/serializers/landable/author_serializer.rb +5 -0
- data/app/serializers/landable/category_serializer.rb +5 -0
- data/app/serializers/landable/directory_serializer.rb +8 -0
- data/app/serializers/landable/page_revision_serializer.rb +15 -0
- data/app/serializers/landable/page_serializer.rb +31 -0
- data/app/serializers/landable/template_serializer.rb +5 -0
- data/app/serializers/landable/theme_serializer.rb +7 -0
- data/app/services/landable/authentication_service.rb +44 -0
- data/app/services/landable/registration_service.rb +13 -0
- data/app/services/landable/render_service.rb +86 -0
- data/app/services/landable/tidy_service.rb +155 -0
- data/app/uploaders/landable/asset_uploader.rb +9 -0
- data/app/validators/path_validator.rb +12 -0
- data/app/validators/url_validator.rb +13 -0
- data/app/views/templates/preview.liquid +122 -0
- data/bin/rails +8 -0
- data/bin/redb +7 -0
- data/config.ru +7 -0
- data/config/cucumber.yml +5 -0
- data/config/routes.rb +62 -0
- data/db/migrate/20130510221424_create_landable_schema.rb +338 -0
- data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +11 -0
- data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +72 -0
- data/db/migrate/20130909191153_landable_pages__add_lock_version.rb +5 -0
- data/db/migrate/20131002220041_file_based_themes.rb +12 -0
- data/db/migrate/20131008164204_create_head_tag_on_page.rb +19 -0
- data/db/migrate/20131008193544_drop_status_codes_model.rb +44 -0
- data/db/migrate/20131028145652_add_traffic_schema.rb +276 -0
- data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +7 -0
- data/db/migrate/20131104224120_add_meta_on_events.rb +7 -0
- data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +6 -0
- data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +9 -0
- data/db/migrate/20131108212501_traffic_owner_ids_are_serials.rb +20 -0
- data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +10 -0
- data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +6 -0
- data/db/migrate/20140128170659_file_backed_templates.rb +8 -0
- data/db/migrate/20140205193757_fix_status_codes.rb +24 -0
- data/db/migrate/20140206211322_add_response_time_to_traffic_page_views.rb +7 -0
- data/db/migrate/20140220170324_add_slug_to_categories.rb +14 -0
- data/db/migrate/20140220174630_add_abstract_and_hero_asset_to_pages_and_page_revisions.rb +8 -0
- data/db/migrate/20140224205516_rename_traffic_schema.rb +40 -0
- data/db/pgtap/pgtap.sql +9034 -0
- data/db/test/landable.access_tokens.sql +13 -0
- data/db/test/landable.assets.sql +16 -0
- data/db/test/landable.authors.sql +22 -0
- data/db/test/landable.categories.sql +9 -0
- data/db/test/landable.page_revisions.sql +41 -0
- data/db/test/landable.pages.sql +19 -0
- data/db/test/landable.templates.sql +15 -0
- data/db/test/landable.themes.sql +25 -0
- data/doc/schema/access_token.json +22 -0
- data/doc/schema/asset.json +65 -0
- data/doc/schema/author.json +30 -0
- data/doc/schema/directory.json +24 -0
- data/doc/schema/page.json +95 -0
- data/doc/schema/page_revision.json +70 -0
- data/doc/schema/theme.json +37 -0
- data/doc/schema/uuid.json +6 -0
- data/features/api/access_tokens.feature +84 -0
- data/features/api/assets.feature +46 -0
- data/features/api/cors.feature +25 -0
- data/features/api/pages.feature +42 -0
- data/features/api/preview.feature +16 -0
- data/features/api/templates.feature +33 -0
- data/features/api/themes.feature +33 -0
- data/features/liquid/body.feature +35 -0
- data/features/liquid/drops/categories.feature +54 -0
- data/features/liquid/tags.feature +168 -0
- data/features/public/content_types.feature +17 -0
- data/features/public/publishing.feature +45 -0
- data/features/public/status_codes.feature +25 -0
- data/features/public/views.feature +17 -0
- data/features/step_definitions/asset_steps.rb +60 -0
- data/features/step_definitions/core_api_steps.rb +139 -0
- data/features/step_definitions/debug_steps.rb +3 -0
- data/features/step_definitions/factory_steps.rb +124 -0
- data/features/step_definitions/html_steps.rb +9 -0
- data/features/step_definitions/liquid_steps.rb +79 -0
- data/features/step_definitions/revision_steps.rb +5 -0
- data/features/step_definitions/theme_steps.rb +43 -0
- data/features/support/env.rb +66 -0
- data/features/support/usefulness.rb +13 -0
- data/landable.gemspec +54 -0
- data/lib/generators/landable/collection/collection_generator.rb +0 -0
- data/lib/generators/landable/collection/templates/stylesheets/landable/%file_name%.less +0 -0
- data/lib/generators/landable/collection/templates/stylesheets/landable/%file_name%/mixins.less +0 -0
- data/lib/generators/landable/collection/templates/stylesheets/landable/%file_name%/variables.less +0 -0
- data/lib/generators/landable/component/component_generator.rb +0 -0
- data/lib/generators/landable/component/templates/javascripts/landable/%file_name%.less +0 -0
- data/lib/generators/landable/component/templates/stylesheets/landable/%file_name%.less +0 -0
- data/lib/generators/landable/install_generator.rb +19 -0
- data/lib/generators/landable/landable_generator.rb +22 -0
- data/lib/generators/templates/landable.rb +34 -0
- data/lib/landable.rb +30 -0
- data/lib/landable/configuration.rb +115 -0
- data/lib/landable/core_ext/ipaddr.rb +18 -0
- data/lib/landable/engine.rb +69 -0
- data/lib/landable/error.rb +16 -0
- data/lib/landable/inflections.rb +4 -0
- data/lib/landable/layout.rb +60 -0
- data/lib/landable/liquid.rb +27 -0
- data/lib/landable/liquid/asset_tags.rb +76 -0
- data/lib/landable/liquid/drops.rb +46 -0
- data/lib/landable/liquid/filters.rb +11 -0
- data/lib/landable/liquid/tags.rb +91 -0
- data/lib/landable/migration.rb +40 -0
- data/lib/landable/mime_types.rb +15 -0
- data/lib/landable/partial.rb +46 -0
- data/lib/landable/seeds.rb +36 -0
- data/lib/landable/traffic.rb +34 -0
- data/lib/landable/traffic/crawl_tracker.rb +9 -0
- data/lib/landable/traffic/noop_tracker.rb +8 -0
- data/lib/landable/traffic/ping_tracker.rb +9 -0
- data/lib/landable/traffic/scan_tracker.rb +9 -0
- data/lib/landable/traffic/scrape_tracker.rb +9 -0
- data/lib/landable/traffic/tracker.rb +283 -0
- data/lib/landable/traffic/user_tracker.rb +65 -0
- data/lib/landable/version.rb +10 -0
- data/lib/tasks/landable/cucumber.rake +67 -0
- data/lib/tasks/landable/data.rake +166 -0
- data/lib/tasks/landable/pgtap.rake +26 -0
- data/lib/tasks/landable/rdoc.rake +11 -0
- data/lib/tasks/landable/seed.rake +16 -0
- data/lib/tasks/landable/spec.rake +15 -0
- data/script/cucumber +10 -0
- data/spec/concerns/landable/has_assets_spec.rb +75 -0
- data/spec/concerns/landable/table_name_spec.rb +15 -0
- data/spec/concerns/landable/traffic/table_name_spec.rb +16 -0
- data/spec/controllers/concerns/landable/variables_concern_spec.rb +66 -0
- data/spec/controllers/landable/api/assets_controller_spec.rb +24 -0
- data/spec/controllers/landable/api/categories_controller_spec.rb +45 -0
- data/spec/controllers/landable/api/directories_controller_spec.rb +56 -0
- data/spec/controllers/landable/api/page_revisions_controller_spec.rb +29 -0
- data/spec/controllers/landable/api/pages_controller_spec.rb +271 -0
- data/spec/controllers/landable/api_controller_spec.rb +189 -0
- data/spec/controllers/public/preview/page_revisions_controller_spec.rb +41 -0
- data/spec/controllers/public/preview/pages_controller_spec.rb +36 -0
- data/spec/controllers/public/sitemap_controller_spec.rb +25 -0
- data/spec/decorators/page_decorator_spec.rb +90 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/foo.jpg +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/priority_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +5 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/priority.html.erb +18 -0
- data/spec/dummy/app/views/partials/_foobazz.html +1 -0
- data/spec/dummy/app/views/priority/show.html.erb +11 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +21 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +60 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/landable.rb +22 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/structure.sql +3736 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/asset.rb +29 -0
- data/spec/factories/authors.rb +12 -0
- data/spec/factories/category.rb +6 -0
- data/spec/factories/page_revision.rb +6 -0
- data/spec/factories/pages.rb +33 -0
- data/spec/factories/template.rb +13 -0
- data/spec/factories/theme.rb +14 -0
- data/spec/fixtures/assets/cthulhu.jpg +0 -0
- data/spec/fixtures/assets/panda.png +0 -0
- data/spec/fixtures/assets/sloth.png +0 -0
- data/spec/fixtures/assets/small.pdf +0 -0
- data/spec/helpers/pages_helper_spec.rb +35 -0
- data/spec/lib/landable/configuration_spec.rb +20 -0
- data/spec/lib/landable/layout_spec.rb +25 -0
- data/spec/lib/landable/liquid_spec.rb +24 -0
- data/spec/lib/landable/migration_spec.rb +51 -0
- data/spec/lib/landable/partial_spec.rb +84 -0
- data/spec/lib/landable/tracking_spec.rb +62 -0
- data/spec/lib/landable/traffic_spec.rb +45 -0
- data/spec/models/landable/access_token_spec.rb +13 -0
- data/spec/models/landable/asset_spec.rb +48 -0
- data/spec/models/landable/directory_spec.rb +36 -0
- data/spec/models/landable/page/errors_spec.rb +30 -0
- data/spec/models/landable/page_revision_spec.rb +75 -0
- data/spec/models/landable/page_spec.rb +377 -0
- data/spec/models/landable/template_spec.rb +47 -0
- data/spec/models/landable/theme_spec.rb +8 -0
- data/spec/responders/page_render_responder_spec.rb +43 -0
- data/spec/routing/public_page_route_spec.rb +36 -0
- data/spec/services/landable/authentication_service_spec.rb +61 -0
- data/spec/services/landable/render_service_spec.rb +103 -0
- data/spec/services/landable/tidy_service_spec.rb +157 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/behaviors.rb +107 -0
- data/spec/support/carrier_wave.rb +17 -0
- data/spec/support/categories.yml +2 -0
- data/spec/support/helpers.rb +22 -0
- metadata +795 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Landable::ApiController, json: true do
|
|
4
|
+
controller(Landable::ApiController) do
|
|
5
|
+
skip_before_filter :require_author!, except: [:index]
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
render nothing: true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def ok
|
|
12
|
+
render nothing: true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def responder
|
|
16
|
+
respond_with @resource
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update_responder
|
|
20
|
+
respond_with @resource
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def not_found
|
|
24
|
+
raise ActiveRecord::RecordNotFound
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def xml_only
|
|
28
|
+
respond_to do |format|
|
|
29
|
+
format.xml { render xml: '<lol/>' }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def record_invalid
|
|
34
|
+
Landable::Page.create!
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def uuid_invalid
|
|
38
|
+
Landable::Page.find('1')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def other_pg_error
|
|
42
|
+
ActiveRecord::Base.connection.execute "LOL THIS IS NOT SQL AT ALL GUYS!"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
before do
|
|
47
|
+
routes.draw do
|
|
48
|
+
get 'index' => 'anonymous#index'
|
|
49
|
+
get 'ok' => 'anonymous#ok'
|
|
50
|
+
get 'responder' => 'anonymous#responder'
|
|
51
|
+
patch 'responder' => 'anonymous#responder'
|
|
52
|
+
put 'responder' => 'anonymous#responder'
|
|
53
|
+
get 'not_found' => 'anonymous#not_found'
|
|
54
|
+
get 'xml_only' => 'anonymous#xml_only'
|
|
55
|
+
get 'record_invalid' => 'anonymous#record_invalid'
|
|
56
|
+
get 'uuid_invalid' => 'anonymous#uuid_invalid'
|
|
57
|
+
get 'other_pg_error' => 'anonymous#other_pg_error'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe 'access token' do
|
|
62
|
+
let(:author) { create :author }
|
|
63
|
+
let(:token) { create :access_token, author: author }
|
|
64
|
+
let(:headers) do
|
|
65
|
+
{ 'HTTP_AUTHORIZATION' => encode_basic_auth(author.username, token.id) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def make_request(params = nil)
|
|
69
|
+
request.env.merge!(headers)
|
|
70
|
+
get :index, params
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "sets current_author when valid" do
|
|
74
|
+
make_request
|
|
75
|
+
controller.send(:current_author).should == author
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "must be in the HTTP Authorization header" do
|
|
79
|
+
headers.delete 'HTTP_AUTHORIZATION'
|
|
80
|
+
make_request access_token: token.id
|
|
81
|
+
response.status.should == 401
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "must belong to a valid Author username" do
|
|
85
|
+
headers['HTTP_AUTHORIZATION'] = encode_basic_auth('wrong-username', token.id)
|
|
86
|
+
make_request
|
|
87
|
+
response.status.should == 401
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "must be an existing token ID" do
|
|
91
|
+
headers['HTTP_AUTHORIZATION'] = encode_basic_auth(author.username, token.id.reverse)
|
|
92
|
+
make_request
|
|
93
|
+
response.status.should == 401
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it "must not be expired" do
|
|
97
|
+
token.update_attributes(expires_at: 1.minute.ago)
|
|
98
|
+
make_request
|
|
99
|
+
response.status.should == 401
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
context 'rescues RecordNotFound' do
|
|
104
|
+
it 'returns 404 Not Found' do
|
|
105
|
+
get :not_found
|
|
106
|
+
response.status.should == 404
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context 'rescues RecordInvalid' do
|
|
111
|
+
it 'returns 422 Unprocessable Entity' do
|
|
112
|
+
get :record_invalid
|
|
113
|
+
response.status.should == 422
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'renders ActiveModel::Errors as the JSON response' do
|
|
117
|
+
get :record_invalid
|
|
118
|
+
last_json['errors'].should have_key('path')
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
context 'rescues UnknownFormat' do
|
|
123
|
+
it 'returns 406 Not Acceptable' do
|
|
124
|
+
request.env['HTTP_ACCEPT'] = 'text/plain'
|
|
125
|
+
get :xml_only
|
|
126
|
+
response.status.should == 406
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
context 'rescues PG::Errors about invalid UUIDs' do
|
|
131
|
+
it 'returns 404' do
|
|
132
|
+
get :uuid_invalid
|
|
133
|
+
response.status.should == 404
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 're-raises any other PG::Error' do
|
|
137
|
+
expect {
|
|
138
|
+
get :other_pg_error
|
|
139
|
+
}.to raise_error(PG::Error)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
describe '#api_media' do
|
|
144
|
+
let(:headers) { {} }
|
|
145
|
+
|
|
146
|
+
it 'should match the request format and api version' do
|
|
147
|
+
request.env['HTTP_ACCEPT'] = 'application/xml'
|
|
148
|
+
|
|
149
|
+
get :ok
|
|
150
|
+
|
|
151
|
+
# sanity check
|
|
152
|
+
request.format.symbol.should == :xml
|
|
153
|
+
|
|
154
|
+
controller.api_media.should == {
|
|
155
|
+
format: request.format.symbol,
|
|
156
|
+
version: Landable::VERSION::STRING,
|
|
157
|
+
param: nil,
|
|
158
|
+
}
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
describe 'responder' do
|
|
163
|
+
before(:each) do
|
|
164
|
+
controller.instance_variable_set :@resource, resource
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
let(:resource) { build :author }
|
|
168
|
+
|
|
169
|
+
it 'should set X-Landable-Media-Type' do
|
|
170
|
+
get :responder
|
|
171
|
+
response.status.should == 200
|
|
172
|
+
response.headers['X-Landable-Media-Type'].should == "landable.v#{Landable::VERSION::STRING}; format=json"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
context 'patch' do
|
|
176
|
+
it 'should display the resource' do
|
|
177
|
+
put :responder
|
|
178
|
+
response.body.should_not be_empty
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
context 'put' do
|
|
183
|
+
it 'should display the resource' do
|
|
184
|
+
put :responder
|
|
185
|
+
response.body.should_not be_empty
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Landable::Public::Preview
|
|
4
|
+
describe PageRevisionsController do
|
|
5
|
+
routes { Landable::Engine.routes }
|
|
6
|
+
|
|
7
|
+
describe '#show' do
|
|
8
|
+
|
|
9
|
+
let(:author) { create :author }
|
|
10
|
+
let(:page) { create :page, body: '<p>hello</p>' }
|
|
11
|
+
let(:page_revision) do
|
|
12
|
+
page.publish! author: author
|
|
13
|
+
page.revisions.first
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
before(:each) do
|
|
17
|
+
# establish the tested-for revision
|
|
18
|
+
page_revision
|
|
19
|
+
|
|
20
|
+
2.times do |i|
|
|
21
|
+
page.update_attributes! body: "update #{i}"
|
|
22
|
+
page.publish! author: author
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def make_request
|
|
27
|
+
get :show, id: page_revision.id
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'renders the page revision' do
|
|
31
|
+
make_request
|
|
32
|
+
response.body.should include '<p>hello</p>'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'is available at /-/pr/:id' do
|
|
36
|
+
assert_recognizes({controller: 'landable/public/preview/page_revisions', action: 'show', id: page_revision.id}, "/-/pr/#{page_revision.id}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Landable::Public::Preview
|
|
4
|
+
describe PagesController do
|
|
5
|
+
routes { Landable::Engine.routes }
|
|
6
|
+
|
|
7
|
+
describe '#show' do
|
|
8
|
+
|
|
9
|
+
let(:page) { create :page, body: '<p>hello</p>' }
|
|
10
|
+
|
|
11
|
+
before(:each) do
|
|
12
|
+
page.publish! author: create(:author)
|
|
13
|
+
page.update_attributes! body: '<p>why hello there</p>'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def make_request
|
|
17
|
+
get :show, id: page.id
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'renders the page in situ' do
|
|
21
|
+
make_request
|
|
22
|
+
response.body.should include '<p>why hello there</p>'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'renders the preview message' do
|
|
26
|
+
make_request
|
|
27
|
+
response.body.should include 'Test your unpublished changes with this page. Share this URL!'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'is available at /-/p/:id' do
|
|
31
|
+
assert_recognizes({controller: 'landable/public/preview/pages', action: 'show', id: page.id}, "/-/p/#{page.id}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Landable::Public
|
|
4
|
+
describe SitemapController do
|
|
5
|
+
routes { Landable::Engine.routes }
|
|
6
|
+
|
|
7
|
+
it 'returns a 200 status' do
|
|
8
|
+
get :index
|
|
9
|
+
response.status.should == 200
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'returns xml' do
|
|
13
|
+
get :index
|
|
14
|
+
response.content_type.should == 'application/xml'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'calls generate_sitemap with appropriate arguments' do
|
|
18
|
+
Landable::Page.should_receive(:generate_sitemap).with(host: 'test.host',
|
|
19
|
+
protocol: 'https',
|
|
20
|
+
exclude_categories: ['Testing'],
|
|
21
|
+
sitemap_additional_paths: ['/terms.html']).and_call_original
|
|
22
|
+
get :index, format: :xml
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Landable
|
|
4
|
+
describe PageDecorator do
|
|
5
|
+
let(:page_decorator) { Landable::PageDecorator.new(page) }
|
|
6
|
+
|
|
7
|
+
describe '#title' do
|
|
8
|
+
let(:page) { create :page, title: 'title'}
|
|
9
|
+
|
|
10
|
+
it 'lists the title' do
|
|
11
|
+
page_decorator.title.should == "<title>title</title>"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context 'nil' do
|
|
15
|
+
let(:page) { create :page, title: nil }
|
|
16
|
+
|
|
17
|
+
it 'returns nil' do
|
|
18
|
+
page_decorator.title.should be_nil
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#path' do
|
|
24
|
+
let(:page) { create :page, path: "/landable" }
|
|
25
|
+
|
|
26
|
+
it 'lists the path' do
|
|
27
|
+
page_decorator.path.should == "/landable"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#body' do
|
|
32
|
+
let(:page) { create :page, body: "Buy pounds for your pocket" }
|
|
33
|
+
|
|
34
|
+
it 'lists the body' do
|
|
35
|
+
page_decorator.body.should == "Buy pounds for your pocket"
|
|
36
|
+
page_decorator.body.should be_html_safe
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'nil' do
|
|
40
|
+
let(:page) { create :page, head_content: nil }
|
|
41
|
+
|
|
42
|
+
it 'returns nil' do
|
|
43
|
+
page_decorator.head_content.should be_nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '#head_content' do
|
|
49
|
+
let(:page) { create :page, head_content: "<head lang='en' />" }
|
|
50
|
+
|
|
51
|
+
it 'lists the head_tags seperated by a new line' do
|
|
52
|
+
page_decorator.head_content.should == "<head lang='en' />"
|
|
53
|
+
page_decorator.head_content.should be_html_safe
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'nil' do
|
|
57
|
+
let(:page) { create :page, head_content: nil }
|
|
58
|
+
|
|
59
|
+
it 'returns nil' do
|
|
60
|
+
page_decorator.head_content.should be_nil
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe '#meta_tags' do
|
|
66
|
+
let(:page) { create :page, meta_tags: { content: 'robots', keyword: 'p2p' } }
|
|
67
|
+
|
|
68
|
+
it 'lists the meta_tags seperated by a new line' do
|
|
69
|
+
page_decorator.meta_tags.should == %Q(<meta content="robots" name="content" />\n<meta content="p2p" name="keyword" />)
|
|
70
|
+
page_decorator.meta_tags.should be_html_safe
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context 'nil' do
|
|
74
|
+
let(:page) { create :page, meta_tags: nil }
|
|
75
|
+
|
|
76
|
+
it 'returns nil' do
|
|
77
|
+
page_decorator.meta_tags.should be_nil
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context 'string' do
|
|
82
|
+
let(:page) { create :page, meta_tags: "I should be a hash!" }
|
|
83
|
+
|
|
84
|
+
it 'returns nil' do
|
|
85
|
+
page_decorator.meta_tags.should be_nil
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
// 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_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
|
+
*/
|