landable 1.7.1.rc1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rbenv-gemsets +1 -0
  4. data/.travis.yml +20 -2
  5. data/CHANGELOG.md +8 -1
  6. data/Gemfile +14 -13
  7. data/Rakefile +0 -1
  8. data/app/controllers/landable/api/assets_controller.rb +49 -31
  9. data/app/controllers/landable/api/pages_controller.rb +64 -42
  10. data/app/controllers/landable/api/templates_controller.rb +37 -13
  11. data/app/controllers/landable/api/themes_controller.rb +35 -14
  12. data/app/models/concerns/landable/librarian.rb +36 -0
  13. data/app/models/landable/asset.rb +1 -0
  14. data/app/models/landable/page.rb +9 -0
  15. data/app/models/landable/page_revision.rb +52 -9
  16. data/app/models/landable/search_engine.rb +1 -1
  17. data/app/models/landable/template.rb +10 -0
  18. data/app/models/landable/template_revision.rb +1 -0
  19. data/app/models/landable/theme.rb +1 -0
  20. data/app/responders/landable/api_responder.rb +1 -1
  21. data/app/serializers/landable/asset_serializer.rb +1 -0
  22. data/app/serializers/landable/page_revision_serializer.rb +1 -0
  23. data/app/serializers/landable/page_serializer.rb +4 -13
  24. data/app/serializers/landable/template_serializer.rb +3 -3
  25. data/app/serializers/landable/theme_serializer.rb +1 -1
  26. data/app/services/landable/screenshot_service.rb +32 -0
  27. data/app/views/templates/preview.liquid +13 -11
  28. data/config/routes.rb +6 -3
  29. data/db/migrate/20140501171345_add_deleted_at_to_pages.rb +5 -0
  30. data/db/migrate/20140501171352_add_deleted_at_to_themes.rb +5 -0
  31. data/db/migrate/20140501171359_add_deleted_at_to_assets.rb +5 -0
  32. data/db/migrate/20140501171406_add_deleted_at_to_templates.rb +5 -0
  33. data/db/migrate/20140515164543_add_screenshot_to_page_revisions.rb +5 -0
  34. data/db/test/landable.general.sql +9 -0
  35. data/db/test/landable.page_revisions.sql +5 -3
  36. data/db/test/landable.templates.sql +29 -2
  37. data/db/test/landable.themes.sql +5 -2
  38. data/doc/schema/asset.json +5 -0
  39. data/doc/schema/page.json +5 -0
  40. data/doc/schema/page_revision.json +6 -1
  41. data/doc/schema/template.json +5 -0
  42. data/doc/schema/template_revision.json +5 -0
  43. data/doc/schema/theme.json +5 -0
  44. data/landable.gemspec +31 -33
  45. data/lib/generators/templates/landable.rb +6 -0
  46. data/lib/landable/configuration.rb +39 -6
  47. data/lib/landable/version.rb +3 -3
  48. data/lib/tasks/landable/pgtap.rake +1 -2
  49. data/script/pgtap +10 -0
  50. data/script/redb +0 -2
  51. data/spec/concerns/landable/librarian.rb +45 -0
  52. data/spec/controllers/public/preview/pages_controller_spec.rb +1 -1
  53. data/spec/dummy/db/.keep +0 -0
  54. data/spec/models/landable/page_revision_spec.rb +60 -2
  55. data/spec/models/landable/page_spec.rb +3 -1
  56. data/spec/services/landable/authentication_service_spec.rb +1 -1
  57. data/spec/services/landable/screenshot_service_spec.rb +43 -0
  58. data/spec/services/landable/tidy_service_spec.rb +3 -2
  59. metadata +67 -82
  60. data/landable-1.7.0.gem +0 -0
  61. data/spec/dummy/db/structure.sql +0 -3837
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68d0d159a866cc88742e6b5603bcd0d5edb09b65
4
- data.tar.gz: 2f1aa05942baaedab945f6163cebd4e65c5e4599
3
+ metadata.gz: 816bb86d55b2ddcc550fba26aa46b38866f1cc4d
4
+ data.tar.gz: f995700b848201ee82badbcb96fdc9f2f7c3934d
5
5
  SHA512:
