releaf-core 1.1.14 → 1.1.15

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: f4323ee3e9a27822649d98f7aed7818667753f89
4
- data.tar.gz: efa501ef6988fcc657109fea9897812c5581e4dd
3
+ metadata.gz: fbb27a39f7cda96944b4f0f2e73acf433e75fb03
4
+ data.tar.gz: 5d4ae2f2f806b98921e24843d3fa37882452f75f
5
5
  SHA512:
6
- metadata.gz: c43ec81cbea35299c280fe204a867a1bdd92f19b211c661857896cbb63201b1500e03642a772a31c26aafe815785da5222e45b1076c2469438e2654f955e9091
7
- data.tar.gz: d8cbe4cbc651334be99893fd181390c7ca09464fd7eb2d1ec493b748e6877b98bf690afadb79799d6030a60be092ff77bd951b1dfa434f709bd7a05ab9d03e3c
6
+ metadata.gz: 5139843d83c0273de34b8f1a1eb7ba96e208695e2d806996c640b36b41d95b8eeed657bde84d1c54af9845d8182a34c0bdd9cd1202a45043ddeab5e11be82da0
7
+ data.tar.gz: bc688fd1c6653c2a5beb5dcbdd4192b92cb5ea1776834e2d446a938727f107ce39e8d6af8fc9f8e238d8da35ab098c57f8c44941a07a38fe285e1033a71da5f1
@@ -149,6 +149,11 @@ class Releaf::Builders::TableBuilder
149
149
  format_text_content(resource, column)
150
150
  end
151
151
 
152
+ def format_richtext_content(resource, column)
153
+ value = ActionView::Base.full_sanitizer.sanitize(column_value(resource, column).to_s)
154
+ truncate(value, length: 32, separator: ' ')
155
+ end
156
+
152
157
  def format_string_content(resource, column)
153
158
  value = column_value(resource, column)
154
159
  resource_title(value)
@@ -34,6 +34,6 @@ class Releaf::Settings < RailsSettings::Base
34
34
  end
35
35
 
36
36
  def self.supported_types
37
- [:boolean, :date, :time, :datetime, :integer, :float, :decimal, :email, :text, :textarea]
37
+ [:boolean, :date, :time, :datetime, :integer, :float, :decimal, :email, :text, :textarea, :richtext]
38
38
  end
39
39
  end
@@ -364,6 +364,21 @@ describe Releaf::Builders::TableBuilder, type: :class do
364
364
  end
365
365
  end
366
366
 
367
+ describe "#format_richtext_content" do
368
+ it "returns truncated and sanitized column value" do
369
+ allow(subject).to receive(:column_value).with(resource, :title)
370
+ .and_return('"Pra<tag>nt commodo\ncursus magn')
371
+ expect(subject.format_richtext_content(resource, :title))
372
+ .to eq('&quot;Prant commodo\ncursus magn')
373
+ end
374
+
375
+ it "casts value to string before truncation" do
376
+ allow(subject).to receive(:column_value).with(resource, :title)
377
+ .and_return(nil)
378
+ expect(subject.format_richtext_content(resource, :title)).to eq("")
379
+ end
380
+ end
381
+
367
382
  describe "#format_textarea_content" do
368
383
  it "returns truncated and escape column value" do
369
384
  allow(subject).to receive(:column_value).with(resource, :title)
@@ -8,13 +8,14 @@ feature "Settings", js: true do
8
8
  {key: "content.title", default: "some"},
9
9
  {key: "content.date", default: DateTime.parse("2015-05-02"), type: "date"},
10
10
  {key: "content.textarea", type: :textarea},
11
+ {key: "content.richtext", type: :richtext},
11
12
  ]
12
13
  Releaf::Settings.destroy_all
13
14
  Releaf::Settings.register(*values)
14
15
  auth_as_user
15
16
 
16
17
  visit releaf_settings_path
17
- expect(page).to have_number_of_resources(6)
18
+ expect(page).to have_number_of_resources(7)
18
19
  expect(page).to have_css(".table.releaf\\/settings tbody tr:first-child td:first-child", text: "content.date")
19
20
  expect(page).to have_css(".table.releaf\\/settings tbody tr:first-child td:nth-child(2)", text: /^Sat, 02 May 2015 00:00:00 \+0000$/)
20
21
  expect(page).to have_css(".table.releaf\\/settings tbody tr:last-child td:first-child", text: "content.updated_at")
@@ -54,5 +55,16 @@ feature "Settings", js: true do
54
55
 
55
56
  expect(Releaf::Settings["content.textarea"]).to eq("AA\r\nBB\r\nCC\r\nDD\r\n")
56
57
  expect(page).to have_content("AA\nBB\nCC\nDD\n")
58
+
59
+ click_link "content.richtext"
60
+ wait_for_all_richtexts
61
+
62
+ update_resource do
63
+ fill_in_richtext "Value", with: "<p>EE<br/>FF</p>\nGG\n<b>HH</b>\n"
64
+ end
65
+ click_link "Back to list"
66
+
67
+ expect(Releaf::Settings["content.richtext"]).to eq("<p>EE<br />\r\nFF</p>\r\n\r\n<p>GG <b>HH</b></p>\r\n")
68
+ expect(page).to have_content("EE\nFF\nGG\nHH\n")
57
69
  end
58
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releaf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.14
4
+ version: 1.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems