landable 1.11.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33e0d69e6891c96f2d1a009ef58a5a82ddc5f3a6
4
- data.tar.gz: d5007db85e84798a12c6abf7e6d1c43548264556
3
+ metadata.gz: 7eeff5bea21d975e1a609fae486601fd56f01d14
4
+ data.tar.gz: 5166ca9ae9d0ce55bc358e277f9ecffea37fbd7e
5
5
  SHA512:
6
- metadata.gz: 8e1199458a3de14521df62769d390e8fbc4fccac423a58903be15af167b99ca9855c2ab7765183d95e7c2b09ae7e0d98fac0aa879c8d7a09dc125eb8438d6594
7
- data.tar.gz: f569cbfb3c711e2f2c2453eff742d1b8c4ca7498c9d5bf2ed0fc1b453fdcd5455fc193f9c0eeeb22f5a45bfa8577bcccb8978b4a10239c4e7fa3e3824137d8ff
6
+ metadata.gz: 7c1cf3cead1831d185ad8054651c6f6caf69e933aa1662a775011857a66e89ec4f337a408ebbe597cbcab12b1ab7fec6df48e457303ad6e337ac5c2990122b90
7
+ data.tar.gz: fad90831911bae1b77ed361ee0ad66bc1e643316798c92fa9fab99764cce0bb5975b0814933dd62283ed643d6732b7390874221ef5daf3252368f4e50d713d3c
data/CHANGELOG.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  See README.md before updating this file.
4
4
 
