landable 1.13.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +281 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +3 -4
- data/README.md +2 -0
- data/Rakefile +6 -3
- data/app/controllers/concerns/landable/variables_concern.rb +9 -9
- data/app/controllers/landable/api/access_tokens_controller.rb +7 -8
- data/app/controllers/landable/api/assets_controller.rb +29 -26
- data/app/controllers/landable/api/audits_controller.rb +6 -5
- data/app/controllers/landable/api/configurations_controller.rb +1 -1
- data/app/controllers/landable/api/directories_controller.rb +2 -2
- data/app/controllers/landable/api/page_revisions_controller.rb +2 -4
- data/app/controllers/landable/api/pages_controller.rb +39 -40
- data/app/controllers/landable/api/template_revisions_controller.rb +1 -2
- data/app/controllers/landable/api/templates_controller.rb +15 -14
- data/app/controllers/landable/api/themes_controller.rb +15 -14
- data/app/controllers/landable/api_controller.rb +10 -11
- data/app/controllers/landable/public/pages_controller.rb +2 -2
- data/app/controllers/landable/public/preview/page_revisions_controller.rb +2 -2
- data/app/controllers/landable/public/preview/pages_controller.rb +1 -1
- data/app/controllers/landable/public/sitemap_controller.rb +2 -2
- data/app/decorators/landable/page_decorator.rb +3 -3
- data/app/helpers/landable/pages_helper.rb +2 -2
- data/app/helpers/landable/traffic_helper.rb +2 -4
- data/app/models/concerns/landable/has_assets.rb +6 -9
- data/app/models/concerns/landable/has_templates.rb +6 -7
- data/app/models/concerns/landable/librarian.rb +5 -5
- data/app/models/concerns/landable/table_name.rb +2 -2
- data/app/models/landable/access_token.rb +1 -1
- data/app/models/landable/asset.rb +8 -8
- data/app/models/landable/asset_search_engine.rb +7 -8
- data/app/models/landable/author.rb +2 -1
- data/app/models/landable/category.rb +1 -3
- data/app/models/landable/directory.rb +2 -2
- data/app/models/landable/page.rb +44 -50
- data/app/models/landable/page_revision.rb +27 -41
- data/app/models/landable/page_search_engine.rb +5 -6
- data/app/models/landable/search_engine.rb +2 -2
- data/app/models/landable/template.rb +9 -11
- data/app/models/landable/template_revision.rb +4 -14
- data/app/models/landable/theme.rb +1 -1
- data/app/models/landable/traffic/attribution.rb +3 -1
- data/app/models/landable/traffic/page_view.rb +1 -1
- data/app/models/landable/traffic/user_agent.rb +1 -1
- data/app/models/landable/traffic/visit.rb +1 -1
- data/app/responders/landable/api_responder.rb +5 -3
- data/app/responders/landable/page_render_responder.rb +1 -1
- data/app/serializers/landable/asset_serializer.rb +1 -1
- data/app/serializers/landable/audit_serializer.rb +2 -3
- data/app/serializers/landable/directory_serializer.rb +2 -2
- data/app/serializers/landable/page_revision_serializer.rb +0 -1
- data/app/serializers/landable/page_serializer.rb +5 -5
- data/app/serializers/landable/template_serializer.rb +2 -2
- data/app/services/landable/authentication_service.rb +1 -1
- data/app/services/landable/registration_service.rb +3 -2
- data/app/services/landable/render_service.rb +16 -18
- data/app/services/landable/screenshot_service.rb +3 -4
- data/app/services/landable/tidy_service.rb +32 -37
- data/app/validators/path_validator.rb +1 -3
- data/app/validators/url_validator.rb +4 -7
- data/config/routes.rb +3 -6
- data/db/migrate/20130510221424_create_landable_schema.rb +45 -56
- data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +2 -2
- data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +9 -12
- data/db/migrate/20131002220041_file_based_themes.rb +3 -3
- data/db/migrate/20131008164204_create_head_tag_on_page.rb +4 -4
- data/db/migrate/20131008193544_drop_status_codes_model.rb +1 -2
- data/db/migrate/20131028145652_add_traffic_schema.rb +5 -5
- data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +1 -1
- data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +1 -1
- data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +1 -1
- data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +2 -2
- data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +3 -3
- data/db/migrate/20140128170659_file_backed_templates.rb +1 -1
- data/db/migrate/20140205193757_fix_status_codes.rb +3 -3
- data/db/migrate/20140220170324_add_slug_to_categories.rb +1 -1
- data/db/migrate/20140224205516_rename_traffic_schema.rb +7 -9
- data/db/migrate/20140509190128_create_template_revisions.rb +13 -15
- data/db/migrate/20140509192856_create_audits.rb +3 -3
- data/db/migrate/20140602213937_path_response_time_view.rb +20 -19
- data/features/step_definitions/asset_steps.rb +10 -12
- data/features/step_definitions/core_api_steps.rb +29 -27
- data/features/step_definitions/factory_steps.rb +16 -16
- data/features/step_definitions/html_steps.rb +1 -1
- data/features/step_definitions/liquid_steps.rb +8 -8
- data/features/step_definitions/theme_steps.rb +4 -4
- data/features/support/env.rb +5 -5
- data/landable.gemspec +2 -2
- data/lib/generators/landable/landable_generator.rb +2 -2
- data/lib/generators/templates/landable.rb +1 -1
- data/lib/landable.rb +7 -7
- data/lib/landable/configuration.rb +10 -19
- data/lib/landable/engine.rb +19 -19
- data/lib/landable/error.rb +1 -3
- data/lib/landable/layout.rb +6 -6
- data/lib/landable/liquid/asset_tags.rb +3 -5
- data/lib/landable/liquid/drops.rb +3 -8
- data/lib/landable/liquid/filters.rb +1 -3
- data/lib/landable/liquid/tags.rb +10 -10
- data/lib/landable/migration.rb +30 -30
- data/lib/landable/mime_types.rb +1 -1
- data/lib/landable/partial.rb +2 -2
- data/lib/landable/seeds.rb +3 -4
- data/lib/landable/traffic.rb +4 -8
- data/lib/landable/traffic/tracker.rb +48 -43
- data/lib/landable/traffic/user_tracker.rb +15 -10
- data/lib/landable/version.rb +1 -1
- data/lib/schema_moves.rb +15 -16
- data/lib/tasks/landable/cucumber.rake +46 -47
- data/lib/tasks/landable/data.rake +13 -14
- data/lib/tasks/landable/pgtap.rake +12 -18
- data/lib/tasks/landable/seed.rake +4 -4
- data/spec/concerns/landable/has_assets_spec.rb +15 -19
- data/spec/concerns/landable/has_templates_spec.rb +10 -13
- data/spec/concerns/landable/librarian.rb +4 -4
- data/spec/concerns/landable/table_name_spec.rb +3 -5
- data/spec/concerns/landable/traffic/table_name_spec.rb +2 -4
- data/spec/controllers/concerns/landable/variables_concern_spec.rb +11 -10
- data/spec/controllers/landable/api/assets_controller_spec.rb +15 -14
- data/spec/controllers/landable/api/audits_controller_spec.rb +104 -102
- data/spec/controllers/landable/api/categories_controller_spec.rb +36 -34
- data/spec/controllers/landable/api/configuration_controller_spec.rb +14 -12
- data/spec/controllers/landable/api/directories_controller_spec.rb +52 -50
- data/spec/controllers/landable/api/page_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/pages_controller_spec.rb +204 -203
- data/spec/controllers/landable/api/template_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/templates_controller_spec.rb +39 -37
- data/spec/controllers/landable/api_controller_spec.rb +24 -26
- data/spec/controllers/public/preview/page_revisions_controller_spec.rb +36 -34
- data/spec/controllers/public/preview/pages_controller_spec.rb +32 -30
- data/spec/controllers/public/sitemap_controller_spec.rb +19 -17
- data/spec/decorators/page_decorator_spec.rb +9 -9
- data/spec/dummy/app/helpers/application_helper.rb +1 -1
- data/spec/dummy/config/application.rb +5 -6
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/landable.rb +7 -6
- data/spec/factories/asset.rb +1 -1
- data/spec/factories/audit.rb +1 -1
- data/spec/factories/authors.rb +1 -1
- data/spec/factories/category.rb +1 -1
- data/spec/factories/pages.rb +4 -4
- data/spec/factories/template.rb +3 -3
- data/spec/factories/theme.rb +2 -2
- data/spec/helpers/pages_helper_spec.rb +5 -5
- data/spec/lib/landable/configuration_spec.rb +2 -4
- data/spec/lib/landable/event_publisher_spec.rb +1 -3
- data/spec/lib/landable/layout_spec.rb +4 -4
- data/spec/lib/landable/liquid_spec.rb +12 -14
- data/spec/lib/landable/migration_spec.rb +4 -4
- data/spec/lib/landable/partial_spec.rb +18 -18
- data/spec/lib/landable/tracking_spec.rb +27 -29
- data/spec/lib/landable/traffic_spec.rb +29 -33
- data/spec/models/landable/access_token_spec.rb +1 -1
- data/spec/models/landable/asset_spec.rb +9 -11
- data/spec/models/landable/directory_spec.rb +7 -7
- data/spec/models/landable/page/errors_spec.rb +1 -3
- data/spec/models/landable/page_revision_spec.rb +23 -24
- data/spec/models/landable/page_spec.rb +41 -42
- data/spec/models/landable/template_revision_spec.rb +3 -3
- data/spec/models/landable/template_spec.rb +11 -11
- data/spec/models/landable/theme_spec.rb +2 -2
- data/spec/models/landable/traffic/referer_spec.rb +3 -3
- data/spec/responders/page_render_responder_spec.rb +0 -2
- data/spec/routing/public_page_route_spec.rb +4 -5
- data/spec/services/landable/authentication_service_spec.rb +7 -7
- data/spec/services/landable/render_service_spec.rb +8 -8
- data/spec/services/landable/screenshot_service_spec.rb +3 -3
- data/spec/services/landable/tidy_service_spec.rb +20 -20
- data/spec/spec_helper.rb +3 -3
- data/spec/support/behaviors.rb +4 -4
- data/spec/support/helpers.rb +1 -1
- metadata +86 -35
- checksums.yaml +0 -7
@@ -3,8 +3,8 @@ class LandablePagesAddUpdatedBy < Landable::Migration
|
|
3
3
|
add_column "#{Landable.configuration.database_schema_prefix}landable.pages", :updated_by_author_id, :uuid
|
4
4
|
|
5
5
|
execute <<-SQL
|
6
|
-
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.pages
|
7
|
-
ADD CONSTRAINT updated_author_fk FOREIGN KEY(updated_by_author_id)
|
6
|
+
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.pages
|
7
|
+
ADD CONSTRAINT updated_author_fk FOREIGN KEY(updated_by_author_id)
|
8
8
|
REFERENCES #{Landable.configuration.database_schema_prefix}landable.authors(author_id)
|
9
9
|
SQL
|
10
10
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require_dependency 'landable/page_revision'
|
2
2
|
class LandablePageRevisionsBreakOutSnapshot < Landable::Migration
|
3
|
-
|
4
3
|
class Landable::PageRevision < ActiveRecord::Base
|
5
4
|
store :snapshot_attributes, accessors: [:body]
|
6
5
|
end
|
7
6
|
|
8
7
|
def up
|
9
|
-
|
10
8
|
# Setup new columns
|
11
9
|
add_column "#{Landable.configuration.database_schema_prefix}landable.page_revisions", :theme_id, :uuid
|
12
10
|
add_column "#{Landable.configuration.database_schema_prefix}landable.page_revisions", :status_code_id, :uuid
|
@@ -19,18 +17,18 @@ class LandablePageRevisionsBreakOutSnapshot < Landable::Migration
|
|
19
17
|
add_column "#{Landable.configuration.database_schema_prefix}landable.page_revisions", :head_tags, :hstore
|
20
18
|
|
21
19
|
execute <<-SQL
|
22
|
-
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
23
|
-
ADD CONSTRAINT theme_id_fk FOREIGN KEY(theme_id)
|
20
|
+
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
21
|
+
ADD CONSTRAINT theme_id_fk FOREIGN KEY(theme_id)
|
24
22
|
REFERENCES #{Landable.configuration.database_schema_prefix}landable.themes(theme_id);
|
25
|
-
|
26
|
-
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
27
|
-
ADD CONSTRAINT status_code_id_fk FOREIGN KEY(status_code_id)
|
23
|
+
|
24
|
+
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
25
|
+
ADD CONSTRAINT status_code_id_fk FOREIGN KEY(status_code_id)
|
28
26
|
REFERENCES #{Landable.configuration.database_schema_prefix}landable.status_codes(status_code_id);
|
29
27
|
|
30
|
-
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
31
|
-
ADD CONSTRAINT category_id_fk FOREIGN KEY(category_id)
|
28
|
+
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
29
|
+
ADD CONSTRAINT category_id_fk FOREIGN KEY(category_id)
|
32
30
|
REFERENCES #{Landable.configuration.database_schema_prefix}landable.categories(category_id);
|
33
|
-
|
31
|
+
SQL
|
34
32
|
|
35
33
|
# Go through each record and copy snapshot into new, broken-out columns
|
36
34
|
Landable::PageRevision.all.each do |rev|
|
@@ -63,10 +61,9 @@ class LandablePageRevisionsBreakOutSnapshot < Landable::Migration
|
|
63
61
|
ON #{Landable.configuration.database_schema_prefix}landable.page_revisions
|
64
62
|
FOR EACH STATEMENT EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.tg_disallow();
|
65
63
|
SQL
|
66
|
-
|
67
64
|
end
|
68
65
|
|
69
66
|
def down
|
70
|
-
|
67
|
+
fail ActiveRecord::IrreversibleMigration
|
71
68
|
end
|
72
69
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class FileBasedThemes < Landable::Migration
|
2
2
|
def up
|
3
3
|
change_table "#{Landable.configuration.database_schema_prefix}landable.themes" do |t|
|
4
|
-
t.text
|
5
|
-
t.text
|
4
|
+
t.text :file
|
5
|
+
t.text :extension
|
6
6
|
t.boolean :editable, null: false, default: true
|
7
7
|
end
|
8
8
|
|
9
|
-
execute "CREATE UNIQUE INDEX #{Landable.configuration.database_schema_prefix}landable_themes__u_file
|
9
|
+
execute "CREATE UNIQUE INDEX #{Landable.configuration.database_schema_prefix}landable_themes__u_file
|
10
10
|
ON #{Landable.configuration.database_schema_prefix}landable.themes(lower(file))"
|
11
11
|
end
|
12
12
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class CreateHeadTagOnPage < Landable::Migration
|
2
2
|
def up
|
3
|
-
execute "DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
3
|
+
execute "DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
4
4
|
ON #{Landable.configuration.database_schema_prefix}landable.page_revisions"
|
5
5
|
|
6
|
-
drop_table
|
6
|
+
drop_table "#{Landable.configuration.database_schema_prefix}landable.head_tags"
|
7
7
|
remove_column "#{Landable.configuration.database_schema_prefix}landable.page_revisions", :head_tags
|
8
8
|
|
9
|
-
add_column
|
10
|
-
add_column
|
9
|
+
add_column "#{Landable.configuration.database_schema_prefix}landable.pages", :head_content, :text
|
10
|
+
add_column "#{Landable.configuration.database_schema_prefix}landable.page_revisions", :head_content, :text
|
11
11
|
|
12
12
|
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
13
13
|
BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require_dependency 'landable/page'
|
2
2
|
class DropStatusCodesModel < Landable::Migration
|
3
|
-
|
4
3
|
class Landable::StatusCode < ActiveRecord::Base
|
5
4
|
self.table_name = "#{Landable.configuration.database_schema_prefix}landable.status_codes"
|
6
5
|
end
|
@@ -26,7 +25,7 @@ class DropStatusCodesModel < Landable::Migration
|
|
26
25
|
execute <<-SQL
|
27
26
|
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.pages DROP CONSTRAINT status_code_fk;
|
28
27
|
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable.page_revisions DROP CONSTRAINT status_code_id_fk;
|
29
|
-
DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
28
|
+
DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
30
29
|
ON #{Landable.configuration.database_schema_prefix}landable.page_revisions;
|
31
30
|
CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
32
31
|
BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal
|
@@ -4,7 +4,7 @@ class AddTrafficSchema < Landable::Migration
|
|
4
4
|
|
5
5
|
OWNER_TYPE = 'INTEGER'
|
6
6
|
|
7
|
-
QUERY_PARAMS = %w
|
7
|
+
QUERY_PARAMS = %w(
|
8
8
|
ad_type
|
9
9
|
ad_group
|
10
10
|
bid_match_type
|
@@ -22,7 +22,7 @@ class AddTrafficSchema < Landable::Migration
|
|
22
22
|
search_term
|
23
23
|
source
|
24
24
|
target
|
25
|
-
|
25
|
+
)
|
26
26
|
|
27
27
|
def up
|
28
28
|
# Resources
|
@@ -46,10 +46,10 @@ class AddTrafficSchema < Landable::Migration
|
|
46
46
|
t.create_lookup_tables :domains, :paths, :query_strings
|
47
47
|
t.create_lookup_tables :http_methods, :mime_types
|
48
48
|
|
49
|
-
t.create_lookup_table
|
49
|
+
t.create_lookup_table :event_types
|
50
50
|
|
51
51
|
# IP / Geolocation
|
52
|
-
t.create_lookup_table
|
52
|
+
t.create_lookup_table :ip_addresses, lookup_type: :inet
|
53
53
|
t.create_lookup_tables :countries, :regions, :cities
|
54
54
|
end
|
55
55
|
|
@@ -94,7 +94,7 @@ class AddTrafficSchema < Landable::Migration
|
|
94
94
|
CREATE TABLE attributions (
|
95
95
|
attribution_id SERIAL PRIMARY KEY
|
96
96
|
|
97
|
-
, #{QUERY_PARAMS.map { |name|
|
97
|
+
, #{QUERY_PARAMS.map { |name| format('%s INTEGER REFERENCES %s', name.foreign_key, name.pluralize) }.join(',')}
|
98
98
|
|
99
99
|
, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
100
100
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class AddIndexOnPageRevisionsPath < Landable::Migration
|
2
2
|
def up
|
3
|
-
execute "CREATE INDEX #{Landable.configuration.database_schema_prefix}landable_page_revisions__path
|
3
|
+
execute "CREATE INDEX #{Landable.configuration.database_schema_prefix}landable_page_revisions__path
|
4
4
|
ON #{Landable.configuration.database_schema_prefix}landable.page_revisions(path)"
|
5
5
|
end
|
6
6
|
end
|
@@ -2,7 +2,7 @@ class PageRevisisonsPathStatusCodeIndex < Landable::Migration
|
|
2
2
|
def up
|
3
3
|
execute <<-SQL
|
4
4
|
DROP INDEX #{Landable.configuration.database_schema_prefix}landable.#{Landable.configuration.database_schema_prefix}landable_page_revisions__path;
|
5
|
-
CREATE INDEX #{Landable.configuration.database_schema_prefix}landable_page_revisions__path_status_code
|
5
|
+
CREATE INDEX #{Landable.configuration.database_schema_prefix}landable_page_revisions__path_status_code
|
6
6
|
ON #{Landable.configuration.database_schema_prefix}landable.page_revisions(path, status_code);
|
7
7
|
SQL
|
8
8
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class AddAttributionIdToUniqueIndex < Landable::Migration
|
2
2
|
def up
|
3
3
|
execute <<-SQL
|
4
|
-
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable_traffic.referers
|
4
|
+
ALTER TABLE #{Landable.configuration.database_schema_prefix}landable_traffic.referers
|
5
5
|
DROP CONSTRAINT referers_domain_id_path_id_query_string_id_key;
|
6
|
-
CREATE UNIQUE INDEX referers_domain_id_path_id_query_string_id_attribution_id
|
6
|
+
CREATE UNIQUE INDEX referers_domain_id_path_id_query_string_id_attribution_id
|
7
7
|
ON #{Landable.configuration.database_schema_prefix}landable_traffic.referers(domain_id, path_id, query_string_id, attribution_id);
|
8
8
|
SQL
|
9
9
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class DropBrowserScreenshotTables < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
drop_table
|
4
|
-
drop_table
|
3
|
+
drop_table "#{Landable.configuration.database_schema_prefix}landable.screenshots"
|
4
|
+
drop_table "#{Landable.configuration.database_schema_prefix}landable.browsers"
|
5
5
|
end
|
6
|
-
end
|
6
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
class FixStatusCodes < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
execute "DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
3
|
+
execute "DROP TRIGGER #{Landable.configuration.database_schema_prefix}landable_page_revisions__no_update
|
4
4
|
ON #{Landable.configuration.database_schema_prefix}landable.page_revisions"
|
5
5
|
|
6
6
|
# Find Pages with 404s, switch to 410s, publish the page!
|
7
|
-
Landable::Page.where(status_code: 404).find_each do |page|
|
7
|
+
Landable::Page.where(status_code: 404).find_each do |page|
|
8
8
|
page.status_code = 410
|
9
9
|
page.save!
|
10
10
|
end
|
11
11
|
|
12
12
|
# Find Remaining PageRevisions with 404s, switch to 410s!
|
13
|
-
Landable::PageRevision.where(status_code: 404).find_each do |page|
|
13
|
+
Landable::PageRevision.where(status_code: 404).find_each do |page|
|
14
14
|
page.status_code = 410
|
15
15
|
page.save!
|
16
16
|
end
|
@@ -3,7 +3,7 @@ class AddSlugToCategories < Landable::Migration
|
|
3
3
|
add_column "#{Landable.configuration.database_schema_prefix}landable.categories", :slug, :text, unique: true
|
4
4
|
|
5
5
|
Landable::Category.reset_column_information
|
6
|
-
Landable::Category.all.each
|
6
|
+
Landable::Category.all.each(&:save!)
|
7
7
|
|
8
8
|
change_column "#{Landable.configuration.database_schema_prefix}landable.categories", :slug, :text, null: false
|
9
9
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
class RenameTrafficSchema < Landable::Migration
|
2
|
-
|
3
2
|
def traffic_schema
|
4
3
|
"#{Landable.configuration.database_schema_prefix}landable_traffic"
|
5
4
|
end
|
6
5
|
|
7
6
|
def schema_exists(schema)
|
8
|
-
execute("SELECT COUNT(*) FROM pg_namespace WHERE nspname = '#{schema}'")[0][
|
7
|
+
execute("SELECT COUNT(*) FROM pg_namespace WHERE nspname = '#{schema}'")[0]['count'] == '1'
|
9
8
|
end
|
10
9
|
|
11
10
|
def move_objects(from_schema, to_schema, relkind, object_type)
|
@@ -21,20 +20,19 @@ class RenameTrafficSchema < Landable::Migration
|
|
21
20
|
")
|
22
21
|
|
23
22
|
objects.each do |object|
|
24
|
-
sql = %
|
23
|
+
sql = %(
|
25
24
|
ALTER #{object_type} #{from_schema}.#{object['relname']}
|
26
25
|
SET SCHEMA #{to_schema}
|
27
|
-
|
26
|
+
)
|
28
27
|
puts "Moving #{from_schema}.#{object['relname']} TO #{to_schema}"
|
29
28
|
execute sql
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
def up
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
33
|
+
return unless schema_exists('traffic')
|
34
|
+
execute("CREATE SCHEMA #{traffic_schema}")
|
35
|
+
move_objects('traffic', "#{traffic_schema}", 'r', 'TABLE')
|
36
|
+
move_objects('traffic', "#{traffic_schema}", 'S', 'SEQUENCE')
|
39
37
|
end
|
40
38
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
class CreateTemplateRevisions < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table "#{Landable.configuration.database_schema_prefix}landable.template_revisions", id: :uuid, primary_key: :template_revision_id do |t|
|
4
|
-
t.integer
|
5
|
-
t.text
|
6
|
-
t.boolean
|
7
|
-
t.boolean
|
4
|
+
t.integer :ordinal
|
5
|
+
t.text :notes
|
6
|
+
t.boolean :is_minor, default: false
|
7
|
+
t.boolean :is_published, default: true
|
8
8
|
|
9
|
-
t.uuid
|
10
|
-
t.uuid
|
9
|
+
t.uuid :template_id, null: false
|
10
|
+
t.uuid :author_id, null: false
|
11
11
|
|
12
|
-
t.text
|
13
|
-
t.text
|
14
|
-
t.text
|
15
|
-
t.text
|
12
|
+
t.text :name
|
13
|
+
t.text :slug
|
14
|
+
t.text :body
|
15
|
+
t.text :description
|
16
16
|
|
17
17
|
t.timestamps
|
18
18
|
end
|
@@ -59,9 +59,9 @@ class CreateTemplateRevisions < ActiveRecord::Migration
|
|
59
59
|
$TRIGGER$
|
60
60
|
LANGUAGE plpgsql;"
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_template_revisions__bfr_insert
|
63
|
+
BEFORE INSERT ON #{Landable.configuration.database_schema_prefix}landable.template_revisions
|
64
|
+
FOR EACH ROW EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.template_revision_ordinal();"
|
65
65
|
|
66
66
|
# Trigger disallowing deletes on template_revisions
|
67
67
|
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_template_revisions__no_delete
|
@@ -71,7 +71,5 @@ class CreateTemplateRevisions < ActiveRecord::Migration
|
|
71
71
|
execute "CREATE TRIGGER #{Landable.configuration.database_schema_prefix}landable_template_revisions__no_update
|
72
72
|
BEFORE UPDATE OF notes, is_minor, template_id, author_id, created_at, ordinal ON #{Landable.configuration.database_schema_prefix}landable.template_revisions
|
73
73
|
FOR EACH STATEMENT EXECUTE PROCEDURE #{Landable.configuration.database_schema_prefix}landable.tg_disallow();"
|
74
|
-
|
75
|
-
|
76
74
|
end
|
77
75
|
end
|
@@ -6,11 +6,11 @@ class CreateAudits < ActiveRecord::Migration
|
|
6
6
|
|
7
7
|
# Audit Model
|
8
8
|
create_table "#{Landable.configuration.database_schema_prefix}landable.audits" do |t|
|
9
|
-
t.uuid
|
9
|
+
t.uuid :auditable_id
|
10
10
|
t.string :auditable_type
|
11
11
|
|
12
|
-
t.text
|
13
|
-
t.text
|
12
|
+
t.text :notes
|
13
|
+
t.text :approver
|
14
14
|
t.string :flags, array: true, default: []
|
15
15
|
|
16
16
|
t.timestamps
|
@@ -1,25 +1,26 @@
|
|
1
1
|
class PathResponseTimeView < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
3
|
+
execute <<-SQL
|
4
|
+
DROP VIEW IF EXISTS #{Landable.configuration.database_schema_prefix}landable_traffic.path_response_time__by_time;
|
5
|
+
CREATE OR REPLACE VIEW #{Landable.configuration.database_schema_prefix}landable_traffic.path_response_time__by_time
|
6
|
+
AS
|
7
|
+
SELECT *
|
8
|
+
FROM
|
9
|
+
(
|
10
|
+
SELECT
|
11
|
+
p.path_id as path_id
|
12
|
+
, p.path as path
|
13
|
+
,round(avg(pv.response_time), 3) as "average response time (ms)"
|
14
|
+
FROM #{Landable.configuration.database_schema_prefix}landable_traffic.page_views pv
|
15
|
+
JOIN #{Landable.configuration.database_schema_prefix}landable_traffic.paths p
|
16
|
+
on p.path_id = pv.path_id
|
17
|
+
group by p.path_id, p.path
|
18
|
+
) agg1
|
19
|
+
order by agg1."average response time (ms)" desc
|
20
|
+
;
|
21
21
|
|
22
|
-
|
22
|
+
COMMENT ON VIEW #{Landable.configuration.database_schema_prefix}landable_traffic.path_response_time__by_time IS $$
|
23
|
+
The view path_response_time__by_time returns the paths displayed and the average reponse time (in ms) for each page of the site. This list is ordered by response time, decending.$$;
|
23
24
|
SQL
|
24
25
|
end
|
25
26
|
end
|
@@ -18,24 +18,22 @@ When 'I POST an asset to "$path" with both $assoc IDs' do |path, assoc|
|
|
18
18
|
ary = instance_variable_get("@#{assoc}s")
|
19
19
|
key = :"#{assoc}_ids"
|
20
20
|
|
21
|
-
post path, asset: attributes_for(:asset).merge(
|
22
|
-
key => ary.map(&:id)
|
23
|
-
})
|
21
|
+
post path, asset: attributes_for(:asset).merge(key => ary.map(&:id))
|
24
22
|
end
|
25
23
|
|
26
24
|
Then 'the response should contain an "asset"' do
|
27
25
|
last_json.should have_key('asset')
|
28
|
-
last_json['asset']['mime_type'].should
|
26
|
+
last_json['asset']['mime_type'].should eq 'image/png'
|
29
27
|
end
|
30
28
|
|
31
|
-
Then 'the response should contain the $version "asset"' do |
|
29
|
+
Then 'the response should contain the $version "asset"' do |_|
|
32
30
|
# version is intentionally ignored; it just reads better in the steps.
|
33
31
|
|
34
32
|
@asset ||= Landable::Asset.order('created_at DESC').first
|
35
|
-
at_json('asset/id').should
|
33
|
+
at_json('asset/id').should eq @asset.id
|
36
34
|
end
|
37
35
|
|
38
|
-
Then
|
36
|
+
Then(/^the asset ID should( not)? be in the array at "([^"]+)"$/) do |negative, json_path|
|
39
37
|
array = at_json json_path
|
40
38
|
if negative
|
41
39
|
array.should_not include(@asset.id)
|
@@ -45,16 +43,16 @@ Then /^the asset ID should( not)? be in the array at "([^"]+)"$/ do |negative, j
|
|
45
43
|
end
|
46
44
|
|
47
45
|
Then 'both $assoc IDs should be in the array at "$json_path"' do |assoc, json_path|
|
48
|
-
ids = instance_variable_get("@#{assoc}s").map
|
46
|
+
ids = instance_variable_get("@#{assoc}s").map(&:id)
|
49
47
|
at_json(json_path).should include(*ids)
|
50
48
|
end
|
51
49
|
|
52
50
|
Then 'the rendered body should be the correct assets' do
|
53
51
|
<<-eos
|
54
|
-
<link href="/assets/application
|
55
|
-
<script src="/assets/application
|
56
|
-
<img alt="Foo" src="/assets/foo
|
57
|
-
<img alt="Foo" src="/assets/foo
|
52
|
+
<link href="/assets/application-//./.css" media="screen" rel="stylesheet" />
|
53
|
+
<script src="/assets/application-/./.js"></script>
|
54
|
+
<img alt="Foo" src="/assets/foo-/./.jpg" />
|
55
|
+
<img alt="Foo" src="/assets/foo-/./.jpg" />
|
58
56
|
<img alt="Baz!" src="https://landable.dev/_assets//uploads/panda.png" />
|
59
57
|
eos
|
60
58
|
end
|