landable 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.rubocop.yml +281 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +5 -1
  4. data/Gemfile +3 -4
  5. data/README.md +2 -0
  6. data/Rakefile +6 -3
  7. data/app/controllers/concerns/landable/variables_concern.rb +9 -9
  8. data/app/controllers/landable/api/access_tokens_controller.rb +7 -8
  9. data/app/controllers/landable/api/assets_controller.rb +29 -26
  10. data/app/controllers/landable/api/audits_controller.rb +6 -5
  11. data/app/controllers/landable/api/configurations_controller.rb +1 -1
  12. data/app/controllers/landable/api/directories_controller.rb +2 -2
  13. data/app/controllers/landable/api/page_revisions_controller.rb +2 -4
  14. data/app/controllers/landable/api/pages_controller.rb +39 -40
  15. data/app/controllers/landable/api/template_revisions_controller.rb +1 -2
  16. data/app/controllers/landable/api/templates_controller.rb +15 -14
  17. data/app/controllers/landable/api/themes_controller.rb +15 -14
  18. data/app/controllers/landable/api_controller.rb +10 -11
  19. data/app/controllers/landable/public/pages_controller.rb +2 -2
  20. data/app/controllers/landable/public/preview/page_revisions_controller.rb +2 -2
  21. data/app/controllers/landable/public/preview/pages_controller.rb +1 -1
  22. data/app/controllers/landable/public/sitemap_controller.rb +2 -2
  23. data/app/decorators/landable/page_decorator.rb +3 -3
  24. data/app/helpers/landable/pages_helper.rb +2 -2
  25. data/app/helpers/landable/traffic_helper.rb +2 -4
  26. data/app/models/concerns/landable/has_assets.rb +6 -9
  27. data/app/models/concerns/landable/has_templates.rb +6 -7
  28. data/app/models/concerns/landable/librarian.rb +5 -5
  29. data/app/models/concerns/landable/table_name.rb +2 -2
  30. data/app/models/landable/access_token.rb +1 -1
  31. data/app/models/landable/asset.rb +8 -8
  32. data/app/models/landable/asset_search_engine.rb +7 -8
  33. data/app/models/landable/author.rb +2 -1
  34. data/app/models/landable/category.rb +1 -3
  35. data/app/models/landable/directory.rb +2 -2
  36. data/app/models/landable/page.rb +44 -50
  37. data/app/models/landable/page_revision.rb +27 -41
  38. data/app/models/landable/page_search_engine.rb +5 -6
  39. data/app/models/landable/search_engine.rb +2 -2
  40. data/app/models/landable/template.rb +9 -11
  41. data/app/models/landable/template_revision.rb +4 -14
  42. data/app/models/landable/theme.rb +1 -1
  43. data/app/models/landable/traffic/attribution.rb +3 -1
  44. data/app/models/landable/traffic/page_view.rb +1 -1
  45. data/app/models/landable/traffic/user_agent.rb +1 -1
  46. data/app/models/landable/traffic/visit.rb +1 -1
  47. data/app/responders/landable/api_responder.rb +5 -3
  48. data/app/responders/landable/page_render_responder.rb +1 -1
  49. data/app/serializers/landable/asset_serializer.rb +1 -1
  50. data/app/serializers/landable/audit_serializer.rb +2 -3
  51. data/app/serializers/landable/directory_serializer.rb +2 -2
  52. data/app/serializers/landable/page_revision_serializer.rb +0 -1
  53. data/app/serializers/landable/page_serializer.rb +5 -5
  54. data/app/serializers/landable/template_serializer.rb +2 -2
  55. data/app/services/landable/authentication_service.rb +1 -1
  56. data/app/services/landable/registration_service.rb +3 -2
  57. data/app/services/landable/render_service.rb +16 -18
  58. data/app/services/landable/screenshot_service.rb +3 -4
  59. data/app/services/landable/tidy_service.rb +32 -37
  60. data/app/validators/path_validator.rb +1 -3
  61. data/app/validators/url_validator.rb +4 -7
  62. data/config/routes.rb +3 -6
  63. data/db/migrate/20130510221424_create_landable_schema.rb +45 -56
  64. data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +2 -2
  65. data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +9 -12
  66. data/db/migrate/20131002220041_file_based_themes.rb +3 -3
  67. data/db/migrate/20131008164204_create_head_tag_on_page.rb +4 -4
  68. data/db/migrate/20131008193544_drop_status_codes_model.rb +1 -2
  69. data/db/migrate/20131028145652_add_traffic_schema.rb +5 -5
  70. data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +1 -1
  71. data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +1 -1
  72. data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +1 -1
  73. data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +2 -2
  74. data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +3 -3
  75. data/db/migrate/20140128170659_file_backed_templates.rb +1 -1
  76. data/db/migrate/20140205193757_fix_status_codes.rb +3 -3
  77. data/db/migrate/20140220170324_add_slug_to_categories.rb +1 -1
  78. data/db/migrate/20140224205516_rename_traffic_schema.rb +7 -9
  79. data/db/migrate/20140509190128_create_template_revisions.rb +13 -15
  80. data/db/migrate/20140509192856_create_audits.rb +3 -3
  81. data/db/migrate/20140602213937_path_response_time_view.rb +20 -19
  82. data/features/step_definitions/asset_steps.rb +10 -12
  83. data/features/step_definitions/core_api_steps.rb +29 -27
  84. data/features/step_definitions/factory_steps.rb +16 -16
  85. data/features/step_definitions/html_steps.rb +1 -1
  86. data/features/step_definitions/liquid_steps.rb +8 -8
  87. data/features/step_definitions/theme_steps.rb +4 -4
  88. data/features/support/env.rb +5 -5
  89. data/landable.gemspec +2 -2
  90. data/lib/generators/landable/landable_generator.rb +2 -2
  91. data/lib/generators/templates/landable.rb +1 -1
  92. data/lib/landable.rb +7 -7
  93. data/lib/landable/configuration.rb +10 -19
  94. data/lib/landable/engine.rb +19 -19
  95. data/lib/landable/error.rb +1 -3
  96. data/lib/landable/layout.rb +6 -6
  97. data/lib/landable/liquid/asset_tags.rb +3 -5
  98. data/lib/landable/liquid/drops.rb +3 -8
  99. data/lib/landable/liquid/filters.rb +1 -3
  100. data/lib/landable/liquid/tags.rb +10 -10
  101. data/lib/landable/migration.rb +30 -30
  102. data/lib/landable/mime_types.rb +1 -1
  103. data/lib/landable/partial.rb +2 -2
  104. data/lib/landable/seeds.rb +3 -4
  105. data/lib/landable/traffic.rb +4 -8
  106. data/lib/landable/traffic/tracker.rb +48 -43
  107. data/lib/landable/traffic/user_tracker.rb +15 -10
  108. data/lib/landable/version.rb +1 -1
  109. data/lib/schema_moves.rb +15 -16
  110. data/lib/tasks/landable/cucumber.rake +46 -47
  111. data/lib/tasks/landable/data.rake +13 -14
  112. data/lib/tasks/landable/pgtap.rake +12 -18
  113. data/lib/tasks/landable/seed.rake +4 -4
  114. data/spec/concerns/landable/has_assets_spec.rb +15 -19
  115. data/spec/concerns/landable/has_templates_spec.rb +10 -13
  116. data/spec/concerns/landable/librarian.rb +4 -4
  117. data/spec/concerns/landable/table_name_spec.rb +3 -5
  118. data/spec/concerns/landable/traffic/table_name_spec.rb +2 -4
  119. data/spec/controllers/concerns/landable/variables_concern_spec.rb +11 -10
  120. data/spec/controllers/landable/api/assets_controller_spec.rb +15 -14
  121. data/spec/controllers/landable/api/audits_controller_spec.rb +104 -102
  122. data/spec/controllers/landable/api/categories_controller_spec.rb +36 -34
  123. data/spec/controllers/landable/api/configuration_controller_spec.rb +14 -12
  124. data/spec/controllers/landable/api/directories_controller_spec.rb +52 -50
  125. data/spec/controllers/landable/api/page_revisions_controller_spec.rb +20 -18
  126. data/spec/controllers/landable/api/pages_controller_spec.rb +204 -203
  127. data/spec/controllers/landable/api/template_revisions_controller_spec.rb +20 -18
  128. data/spec/controllers/landable/api/templates_controller_spec.rb +39 -37
  129. data/spec/controllers/landable/api_controller_spec.rb +24 -26
  130. data/spec/controllers/public/preview/page_revisions_controller_spec.rb +36 -34
  131. data/spec/controllers/public/preview/pages_controller_spec.rb +32 -30
  132. data/spec/controllers/public/sitemap_controller_spec.rb +19 -17
  133. data/spec/decorators/page_decorator_spec.rb +9 -9
  134. data/spec/dummy/app/helpers/application_helper.rb +1 -1
  135. data/spec/dummy/config/application.rb +5 -6
  136. data/spec/dummy/config/boot.rb +1 -1
  137. data/spec/dummy/config/environments/test.rb +1 -1
  138. data/spec/dummy/config/initializers/landable.rb +7 -6
  139. data/spec/factories/asset.rb +1 -1
  140. data/spec/factories/audit.rb +1 -1
  141. data/spec/factories/authors.rb +1 -1
  142. data/spec/factories/category.rb +1 -1
  143. data/spec/factories/pages.rb +4 -4
  144. data/spec/factories/template.rb +3 -3
  145. data/spec/factories/theme.rb +2 -2
  146. data/spec/helpers/pages_helper_spec.rb +5 -5
  147. data/spec/lib/landable/configuration_spec.rb +2 -4
  148. data/spec/lib/landable/event_publisher_spec.rb +1 -3
  149. data/spec/lib/landable/layout_spec.rb +4 -4
  150. data/spec/lib/landable/liquid_spec.rb +12 -14
  151. data/spec/lib/landable/migration_spec.rb +4 -4
  152. data/spec/lib/landable/partial_spec.rb +18 -18
  153. data/spec/lib/landable/tracking_spec.rb +27 -29
  154. data/spec/lib/landable/traffic_spec.rb +29 -33
  155. data/spec/models/landable/access_token_spec.rb +1 -1
  156. data/spec/models/landable/asset_spec.rb +9 -11
  157. data/spec/models/landable/directory_spec.rb +7 -7
  158. data/spec/models/landable/page/errors_spec.rb +1 -3
  159. data/spec/models/landable/page_revision_spec.rb +23 -24
  160. data/spec/models/landable/page_spec.rb +41 -42
  161. data/spec/models/landable/template_revision_spec.rb +3 -3
  162. data/spec/models/landable/template_spec.rb +11 -11
  163. data/spec/models/landable/theme_spec.rb +2 -2
  164. data/spec/models/landable/traffic/referer_spec.rb +3 -3
  165. data/spec/responders/page_render_responder_spec.rb +0 -2
  166. data/spec/routing/public_page_route_spec.rb +4 -5
  167. data/spec/services/landable/authentication_service_spec.rb +7 -7
  168. data/spec/services/landable/render_service_spec.rb +8 -8
  169. data/spec/services/landable/screenshot_service_spec.rb +3 -3
  170. data/spec/services/landable/tidy_service_spec.rb +20 -20
  171. data/spec/spec_helper.rb +3 -3
  172. data/spec/support/behaviors.rb +4 -4
  173. data/spec/support/helpers.rb +1 -1
  174. metadata +86 -35
  175. 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 "Clean & restore database from specified source"
