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
@@ -5,26 +5,26 @@ include SchemaMoves::Helpers
|
|
5
5
|
|
6
6
|
namespace :landable do
|
7
7
|
namespace :data do
|
8
|
-
desc
|
9
|
-
task :
|
8
|
+
desc 'Clean & restore database from specified source'
|
9
|
+
task restore: ['db:drop', 'db:create', 'db:migrate', 'dump_and_load']
|
10
10
|
|
11
11
|
desc 'Restore database from specified source'
|
12
12
|
task dump_and_load: :environment do
|
13
|
-
|
14
|
-
|
13
|
+
STDOUT.puts 'Enter Remote DB Host'
|
14
|
+
host = STDIN.gets.strip
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
STDOUT.puts 'Enter Remote Database'
|
17
|
+
database = STDIN.gets.strip
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
STDOUT.puts 'Enter Remote Username'
|
20
|
+
username = STDIN.gets.strip
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
`pg_dump -h #{host} -U #{username} --data-only --format plain --schema landable #{database} > landable_import.sql`
|
23
|
+
`psql #{Rails.configuration.database_configuration[Rails.env]['database']} -f landable_import.sql`
|
24
|
+
`rm landable_import.sql`
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
27
|
+
desc 'Migrates all to new schema'
|
28
28
|
task move_schemas: :environment do
|
29
29
|
get_schema_names
|
30
30
|
create_schemas
|
@@ -32,11 +32,10 @@ namespace :landable do
|
|
32
32
|
drop_old_schemas if want_to_drop_old_schemas?
|
33
33
|
end
|
34
34
|
|
35
|
-
desc
|
35
|
+
desc 'Drop the old schemas'
|
36
36
|
task drop_schemas: :environment do
|
37
37
|
get_schema_names false
|
38
38
|
drop_old_schemas if want_to_drop_old_schemas?
|
39
39
|
end
|
40
|
-
|
41
40
|
end
|
42
41
|
end
|
@@ -1,35 +1,29 @@
|
|
1
1
|
namespace :landable do
|
2
2
|
namespace :pgtap do
|
3
|
-
def
|
4
|
-
|
3
|
+
def pgprove?
|
4
|
+
@has_prove ||= Kernel.system('which pg_prove > /dev/null')
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
|
7
|
+
def pgconfig?
|
8
|
+
@has_pgconfig ||= Kernel.system('which pg_config > /dev/null')
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def pgtap?
|
12
12
|
has_pgtap = false
|
13
13
|
|
14
|
-
if
|
14
|
+
if pgconfig?
|
15
15
|
sharedir = "#{`pg_config | grep SHAREDIR | awk {' print $3 '}`.strip}/extension/pgtap.control"
|
16
|
-
if File.file?("#{sharedir}")
|
17
|
-
has_pgtap = true
|
18
|
-
end
|
16
|
+
has_pgtap = true if File.file?("#{sharedir}")
|
19
17
|
end
|
20
18
|
|
21
19
|
has_pgtap
|
22
20
|
end
|
23
21
|
|
24
|
-
desc
|
25
|
-
task :run, [:test_file] => [
|
26
|
-
|
27
|
-
|
28
|
-
tests = args[:test_file] ? args[:test_file] : "*.sql"
|
29
|
-
|
30
|
-
if has_pgprove? and has_pgtap?
|
22
|
+
desc 'Run PGTap unit tests'
|
23
|
+
task :run, [:test_file] => [:environment] do |_t, _args|
|
24
|
+
if pgprove? && pgtap?
|
31
25
|
# Load pgtap functions into database. Will not complain if already loaded.
|
32
|
-
ActiveRecord::Base.connection.execute(
|
26
|
+
ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS pgtap;')
|
33
27
|
|
34
28
|
# Runs the tests. Wrapped pg_prove call in shell script due to issues with return values
|
35
29
|
sh "cd #{Rails.root}/../../script && ./pgtap"
|
@@ -40,5 +34,5 @@ namespace :landable do
|
|
40
34
|
end
|
41
35
|
end
|
42
36
|
|
43
|
-
task :
|
37
|
+
task pgtap: 'pgtap:run'
|
44
38
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
namespace :landable do
|
2
2
|
namespace :seed do
|
3
3
|
desc 'Seed extra data (starter themes)'
|
4
|
-
task :
|
4
|
+
task extras: :environment do
|
5
5
|
Landable::Seeds.seed(:extras)
|
6
6
|
end
|
7
7
|
|
8
8
|
desc 'Seed required data (categories)'
|
9
|
-
task :
|
9
|
+
task required: :environment do
|
10
10
|
Landable::Seeds.seed(:required)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
desc 'Seed required and extra data'
|
15
|
-
task :
|
16
|
-
end
|
15
|
+
task seed: ['seed:required', 'seed:extras']
|
16
|
+
end
|
@@ -2,39 +2,36 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
describe HasAssets do
|
5
|
-
|
6
5
|
before(:each) { create_list :asset, 4 }
|
7
6
|
|
8
7
|
let(:assets) { Landable::Asset.first(3) }
|
9
|
-
let(:subject)
|
10
|
-
build :page,
|
11
|
-
body: "
|
8
|
+
let(:subject) do
|
9
|
+
build :page, body: "
|
12
10
|
<div>{% img_tag #{assets[0].name} %}</div>
|
13
11
|
<div>{% asset_url #{assets[1].name} %}</div>
|
14
12
|
<div>{% asset_description #{assets[2].name} %}</div>
|
15
13
|
<div>{% img_tag #{assets[0].name} %}</div>
|
16
14
|
"
|
17
|
-
|
18
|
-
}
|
15
|
+
end
|
19
16
|
|
20
17
|
describe '#assets' do
|
21
18
|
it 'should return assets matching #asset_names' do
|
22
|
-
result = double
|
23
|
-
subject.should_receive(:asset_names) {
|
24
|
-
Landable::Asset.should_receive(:where).with(name:
|
25
|
-
subject.assets.should
|
19
|
+
result = double
|
20
|
+
subject.should_receive(:asset_names) { %w(one two three) }
|
21
|
+
Landable::Asset.should_receive(:where).with(name: %w(one two three)) { result }
|
22
|
+
subject.assets.should eq result
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
29
26
|
describe '#asset_names' do
|
30
27
|
it 'should pull asset names out of the body' do
|
31
|
-
subject.asset_names.sort.should
|
28
|
+
subject.asset_names.sort.should eq assets.map(&:name).uniq.sort
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
35
32
|
describe '#save_assets!' do
|
36
33
|
it 'should save the assets' do
|
37
|
-
assets_double = double
|
34
|
+
assets_double = double
|
38
35
|
subject.should_receive(:assets) { assets_double }
|
39
36
|
subject.should_receive(:assets=).with(assets_double)
|
40
37
|
subject.save_assets!
|
@@ -49,7 +46,7 @@ module Landable
|
|
49
46
|
describe '#assets_as_hash' do
|
50
47
|
it 'should return a hash of asset names to asset instances' do
|
51
48
|
subject.save!
|
52
|
-
subject.assets_as_hash.should
|
49
|
+
subject.assets_as_hash.should eq Hash[assets.map { |asset| [asset.name, asset] }]
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
@@ -57,19 +54,18 @@ module Landable
|
|
57
54
|
it 'should reset the asset_names cache, then set the body' do
|
58
55
|
subject.instance_eval { @asset_names = 'foo' }
|
59
56
|
subject.body = 'bar'
|
60
|
-
subject.body.should
|
57
|
+
subject.body.should eq 'bar'
|
61
58
|
subject.instance_eval { @asset_names }.should be_nil
|
62
|
-
subject.asset_names.should
|
59
|
+
subject.asset_names.should eq []
|
63
60
|
end
|
64
61
|
end
|
65
62
|
|
66
63
|
describe '#assets_join_table_name' do
|
67
64
|
it 'should generate the correct join_table, and then apologize for doing so' do
|
68
|
-
Page.send(:assets_join_table_name).should
|
69
|
-
PageRevision.send(:assets_join_table_name).should
|
70
|
-
Theme.send(:assets_join_table_name).should
|
65
|
+
Page.send(:assets_join_table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.page_assets"
|
66
|
+
PageRevision.send(:assets_join_table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.page_revision_assets"
|
67
|
+
Theme.send(:assets_join_table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.theme_assets"
|
71
68
|
end
|
72
69
|
end
|
73
|
-
|
74
70
|
end
|
75
71
|
end
|
@@ -2,39 +2,36 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
describe HasTemplates do
|
5
|
-
|
6
|
-
before(:each) do
|
5
|
+
before(:each) do
|
7
6
|
create_list :template, 2
|
8
7
|
create :template, slug: 'I have a space'
|
9
8
|
end
|
10
9
|
|
11
10
|
let(:templates) { Landable::Template.last(3) }
|
12
|
-
let(:subject)
|
13
|
-
build :page,
|
14
|
-
body: "
|
11
|
+
let(:subject) do
|
12
|
+
build :page, body: "
|
15
13
|
<div>{% template #{templates[0].slug} %}</div>
|
16
14
|
<div>{% template #{templates[1].slug} %}</div>
|
17
15
|
<div>{% template #{templates[2].slug} %}</div>
|
18
16
|
"
|
19
|
-
|
20
|
-
}
|
17
|
+
end
|
21
18
|
|
22
19
|
describe '#templates' do
|
23
20
|
it 'should return templates' do
|
24
21
|
slugs = [templates[0].slug, templates[1].slug, templates[2].slug]
|
25
|
-
subject.templates.should
|
22
|
+
subject.templates.should eq Landable::Template.where(slug: slugs)
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
29
26
|
describe '#template_names' do
|
30
27
|
it 'should pull template slugs out of the body' do
|
31
|
-
subject.template_names.sort.should
|
28
|
+
subject.template_names.sort.should eq templates.map(&:slug).uniq.sort
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
35
32
|
describe '#save_templates!' do
|
36
33
|
it 'should save the templates' do
|
37
|
-
assets_double = double
|
34
|
+
assets_double = double
|
38
35
|
subject.should_receive(:templates) { assets_double }
|
39
36
|
subject.should_receive(:templates=).with(assets_double)
|
40
37
|
subject.save_templates!
|
@@ -50,15 +47,15 @@ module Landable
|
|
50
47
|
it 'should reset the template_slug cache, then set the body' do
|
51
48
|
subject.instance_eval { @template_slug = 'foo' }
|
52
49
|
subject.body = 'bar'
|
53
|
-
subject.body.should
|
50
|
+
subject.body.should eq 'bar'
|
54
51
|
subject.instance_eval { @template_slug }.should be_nil
|
55
|
-
subject.templates.should
|
52
|
+
subject.templates.should eq []
|
56
53
|
end
|
57
54
|
end
|
58
55
|
|
59
56
|
describe '#templates_join_table_name' do
|
60
57
|
it 'should generate the correct join_table, and then apologize for doing so' do
|
61
|
-
Page.send(:templates_join_table_name).should
|
58
|
+
Page.send(:templates_join_table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.page_templates"
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
@@ -9,21 +9,21 @@ module Landable
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# tests
|
12
|
-
it
|
12
|
+
it 'should soft delete a content managed Item' do
|
13
13
|
# setup
|
14
14
|
current_page = Page.find(@page.id)
|
15
|
-
|
15
|
+
|
16
16
|
# actions
|
17
17
|
current_page.deactivate
|
18
18
|
|
19
19
|
# expectations
|
20
20
|
expect(current_page).to be_a Page
|
21
21
|
expect(current_page.deleted_at).to_not be_blank
|
22
|
-
|
22
|
+
|
23
23
|
# end
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should restore a content managed Item' do
|
27
27
|
# setup
|
28
28
|
Page.find(@page.id).deactivate
|
29
29
|
restored_page = Page.find(@page.id)
|
@@ -2,14 +2,12 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
describe TableName do
|
5
|
-
|
6
5
|
describe '#table_name' do
|
7
6
|
it 'should generate the correct table name' do
|
8
|
-
Page.send(:table_name).should
|
9
|
-
PageRevision.send(:table_name).should
|
10
|
-
Theme.send(:table_name).should
|
7
|
+
Page.send(:table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.pages"
|
8
|
+
PageRevision.send(:table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.page_revisions"
|
9
|
+
Theme.send(:table_name).should eq "#{Landable.configuration.database_schema_prefix}landable.themes"
|
11
10
|
end
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
@@ -3,14 +3,12 @@ require 'spec_helper'
|
|
3
3
|
module Landable
|
4
4
|
module Traffic
|
5
5
|
describe TableName do
|
6
|
-
|
7
6
|
describe '#table_name' do
|
8
7
|
it 'should generate the correct table name' do
|
9
|
-
Visit.send(:table_name).should
|
10
|
-
PageView.send(:table_name).should
|
8
|
+
Visit.send(:table_name).should eq "#{Landable.configuration.database_schema_prefix}landable_traffic.visits"
|
9
|
+
PageView.send(:table_name).should eq "#{Landable.configuration.database_schema_prefix}landable_traffic.page_views"
|
11
10
|
end
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -6,12 +6,13 @@ module Landable
|
|
6
6
|
# setup
|
7
7
|
controller(ApplicationController) do
|
8
8
|
protected
|
9
|
+
|
9
10
|
def hello_world
|
10
|
-
|
11
|
+
'i live in a giant bucket.'
|
11
12
|
end
|
12
13
|
|
13
14
|
def hello_cleveland
|
14
|
-
|
15
|
+
'i am a banana.'
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -27,7 +28,7 @@ module Landable
|
|
27
28
|
end
|
28
29
|
|
29
30
|
# tests
|
30
|
-
it
|
31
|
+
it 'should include the VariablesConcern module' do
|
31
32
|
# setup
|
32
33
|
# actions
|
33
34
|
# expectations
|
@@ -35,27 +36,27 @@ module Landable
|
|
35
36
|
# end
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
+
it 'should use the #register_landable_variable with a similarly named method' do
|
39
40
|
# setup
|
40
41
|
# actions
|
41
42
|
# expectations
|
42
|
-
expect(controller.fetch_landable_variables[:hello_world]).to eql(
|
43
|
+
expect(controller.fetch_landable_variables[:hello_world]).to eql('i live in a giant bucket.')
|
43
44
|
# end
|
44
45
|
end
|
45
46
|
|
46
|
-
it
|
47
|
+
it 'should use the #register_landable_variable with a custom named method' do
|
47
48
|
# setup
|
48
49
|
# actions
|
49
50
|
# expectations
|
50
|
-
expect(controller.fetch_landable_variables[:is_rejected]).to eql(
|
51
|
+
expect(controller.fetch_landable_variables[:is_rejected]).to eql('i am a banana.')
|
51
52
|
# end
|
52
53
|
end
|
53
54
|
|
54
|
-
it
|
55
|
+
it 'should use the #register_landable_variable with a string-based name' do
|
55
56
|
# setup
|
56
57
|
# actions
|
57
58
|
# expectations
|
58
|
-
expect(controller.fetch_landable_variables['is_rejected']).to eql(
|
59
|
+
expect(controller.fetch_landable_variables['is_rejected']).to eql('i am a banana.')
|
59
60
|
# end
|
60
61
|
end
|
61
62
|
|
@@ -63,4 +64,4 @@ module Landable
|
|
63
64
|
end
|
64
65
|
|
65
66
|
# end
|
66
|
-
end
|
67
|
+
end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module Landable
|
4
|
-
|
5
|
-
|
3
|
+
module Landable
|
4
|
+
module Api
|
5
|
+
describe AssetsController, json: true do
|
6
|
+
routes { Landable::Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
describe '#update' do
|
9
|
+
include_examples 'Authenticated API controller', :make_request
|
9
10
|
|
10
|
-
|
11
|
+
let(:asset) { create :asset, description: 'Not updated' }
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def make_request
|
14
|
+
put :update, id: asset.id, asset: { description: 'Updated' }
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it 'updates the asset description' do
|
18
|
+
make_request
|
19
|
+
asset.reload
|
20
|
+
asset.description.should eq 'Updated'
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
24
25
|
end
|
@@ -1,147 +1,149 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module Landable
|
4
|
-
|
5
|
-
|
3
|
+
module Landable
|
4
|
+
module Api
|
5
|
+
describe AuditsController, json: true do
|
6
|
+
routes { Landable::Engine.routes }
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
let(:page) { create :page }
|
9
|
+
let(:template) { create :template }
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
let(:audits) { create_list :audit, 3 }
|
15
|
-
|
16
|
-
def make_request(params = {})
|
17
|
-
get :index
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'renders audits as json' do
|
21
|
-
make_request
|
22
|
-
last_json['audits'].collect { |p| p['id'] }.sort.should == Landable::Audit.all.map(&:id).sort
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'tempalte audits' do
|
27
|
-
include_examples 'Authenticated API controller', :make_request
|
11
|
+
describe '#index' do
|
12
|
+
context 'all' do
|
13
|
+
include_examples 'Authenticated API controller', :make_request
|
28
14
|
|
29
|
-
|
15
|
+
let(:audits) { create_list :audit, 3 }
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
def make_request(_params = {})
|
18
|
+
get :index
|
19
|
+
end
|
34
20
|
|
35
|
-
|
36
|
-
|
37
|
-
|
21
|
+
it 'renders audits as json' do
|
22
|
+
make_request
|
23
|
+
last_json['audits'].collect { |p| p['id'] }.sort.should eq Landable::Audit.all.map(&:id).sort
|
24
|
+
end
|
38
25
|
end
|
39
|
-
end
|
40
26
|
|
41
|
-
|
42
|
-
|
27
|
+
context 'tempalte audits' do
|
28
|
+
include_examples 'Authenticated API controller', :make_request
|
43
29
|
|
44
|
-
|
30
|
+
let(:audits) { create_list :audit, 3, auditable_id: template.id, auditable_type: 'Landable::Template', approver: 'ME!!!' }
|
45
31
|
|
46
|
-
|
47
|
-
|
48
|
-
|
32
|
+
def make_request(_params = {})
|
33
|
+
get :index, auditable_id: template.id
|
34
|
+
end
|
49
35
|
|
50
|
-
|
51
|
-
|
52
|
-
|
36
|
+
it 'renders audits as json' do
|
37
|
+
make_request
|
38
|
+
last_json['audits'].collect { |p| p['id'] }.sort.should eq Landable::Audit.all.map(&:id).sort
|
39
|
+
end
|
53
40
|
end
|
54
|
-
end
|
55
|
-
end
|
56
41
|
|
57
|
-
|
58
|
-
|
59
|
-
let(:audit) { create(:audit) }
|
42
|
+
context 'page audits' do
|
43
|
+
include_examples 'Authenticated API controller', :make_request
|
60
44
|
|
61
|
-
|
62
|
-
get :show, id: id
|
63
|
-
end
|
45
|
+
let(:audits) { create_list :audit, 3, auditable_id: page.id, auditable_type: 'Landable::Page', approver: 'ME!!!' }
|
64
46
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
47
|
+
def make_request(_params = {})
|
48
|
+
get :index, auditable_id: page.id
|
49
|
+
end
|
69
50
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
51
|
+
it 'renders audits as json' do
|
52
|
+
make_request
|
53
|
+
last_json['audits'].collect { |p| p['id'] }.sort.should eq Landable::Audit.all.map(&:id).sort
|
54
|
+
end
|
74
55
|
end
|
75
56
|
end
|
76
|
-
end
|
77
57
|
|
78
|
-
|
79
|
-
context 'template audit' do
|
58
|
+
describe '#show' do
|
80
59
|
include_examples 'Authenticated API controller', :make_request
|
60
|
+
let(:audit) { create(:audit) }
|
81
61
|
|
82
|
-
|
83
|
-
|
84
|
-
auditable_type: 'Landable::Template',
|
85
|
-
approver: 'Marley') }
|
62
|
+
def make_request(id = audit.id)
|
63
|
+
get :show, id: id
|
86
64
|
end
|
87
65
|
|
88
|
-
|
89
|
-
|
66
|
+
it 'renders the page as JSON' do
|
67
|
+
make_request
|
68
|
+
last_json['audit']['flags'].should eq audit.flags
|
90
69
|
end
|
91
70
|
|
92
|
-
|
93
|
-
|
71
|
+
context 'no such page' do
|
72
|
+
it 'returns 404' do
|
73
|
+
make_request random_uuid
|
74
|
+
response.status.should eq 404
|
75
|
+
end
|
94
76
|
end
|
77
|
+
end
|
95
78
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
response.status.should == 201
|
100
|
-
end
|
79
|
+
describe '#create' do
|
80
|
+
context 'template audit' do
|
81
|
+
include_examples 'Authenticated API controller', :make_request
|
101
82
|
|
102
|
-
|
103
|
-
|
104
|
-
|
83
|
+
let(:default_params) do
|
84
|
+
{ audit: attributes_for(:audit).merge(auditable_id: template.id,
|
85
|
+
auditable_type: 'Landable::Template',
|
86
|
+
approver: 'Marley') }
|
105
87
|
end
|
106
88
|
|
107
|
-
|
108
|
-
|
109
|
-
last_json['audit']['flags'].should == audit.flags
|
89
|
+
let(:audit) do
|
90
|
+
Landable::Audit.where(auditable_id: default_params[:audit][:auditable_id]).first
|
110
91
|
end
|
111
|
-
end
|
112
|
-
end
|
113
92
|
|
114
|
-
|
115
|
-
|
93
|
+
def make_request(params = {})
|
94
|
+
post :create, default_params.deep_merge(audit: params, template_id: template.id)
|
95
|
+
end
|
116
96
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
97
|
+
context 'success' do
|
98
|
+
it 'returns 201 Created' do
|
99
|
+
make_request
|
100
|
+
response.status.should eq 201
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns header Location with the audit URL' do
|
104
|
+
make_request
|
105
|
+
response.headers['Location'].should eq audit_url(audit)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'renders the audit as JSON' do
|
109
|
+
make_request
|
110
|
+
last_json['audit']['flags'].should eq audit.flags
|
111
|
+
end
|
112
|
+
end
|
121
113
|
end
|
122
114
|
|
123
|
-
|
124
|
-
|
125
|
-
end
|
115
|
+
context 'page audit' do
|
116
|
+
include_examples 'Authenticated API controller', :make_request
|
126
117
|
|
127
|
-
|
128
|
-
|
129
|
-
|
118
|
+
let(:default_params) do
|
119
|
+
{ audit: attributes_for(:audit).merge(auditable_id: page.id,
|
120
|
+
auditable_type: 'Landable::Page',
|
121
|
+
approver: 'Marley') }
|
122
|
+
end
|
130
123
|
|
131
|
-
|
132
|
-
|
133
|
-
make_request
|
134
|
-
response.status.should == 201
|
124
|
+
let(:audit) do
|
125
|
+
Landable::Audit.where(auditable_id: default_params[:audit][:auditable_id]).first
|
135
126
|
end
|
136
127
|
|
137
|
-
|
138
|
-
|
139
|
-
response.headers['Location'].should == audit_url(audit)
|
128
|
+
def make_request(params = {})
|
129
|
+
post :create, default_params.deep_merge(page_audit: params, page_id: page.id)
|
140
130
|
end
|
141
131
|
|
142
|
-
|
143
|
-
|
144
|
-
|
132
|
+
context 'success' do
|
133
|
+
it 'returns 201 Created' do
|
134
|
+
make_request
|
135
|
+
response.status.should eq 201
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'returns header Location with the audit URL' do
|
139
|
+
make_request
|
140
|
+
response.headers['Location'].should eq audit_url(audit)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'renders the audit as JSON' do
|
144
|
+
make_request
|
145
|
+
last_json['audit']['flags'].should eq audit.flags
|
146
|
+
end
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end
|