5
- ## Unreleased [#](https://github.com/enova/landable/compare/v1.11.0...master)
5
+ ## Unreleased [#](https://github.com/enova/landable/compare/v1.11.1...master)
6
+
7
+ ## 1.11.1 [#](https://github.com/enova/landable/compare/v1.11.0...v1.11.1)
8
+ * Adding PageName [#39]
9
+ * Force Template Slug to not have a space [#40]
6
10
 
7
11
  ## 1.11.0 [#](https://github.com/enova/landable/compare/v1.10.0.rc1...v1.11.0)
8
12
  * Make the tracker.user_agent accessible [#33]
@@ -112,7 +112,12 @@ module Landable
112
112
 
113
113
  def page_params
114
114
  params[:page][:audit_flags] ||= []
115
- params.require(:page).permit(:id, :path, :theme_id, :category_id, :title, :head_content, :body, :status_code, :redirect_url, :lock_version, :abstract, :hero_asset_name,
115
+ params.require(:page).permit(:id, :path, :theme_id,
116
+ :category_id, :title,
117
+ :head_content, :body,
118
+ :status_code, :redirect_url,
119
+ :lock_version, :abstract,
120
+ :hero_asset_name, :page_name,
116
121
  audit_flags: [],
117
122
  meta_tags: [:description, :keywords, :robots])
118
123
  end
@@ -15,6 +15,10 @@ module Landable
15
15
  page.path
16
16
  end
17
17
 
18
+ def page_name
19
+ page.page_name
20
+ end
21
+
18
22
  def body
19
23
  page.body.try(:html_safe)
20
24
  end
@@ -22,6 +22,8 @@ module Landable
22
22
  validates_uniqueness_of :path
23
23
  validates :path, presence: true
24
24
 
25
+ validate :page_name_byte_size
26
+
25
27
  validate :forbid_changing_path, on: :update
26
28
 
27
29
  validate :body_strip_search
@@ -226,6 +228,12 @@ module Landable
226
228
  end
227
229
  end
228
230
 
231
+ def page_name_byte_size
232
+ if page_name.present? && page_name.bytesize > 100
233
+ errors[:page_name] = 'Invalid PageName, bytesize is too big!'
234
+ end
235
+ end
236
+
229
237
  def hero_asset_existence
230
238
  return true if @hero_asset_name.blank?
231
239
  unless Asset.find_by_name(@hero_asset_name)
@@ -16,7 +16,8 @@ module Landable
16
16
  'is_publishable',
17
17
  'updated_by_author_id',
18
18
  'lock_version',
19
- 'audit_flags'
19
+ 'audit_flags',
20
+ 'page_name'
20
21
  ]
21
22
 
22
23
  cattr_accessor :ignored_page_attributes
@@ -10,6 +10,8 @@ module Landable
10
10
  validates_uniqueness_of :name, case_sensitive: false
11
11
  validates_uniqueness_of :slug, case_sensitive: false
12
12
 
13
+ before_save :slug_has_no_spaces
14
+
13
15
 
14
16
  belongs_to :published_revision, class_name: 'Landable::TemplateRevision'
15
17
  has_many :audits, class_name: 'Landable::Audit', as: :auditable
@@ -63,6 +65,12 @@ module Landable
63
65
  save!
64
66
  end
65
67
 
68
+ def slug_has_no_spaces
69
+ if self.slug =~ /\s/ # check if whitespace
70
+ self.slug = self.slug.underscore.gsub(/[^\w_]/, '_').gsub(/_{2,}/, '_')
71
+ end
72
+ end
73
+
66
74
  class << self
67
75
  def create_from_partials!
68
76
  Partial.all.map(&:to_template)
@@ -5,7 +5,7 @@ module Landable
5
5
  attributes :head_content, :meta_tags
6
6
  attributes :status_code, :redirect_url
7
7
  attributes :is_publishable, :preview_path
8
- attributes :audit_flags
8
+ attributes :audit_flags, :page_name
9
9
  attributes :hero_asset_name, :abstract
10
10
  attributes :lock_version
11
11
  attributes :deleted_at
@@ -0,0 +1,5 @@
1
+ class AddPageNameToPage < ActiveRecord::Migration
2
+ def change
3
+ add_column "#{Landable.configuration.database_schema_prefix}landable.pages", :page_name, :string
4
+ end
5
+ end
data/doc/schema/page.json CHANGED
@@ -97,6 +97,10 @@
97
97
  "type": ["string", "null"]
98
98
  },
99
99
 
100
+ "page_name": {
101
+ "type": ["string", "null"]
102
+ },
103
+
100
104
  "audit_flags" : {
101
105
  "type" : ["array", "null"],
102
106
  "items" : { "type" : "string"}
@@ -2,7 +2,7 @@ module Landable
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 11
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -3,7 +3,10 @@ require 'spec_helper'
3
3
  module Landable
4
4
  describe HasTemplates do
5
5
 
6
- before(:each) { create_list :template, 3 }
6
+ before(:each) do
7
+ create_list :template, 2
8
+ create :template, slug: 'I have a space'
9
+ end
7
10
 
8
11
  let(:templates) { Landable::Template.last(3) }
9
12
  let(:subject) {
@@ -7,6 +7,9 @@ module Landable
7
7
  it { should have_valid(:status_code).when(200, 301, 302, 410) }
8
8
  it { should_not have_valid(:status_code).when(201, 303, 405, 500, 404) }
9
9
 
10
+ it { should have_valid(:page_name).when(nil, 'Hello', 'adssad', '212131') }
11
+ it { should_not have_valid(:page_name).when("#{'hello' * 100}") }
12
+
10
13
  # config.reserved_paths = %w(/reserved_path_set_in_initializer /reject/.* /admin.*)
11
14
  context 'PathValidator' do
12
15
  it { should_not have_valid(:path).when(nil, '', '/reserved_path_set_in_initializer') }
@@ -119,5 +119,24 @@ module Landable
119
119
  template.revert_to! revision
120
120
  end
121
121
  end
122
+
123
+ describe '#slug_has_no_spaces' do
124
+ it 'should not allow a slug with out underscores' do
125
+ t = build :template, slug: 'I have no space'
126
+ t.name = 'No Space'
127
+ t.save!
128
+
129
+ t.slug.should_not == 'I have no space'
130
+ t.slug.should == 'i_have_no_space'
131
+ end
132
+
133
+ it 'should allow the name to set the slug' do
134
+ t = build :template, slug: nil
135
+ t.name = 'I have no space'
136
+ t.save!
137
+
138
+ t.slug.should == 'i_have_no_space'
139
+ end
140
+ end
122
141
  end
123
142
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: landable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Trogdor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -462,6 +462,7 @@ files:
462
462
  - db/migrate/20140515164543_add_screenshot_to_page_revisions.rb
463
463
  - db/migrate/20140522202332_join_table_templates_pages.rb
464
464
  - db/migrate/20140602213937_path_response_time_view.rb
465
+ - db/migrate/20141211200012_add_page_name_to_page.rb
465
466
  - db/test/landable.access_tokens.sql
466
467
  - db/test/landable.assets.sql
467
468
  - db/test/landable.authors.sql