9
- task :restore => [ 'db:drop', 'db:create', 'db:migrate', 'dump_and_load' ]
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
- STDOUT.puts 'Enter Remote DB Host'
14
- host = STDIN.gets.strip
13
+ STDOUT.puts 'Enter Remote DB Host'
14
+ host = STDIN.gets.strip
15
15
 
16
- STDOUT.puts 'Enter Remote Database'
17
- database = STDIN.gets.strip
16
+ STDOUT.puts 'Enter Remote Database'
17
+ database = STDIN.gets.strip
18
18
 
19
- STDOUT.puts 'Enter Remote Username'
20
- username = STDIN.gets.strip
19
+ STDOUT.puts 'Enter Remote Username'
20
+ username = STDIN.gets.strip
21
21
 
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`
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 "Migrates all to new schema"
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 "Drop the old schemas"
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 has_pgprove?
4
- @@has_prove ||= Kernel.system('which pg_prove > /dev/null')
3
+ def pgprove?
4
+ @has_prove ||= Kernel.system('which pg_prove > /dev/null')
5
5
  end
6
6
 
7
- def has_pgconfig?
8
- @@has_pgconfig ||= Kernel.system('which pg_config > /dev/null')
7
+ def pgconfig?
8
+ @has_pgconfig ||= Kernel.system('which pg_config > /dev/null')
9
9
  end
10
10
 
11
- def has_pgtap?
11
+ def pgtap?
12
12
  has_pgtap = false
13
13
 
14
- if has_pgconfig?
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 "Run PGTap unit tests"
25
- task :run, [:test_file] => [ :environment ] do |t, args|
26
- dbdir = "#{Rails.root}/../../db"
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("CREATE EXTENSION IF NOT EXISTS pgtap;")
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 :pgtap => 'pgtap:run'
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 :extras => :environment do
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 :required => :environment do
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 :seed => ['seed:required', 'seed:extras']
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) { ['one', 'two', 'three'] }
24
- Landable::Asset.should_receive(:where).with(name: ['one', 'two', 'three']) { result }
25
- subject.assets.should == result
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 == assets.map(&:name).uniq.sort
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 == Hash[assets.map { |asset| [asset.name, asset] }]
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 == 'bar'
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 == "#{Landable.configuration.database_schema_prefix}landable.page_assets"
69
- PageRevision.send(:assets_join_table_name).should == "#{Landable.configuration.database_schema_prefix}landable.page_revision_assets"
70
- Theme.send(:assets_join_table_name).should == "#{Landable.configuration.database_schema_prefix}landable.theme_assets"
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 == Landable::Template.where(slug: slugs)
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 == templates.map(&:slug).uniq.sort
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 == 'bar'
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 == "#{Landable.configuration.database_schema_prefix}landable.page_templates"
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 "should soft delete a content managed Item" do
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 "should restore a content managed Item" do
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 == "#{Landable.configuration.database_schema_prefix}landable.pages"
9
- PageRevision.send(:table_name).should == "#{Landable.configuration.database_schema_prefix}landable.page_revisions"
10
- Theme.send(:table_name).should == "#{Landable.configuration.database_schema_prefix}landable.themes"
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 == "#{Landable.configuration.database_schema_prefix}landable_traffic.visits"
10
- PageView.send(:table_name).should == "#{Landable.configuration.database_schema_prefix}landable_traffic.page_views"
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
- "i live in a giant bucket."
11
+ 'i live in a giant bucket.'
11
12
  end
12
13
 
13
14
  def hello_cleveland
14
- "i am a banana."
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 "should include the VariablesConcern module" do
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 "should use the #register_landable_variable with a similarly named method" do
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("i live in a giant bucket.")
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 "should use the #register_landable_variable with a custom named method" do
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("i am a banana.")
51
+ expect(controller.fetch_landable_variables[:is_rejected]).to eql('i am a banana.')
51
52
  # end
52
53
  end
53
54
 
54
- it "should use the #register_landable_variable with a string-based name" do
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("i am a banana.")
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::Api
4
- describe AssetsController, json: true do
5
- routes { Landable::Engine.routes }
3
+ module Landable
4
+ module Api
5
+ describe AssetsController, json: true do
6
+ routes { Landable::Engine.routes }
6
7
 
7
- describe '#update' do
8
- include_examples 'Authenticated API controller', :make_request
8
+ describe '#update' do
9
+ include_examples 'Authenticated API controller', :make_request
9
10
 
10
- let(:asset) { create :asset, description: "Not updated" }
11
+ let(:asset) { create :asset, description: 'Not updated' }
11
12
 
12
- def make_request
13
- put :update, id: asset.id, asset: { description: "Updated" }
14
- end
13
+ def make_request
14
+ put :update, id: asset.id, asset: { description: 'Updated' }
15
+ end
15
16
 
16
- it "updates the asset description" do
17
- make_request
18
- asset.reload
19
- asset.description.should == "Updated"
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::Api
4
- describe AuditsController, json: true do
5
- routes { Landable::Engine.routes }
3
+ module Landable
4
+ module Api
5
+ describe AuditsController, json: true do
6
+ routes { Landable::Engine.routes }
6
7
 
7
- let(:page) { create :page }
8
- let(:template) { create :template }
8
+ let(:page) { create :page }
9
+ let(:template) { create :template }
9
10
 
10
- describe '#index' do
11
- context 'all' do
12
- include_examples 'Authenticated API controller', :make_request
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
- let(:audits) { create_list :audit, 3, auditable_id: template.id, auditable_type: 'Landable::Template', approver: 'ME!!!' }
15
+ let(:audits) { create_list :audit, 3 }
30
16
 
31
- def make_request(params = {})
32
- get :index, auditable_id: template.id
33
- end
17
+ def make_request(_params = {})
18
+ get :index
19
+ end
34
20
 
35
- it 'renders audits as json' do
36
- make_request
37
- last_json['audits'].collect { |p| p['id'] }.sort.should == Landable::Audit.all.map(&:id).sort
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
- context 'page audits' do
42
- include_examples 'Authenticated API controller', :make_request
27
+ context 'tempalte audits' do
28
+ include_examples 'Authenticated API controller', :make_request
43
29
 
44
- let(:audits) { create_list :audit, 3, auditable_id: page.id, auditable_type: 'Landable::Page', approver: 'ME!!!' }
30
+ let(:audits) { create_list :audit, 3, auditable_id: template.id, auditable_type: 'Landable::Template', approver: 'ME!!!' }
45
31
 
46
- def make_request(params = {})
47
- get :index, auditable_id: page.id
48
- end
32
+ def make_request(_params = {})
33
+ get :index, auditable_id: template.id
34
+ end
49
35
 
50
- it 'renders audits as json' do
51
- make_request
52
- last_json['audits'].collect { |p| p['id'] }.sort.should == Landable::Audit.all.map(&:id).sort
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
- describe '#show' do
58
- include_examples 'Authenticated API controller', :make_request
59
- let(:audit) { create(:audit) }
42
+ context 'page audits' do
43
+ include_examples 'Authenticated API controller', :make_request
60
44
 
61
- def make_request(id = audit.id)
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
- it 'renders the page as JSON' do
66
- make_request
67
- last_json['audit']['flags'].should == audit.flags
68
- end
47
+ def make_request(_params = {})
48
+ get :index, auditable_id: page.id
49
+ end
69
50
 
70
- context 'no such page' do
71
- it 'returns 404' do
72
- make_request random_uuid
73
- response.status.should == 404
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
- describe '#create' do
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
- let(:default_params) do
83
- { audit: attributes_for(:audit).merge(auditable_id: template.id,
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
- let(:audit) do
89
- Landable::Audit.where(auditable_id: default_params[:audit][:auditable_id]).first
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
- def make_request(params = {})
93
- post :create, default_params.deep_merge(audit: params, template_id: template.id)
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
- context 'success' do
97
- it 'returns 201 Created' do
98
- make_request
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
- it 'returns header Location with the audit URL' do
103
- make_request
104
- response.headers['Location'].should == audit_url(audit)
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
- it 'renders the audit as JSON' do
108
- make_request
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
- context 'page audit' do
115
- include_examples 'Authenticated API controller', :make_request
93
+ def make_request(params = {})
94
+ post :create, default_params.deep_merge(audit: params, template_id: template.id)
95
+ end
116
96
 
117
- let(:default_params) do
118
- { audit: attributes_for(:audit).merge(auditable_id: page.id,
119
- auditable_type: 'Landable::Page',
120
- approver: 'Marley') }
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
- let(:audit) do
124
- Landable::Audit.where(auditable_id: default_params[:audit][:auditable_id]).first
125
- end
115
+ context 'page audit' do
116
+ include_examples 'Authenticated API controller', :make_request
126
117
 
127
- def make_request(params = {})
128
- post :create, default_params.deep_merge(page_audit: params, page_id: page.id)
129
- end
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
- context 'success' do
132
- it 'returns 201 Created' do
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
- it 'returns header Location with the audit URL' do
138
- make_request
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
- it 'renders the audit as JSON' do
143
- make_request
144
- last_json['audit']['flags'].should == audit.flags
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