6
- metadata.gz: d9faf6bc62457e8a574dc47ca2eb6a2b95593bb2bcc72db13bc1d3f54ba327bb241fff269d658a27ac8d72e8412b4e36804b01fc1485d5ed1b3afce450d8e09b
7
- data.tar.gz: ba14a46c7b46ae299eeb77d6b65568747ec989c3553816a0e947d70d9de1f7eb4f9d381eb60edad56edeca5cc45ce579a7b9cfb3f18ec8b4d1cc35815b705606
6
+ metadata.gz: ddbe06e57c7d69674f0861fb99869d76bf562c5148f7c97ee352b1ea73c7c532809aac6e9f87e26fab42f78164633d749820604622287717721ec5b504def4cc
7
+ data.tar.gz: 88dbec3b8cd76fcdf58f026b9ff748840d6f3c1639e0127b46b456ba15179d88d9bb56780cb5ea41029cdd2c21f2facbd17ab1cba1421ca887d56a1fc28ca4b0
data/.gitignore CHANGED
@@ -2,12 +2,15 @@
2
2
  *.swp
3
3
  Gemfile.lock
4
4
  .bundle/
5
+ db/test/output.txt
5
6
  log/*.log
6
7
  pkg/
7
8
  spec/dummy/db/*.sqlite3
8
9
  spec/dummy/db/*.sqlite3-journal
9
10
  spec/dummy/log/*.log
10
11
  spec/dummy/tmp/
12
+ spec/dummy/db/structure.sql
11
13
  spec/dummy/.sass-cache
12
14
  coverage/
13
15
  tmp/
16
+ landable-*.gem
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ landable
data/.travis.yml CHANGED
@@ -1,12 +1,30 @@
1
1
  language: ruby
2
+
3
+ env:
4
+ - RAILS_VERSION=4.0.0
5
+ - RAILS_VERSION=4.0.5
6
+ - RAILS_VERSION=4.1.0
7
+ - RAILS_VERSION=4.1.1
8
+
2
9
  rvm:
3
10
  - 1.9.3-p448
4
11
  - 2.0.0-p247
5
12
  - 2.1.2
13
+
6
14
  before_script:
15
+ - sudo apt-get update
16
+ - sudo apt-get install postgresql-server-dev-9.1 postgresql-contrib-9.1 libtap-parser-sourcehandler-pgtap-perl
17
+ - git clone https://github.com/theory/pgtap.git /tmp/pgtap
18
+ - env PG_CONFIG=/etc/postgresql/9.1/main/postgresql.conf && export PERL5LIB=/home/travis/perl5/lib/perl5 && cd /tmp/pgtap && make && sudo make install
7
19
  - psql -c "CREATE USER dummy WITH superuser" -U postgres
8
20
  - psql -c "CREATE DATABASE dummy_test;" -U postgres
21
+ - psql -d dummy_test -c "CREATE EXTENSION pgtap" -U postgres
22
+ - sudo sed -e 's/perl \-w/perl -w -X/' -i /usr/bin/pg_prove
23
+ - cd -
9
24
  script:
10
25
  - script/redb
11
- - bundle exec rspec spec
12
- - bundle exec cucumber features
26
+ - bundle exec rake landable
27
+
28
+ notifications:
29
+ # let enova know about the build
30
+ slack: enova:xzPNLg3AxkbkUcUlfn7sqHW5
data/CHANGELOG.md CHANGED
@@ -2,7 +2,14 @@
2
2
 
3
3
  See README.md before updating this file.
4
4
 
5
- ## Unreleased [#](https://github.com/enova/landable/compare/v1.7.1.rc1...master)
5
+ ## Unreleased [#](https://github.com/enova/landable/compare/v1.8.0...master)
6
+
7
+ ## 1.8.0 [#](https://github.com/enova/landable/compare/v1.7.1.rc1...v1.8.0)
8
+ * Removing geminabox [#11]
9
+ * Some fixes to the DB tests [#9]
10
+ * Rails 4.x support [#8]
11
+ * Screenshots by revision [#7]
12
+ * Soft deletes [#6]
6
13
 
7
14
  ## 1.7.1.rc1 [#](https://github.com/enova/landable/compare/v1.7.0...v1.7.1.rc1)
8
15
  * Allow for revisions for Templates [#3]
data/Gemfile CHANGED
@@ -1,18 +1,19 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- group :test do
4
- gem "cucumber-rails", require: false
5
- end
6
-
7
- # Declare your gem's dependencies in landable.gemspec.
8
- # Bundler will treat runtime dependencies like base dependencies, and
9
- # development dependencies will be added by default to the :development group.
3
+ # load dependencies from landable.gemspec
10
4
  gemspec
11
5
 
12
- # Declare any dependencies that are still in development here instead of in
13
- # your gemspec. These might include edge Rails or gems from your path or
14
- # Git. Remember to move these dependencies to your gemspec before releasing
15
- # your gem to rubygems.org.
6
+ # allow us to load up a specific version of rails, since the gemspec is
7
+ # concerned only with compatibility (see bin/test)
8
+ if ENV.key? 'RAILS_VERSION'
9
+ gem 'rails', ENV['RAILS_VERSION']
10
+ end
16
11
 
17
- # To use debugger
18
- # gem 'debugger'
12
+ # development/test dependencies, and anything else that doesn't belong or fit
13
+ # in the gemspec
14
+ group :test do
15
+ gem 'minitest'
16
+ gem 'shoulda-matchers'
17
+ gem 'cucumber-rails', require: false
18
+ gem 'test_after_commit'
19
+ end
data/Rakefile CHANGED
@@ -7,7 +7,6 @@ end
7
7
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
8
  load 'rails/tasks/engine.rake'
9
9
 
10
- require "bundler_geminabox/gem_tasks"
11
10
  Bundler::GemHelper.install_tasks
12
11
 
13
12
  Dir.glob(File.expand_path('../lib/tasks/landable/*.rake', __FILE__)).each { |f| load f }
@@ -1,55 +1,73 @@
1
- require_dependency "landable/api_controller"
2
- require_dependency "landable/asset_search_engine"
1
+ require_dependency 'landable/api_controller'
2
+ require_dependency 'landable/asset_search_engine'
3
3
 
4
4
  module Landable
5
5
  module Api
6
6
  class AssetsController < ApiController
7
- def index
8
- search = Landable::AssetSearchEngine.new search_params.merge(ids: params[:ids])
9
- respond_with search.results, meta: search.meta
10
- end
11
-
12
- def show
13
- respond_with Asset.find(params[:id])
14
- end
15
-
7
+ # filters
8
+ before_filter :load_asset, except: [:create, :index]
9
+
10
+ # RESTful methods
16
11
  def create
17
- asset = Asset.new asset_params
12
+ asset = Asset.new(asset_params)
18
13
 
19
14
  if original = asset.duplicate_of
20
15
  head :moved_permanently, location: asset_url(original)
21
16
  return
22
17
  end
23
-
18
+
24
19
  Asset.transaction do
25
20
  asset.author = current_author
26
21
  asset.save!
27
22
  end
28
-
23
+
29
24
  respond_with asset, status: :created, location: asset_url(asset)
30
25
  end
31
-
32
- def update
33
- asset = Asset.find(params[:id])
34
-
35
- asset.update_attributes! asset_params
36
-
37
- respond_with asset
26
+
27
+ def destroy
28
+ @asset.try(:deactivate)
29
+
30
+ respond_with @asset
31
+ end
32
+
33
+ def index
34
+ search = Landable::AssetSearchEngine.new(search_params.merge(ids: params[:ids]))
35
+ respond_with search.results, meta: search.meta
38
36
  end
39
37
 
40
- private
41
-
42
- def search_params
43
- @search_params ||=
44
- begin
45
- hash = params.permit(search: [:name])
46
- hash[:search] || {}
47
- end
38
+ def reactivate
39
+ @asset.try(:reactivate)
40
+
41
+ respond_with @asset
42
+ end
43
+
44
+ def show
45
+ respond_with @asset
48
46
  end
47
+
48
+ def update
49
+ @asset.update_attributes!(asset_params)
49
50
 
50
- def asset_params
51
- params.require(:asset).permit(:id, :name, :description, :data, :file)
51
+ respond_with @asset
52
52
  end
53
+
54
+ # custom methods
55
+ private
56
+ def asset_params
57
+ params.require(:asset).permit(:id, :name, :description, :data, :file)
58
+ end
59
+
60
+ def load_asset
61
+ @asset = Asset.find(params[:id])
62
+ end
63
+
64
+ def search_params
65
+ @search_params ||=
66
+ begin
67
+ hash = params.permit(search: [:name])
68
+ hash[:search] || {}
69
+ end
70
+ end
53
71
  end
54
72
  end
55
73
  end
@@ -1,37 +1,57 @@
1
- require_dependency "landable/api_controller"
1
+ require_dependency 'landable/api_controller'
2
2
 
3
3
  module Landable
4
4
  module Api
5
5
  class PagesController < ApiController
6
- def index
7
- search = Landable::PageSearchEngine.new search_params.merge(ids: params[:ids]), limit: 100
8
- respond_with search.results, meta: search.meta
9
- end
10
-
6
+ # filters
7
+ before_filter :load_page, except: [:create, :index, :preview]
8
+
9
+ # RESTful methods
11
10
  def create
12
11
  page = Page.new page_params
13
12
  page.updated_by_author = current_author
14
13
  page.save!
14
+
15
15
  respond_with page, status: :created, location: page_url(page)
16
16
  end
17
+
18
+ def destroy
19
+ @page.updated_by_author = current_author
20
+ @page.try(:deactivate)
17
21
 
18
- def show
19
- respond_with Page.find(params[:id])
22
+ respond_with @page
23
+ end
24
+
25
+ def index
26
+ search = Landable::PageSearchEngine.new search_params.merge(ids: params[:ids]), limit: 100
27
+
28
+ respond_with search.results, meta: search.meta
20
29
  end
21
30
 
31
+ def reactivate
32
+ @page.try(:reactivate)
33
+
34
+ respond_with @page
35
+ end
36
+
37
+ def show
38
+ respond_with @page
39
+ end
40
+
22
41
  def update
23
- page = Page.find params[:id]
24
- page.updated_by_author = current_author
25
- page.update_attributes! page_params
26
- respond_with page
42
+ @page.updated_by_author = current_author
43
+ @page.update_attributes!(page_params)
44
+
45
+ respond_with @page
27
46
  end
28
-
47
+
48
+ # custom methods
29
49
  def publish
30
- page = Page.find params[:id]
31
- page.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor]
32
- respond_with page
50
+ @page.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor]
51
+
52
+ respond_with @page
33
53
  end
34
-
54
+
35
55
  def preview
36
56
  page = Page.where(page_id: page_params[:id]).first_or_initialize
37
57
  page.attributes = page_params
@@ -46,51 +66,53 @@ module Landable
46
66
  content = RenderService.call(page, preview: true)
47
67
  end
48
68
  end
49
-
69
+
50
70
  respond_to do |format|
51
71
  format.json do
52
72
  render json: {
53
73
  page: {
54
74
  preview: content,
55
- errors: page.errors,
75
+ errors: page.errors
56
76
  }
57
77
  }
58
78
  end
59
79
  end
60
80
  end
61
-
81
+
62
82
  def screenshots
63
83
  Landable::ScreenshotService.call Page.find(params[:id])
64
84
 
65
- # "{}" is valid json, which jquery will accept as a successful response. "" is not.
85
+ # '{}' is valid json, which jquery will accept as a successful response. '' is not.
66
86
  render json: {}, status: 202
67
87
  end
68
-
88
+
69
89
  private
90
+ def load_page
91
+ @page = Page.find(params[:id])
92
+ end
93
+
94
+ def search_params
95
+ @search_params ||=
96
+ begin
97
+ hash = params.permit(search: [:path])
98
+ hash[:search] || {}
99
+ end
100
+ end
101
+
102
+ def page_params
103
+ params.require(:page).permit(:id, :path, :theme_id, :category_id, :title, :head_content, :body, :status_code, :redirect_url, :lock_version, :abstract, :hero_asset_name, meta_tags: [:description, :keywords, :robots])
104
+ end
105
+
106
+ def with_format(format, &block)
107
+ old_formats = formats
70
108
 
71
- def search_params
72
- @search_params ||=
73
109
  begin
74
- hash = params.permit(search: [:path])
75
- hash[:search] || {}
110
+ self.formats = [format]
111
+ return block.call
112
+ ensure
113
+ self.formats = old_formats
76
114
  end
77
- end
78
-
79
- def page_params
80
- params.require(:page).permit(:id, :path, :theme_id, :category_id, :title, :head_content, :body, :status_code, :redirect_url, :lock_version, :abstract, :hero_asset_name,
81
- meta_tags: [:description, :keywords, :robots])
82
- end
83
-
84
- def with_format(format, &block)
85
- old_formats = formats
86
-
87
- begin
88
- self.formats = [format]
89
- return block.call
90
- ensure
91
- self.formats = old_formats
92
115
  end
93
- end
94
116
  end
95
117
  end
96
118
  end
@@ -3,37 +3,61 @@ require_dependency "landable/api_controller"
3
3
  module Landable
4
4
  module Api
5
5
  class TemplatesController < ApiController
6
- def index
7
- respond_with Template.all
8
- end
6
+ # filters
7
+ before_filter :load_template, except: [:create, :index]
9
8
 
9
+ # RESTful methods
10
10
  def create
11
11
  template = Template.new(template_params)
12
12
  template.save!
13
+
13
14
  respond_with template, status: :created, location: template_url(template)
14
15
  end
15
16
 
17
+ def destroy
18
+ @template.temp_author = current_author
19
+ @template.try(:deactivate)
20
+
21
+ respond_with @template
22
+ end
23
+
24
+ def index
25
+ respond_with Template.all
26
+ end
27
+
16
28
  def show
17
- respond_with Template.find(params[:id])
29
+ respond_with @template
18
30
  end
19
31
 
20
32
  def update
21
- template = Template.find(params[:id])
22
- template.update_attributes! template_params
23
- respond_with template
33
+ @template.update_attributes!(template_params)
34
+
35
+ respond_with @template
24
36
  end
25
37
 
38
+ # custom methods
26
39
  def publish
27
- template = Template.find params[:id]
28
- template.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor]
29
- respond_with template
40
+ @template.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor]
41
+
42
+ respond_with @template
43
+ end
44
+
45
+ def reactivate
46
+ @template.try(:reactivate)
47
+
48
+ respond_with @template
30
49
  end
31
50
 
32
51
  private
52
+ def load_template
53
+ @template = Template.find(params[:id])
54
+ end
33
55
 
34
- def template_params
35
- params.require(:template).permit(:id, :name, :body, :description, :thumbnail_url, :slug, :is_layout, :is_publishable)
36
- end
56
+ def template_params
57
+ params.require(:template).permit(:id, :name, :body, :description, :thumbnail_url, :slug, :is_layout, :is_publishable)
58
+ end
59
+
60
+ # end
37
61
  end
38
62
  end
39
63
  end