rails_admin_content_builder 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +4 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +129 -0
- data/Rakefile +21 -0
- data/app/assets/images/cb-image-default.jpg +0 -0
- data/app/assets/images/cb-loading.svg +1 -0
- data/app/assets/images/cb-snippet-image-text.jpg +0 -0
- data/app/assets/images/cb-snippet-image.jpg +0 -0
- data/app/assets/images/cb-snippet-quote-text.jpg +0 -0
- data/app/assets/images/cb-snippet-quote.jpg +0 -0
- data/app/assets/images/cb-snippet-text-image.jpg +0 -0
- data/app/assets/images/cb-snippet-text-quote.jpg +0 -0
- data/app/assets/images/cb-snippet-text.jpg +0 -0
- data/app/assets/images/cb-snippet-video.jpg +0 -0
- data/app/assets/images/cb-video-default.jpg +0 -0
- data/app/assets/javascripts/rails_admin/content_builder.js.erb +295 -0
- data/app/assets/stylesheets/rails_admin/content_builder.scss +238 -0
- data/app/controllers/rails_admin_content_builder/content_builder_controller.rb +19 -0
- data/app/helpers/rails_admin_content_builder/content_builder_helpers.rb +32 -0
- data/app/models/rails_admin_content_builder/content_builder.rb +27 -0
- data/app/models/rails_admin_content_builder/content_builder_category.rb +12 -0
- data/app/models/rails_admin_content_builder/content_builder_image.rb +10 -0
- data/app/views/.gitkeep +0 -0
- data/app/views/rails_admin/main/content_builder.html.erb +42 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/assets.rb +11 -0
- data/config/locales/content_builder.en.yml +17 -0
- data/config/locales/content_builder.pt-BR.yml +17 -0
- data/config/routes.rb +5 -0
- data/lib/generators/rails_admin_content_builder_generator.rb +32 -0
- data/lib/generators/templates/content_builder_image_uploader.rb +54 -0
- data/lib/generators/templates/create_content_builder_category_migration.rb +10 -0
- data/lib/generators/templates/create_content_builder_image_migration.rb +10 -0
- data/lib/generators/templates/create_content_builder_migration.rb +16 -0
- data/lib/generators/templates/rails_admin_content_builder.rb +37 -0
- data/lib/rails_admin_content_builder.rb +55 -0
- data/lib/rails_admin_content_builder/engine.rb +26 -0
- data/lib/rails_admin_content_builder/version.rb +3 -0
- data/rails_admin_content_builder.gemspec +42 -0
- data/screenshot/image1.png +0 -0
- data/spec/controllers/rails_admin_content_builder/content_builder_controller_spec.rb +19 -0
- data/spec/dummy/Gemfile +11 -0
- data/spec/dummy/Gemfile.lock +217 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/uploaders/content_builder_image_uploader.rb +54 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/rails_admin.rb +37 -0
- data/spec/dummy/config/initializers/rails_admin_content_builder.rb +37 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/simple_form.rb +165 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/locales/simple_form.en.yml +31 -0
- data/spec/dummy/config/routes.rb +57 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20160713200802_create_content_builder_categories.rb +10 -0
- data/spec/dummy/db/migrate/20160713200803_create_content_builders.rb +15 -0
- data/spec/dummy/db/migrate/20160713200804_create_content_builder_images.rb +10 -0
- data/spec/dummy/db/schema.rb +46 -0
- data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/dummy/log/development.log +1182 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/center_example.jpg +0 -0
- data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/example.jpg +0 -0
- data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/left_or_right_example.jpg +0 -0
- data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/center_example.jpg +0 -0
- data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/example.jpg +0 -0
- data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/left_or_right_example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693110-14578-0001-7683/center_example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693110-14578-0001-7683/example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693110-14578-0001-7683/left_or_right_example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693202-14651-0001-6505/center_example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693202-14651-0001-6505/example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693202-14651-0001-6505/left_or_right_example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693245-14728-0001-4392/center_example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693245-14728-0001-4392/example.jpg +0 -0
- data/spec/dummy/public/uploads/tmp/1461693245-14728-0001-4392/left_or_right_example.jpg +0 -0
- data/spec/factories/content_builder_categories.rb +5 -0
- data/spec/factories/content_builder_images.rb +6 -0
- data/spec/factories/content_builders.rb +10 -0
- data/spec/features/create_content_builder_category_spec.rb +18 -0
- data/spec/features/create_content_builder_spec.rb +34 -0
- data/spec/features/status_content_builder_spec.rb +28 -0
- data/spec/fixtures/assets/example.jpg +0 -0
- data/spec/helpers/rails_admin_content_builder/content_builder_helper_spec.rb +33 -0
- data/spec/models/rails_admin_content_builder/content_builder_category_spec.rb +11 -0
- data/spec/models/rails_admin_content_builder/content_builder_image_spec.rb +11 -0
- data/spec/models/rails_admin_content_builder/content_builder_spec.rb +44 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/version_spec.rb +7 -0
- data/vendor/assets/stylesheets/rails_admin_content_builder.scss +214 -0
- metadata +3100 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
Binary file
|
data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/example.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/example.jpg
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :content_builder, class: RailsAdminContentBuilder::ContentBuilder do
|
3
|
+
title { Faker::Lorem.characters }
|
4
|
+
date_publish { Time.now }
|
5
|
+
written_by { Faker::Name.name }
|
6
|
+
content ''
|
7
|
+
content_builder_category factory: :content_builder_category
|
8
|
+
status false
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'create content builder category', :type => :feature do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@model_name = 'rails_admin_content_builder~content_builder_category'
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'first step', js: false do
|
10
|
+
visit rails_admin.new_path(model_name: @model_name)
|
11
|
+
|
12
|
+
fill_in('Name', with: Faker::Lorem.characters)
|
13
|
+
|
14
|
+
click_button('Save')
|
15
|
+
|
16
|
+
expect(page).to have_content('Content builder category successfully created')
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'create content builder', :type => :feature do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@model_name = 'rails_admin_content_builder~content_builder'
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'first step', js: false do
|
10
|
+
category = FactoryGirl.create(:content_builder_category)
|
11
|
+
visit rails_admin.new_path(model_name: @model_name)
|
12
|
+
|
13
|
+
fill_in('Title', with: Faker::Lorem.characters)
|
14
|
+
fill_in('Date publish', with: 'April 25, 2016 15:48')
|
15
|
+
fill_in('Written by', with: Faker::Internet.url)
|
16
|
+
select(category.name, :from => 'Content builder category')
|
17
|
+
|
18
|
+
click_button('Save')
|
19
|
+
|
20
|
+
expect(page).to have_content('Content builder successfully created')
|
21
|
+
end
|
22
|
+
|
23
|
+
scenario 'second step', js: false do
|
24
|
+
content = FactoryGirl.create(:content_builder)
|
25
|
+
visit rails_admin.content_builder_path(model_name: @model_name, id: content.id)
|
26
|
+
|
27
|
+
# find('a[href="#"][data-snippet="1"]').click
|
28
|
+
# find('img[alt="Snippet text"]').click
|
29
|
+
|
30
|
+
click_button('Save')
|
31
|
+
|
32
|
+
expect(page).to have_content('Successfully updated')
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'change status content builder', :type => :feature do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@model_name = 'rails_admin_content_builder~content_builder'
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'publish', js: false do
|
10
|
+
content = FactoryGirl.create(:content_builder)
|
11
|
+
visit rails_admin.content_builder_path(model_name: @model_name, id: content.id)
|
12
|
+
|
13
|
+
click_button('Publish')
|
14
|
+
|
15
|
+
expect(page).to have_content('Successfully updated')
|
16
|
+
expect(page).to have_selector("input[type=submit][name='unpublish']")
|
17
|
+
end
|
18
|
+
|
19
|
+
scenario 'unpublish', js: false do
|
20
|
+
content = FactoryGirl.create(:content_builder, status: true)
|
21
|
+
visit rails_admin.content_builder_path(model_name: @model_name, id: content.id)
|
22
|
+
|
23
|
+
click_button('Unpublish')
|
24
|
+
|
25
|
+
expect(page).to have_content('Successfully updated')
|
26
|
+
expect(page).to have_selector("input[type=submit][name='publish']")
|
27
|
+
end
|
28
|
+
end
|
Binary file
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RailsAdminContentBuilder::ContentBuilderHelpers, type: :helper do
|
4
|
+
describe "#content_created" do
|
5
|
+
it "return object content" do
|
6
|
+
expect(helper.content_created).to eq(RailsAdminContentBuilder::ContentBuilder)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#all_contents_created" do
|
11
|
+
it "return all contents abjects with status true" do
|
12
|
+
content = FactoryGirl.create(:content_builder, status: true)
|
13
|
+
expect(helper.all_contents_created).to include(content)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "not return all contents objects with status false" do
|
17
|
+
content = FactoryGirl.create(:content_builder, status: false)
|
18
|
+
expect(helper.all_contents_created).not_to include(content)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#find_content_created_by_slug" do
|
23
|
+
it "return contents objects by slug with status true" do
|
24
|
+
content = FactoryGirl.create(:content_builder, status: true)
|
25
|
+
expect(helper.find_content_created_by_slug(content.slug)).to eq(content)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "return contents objects by slug with status true" do
|
29
|
+
content = FactoryGirl.create(:content_builder, status: false)
|
30
|
+
expect(helper.find_content_created_by_slug(content.slug)).not_to eq(content)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RailsAdminContentBuilder::ContentBuilderCategory, :type => :model do
|
4
|
+
describe 'validates' do
|
5
|
+
it { should validate_presence_of(:name) }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'associations' do
|
9
|
+
it { should have_many(:content_builders) }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RailsAdminContentBuilder::ContentBuilderImage, :type => :model do
|
4
|
+
describe 'validates' do
|
5
|
+
it { should validate_presence_of(:image) }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'associations' do
|
9
|
+
it { should belong_to(:content_builder) }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RailsAdminContentBuilder::ContentBuilder, :type => :model do
|
4
|
+
describe 'validates' do
|
5
|
+
it { should validate_presence_of(:title) }
|
6
|
+
it { should validate_presence_of(:date_publish) }
|
7
|
+
it { should validate_presence_of(:written_by) }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'associations' do
|
11
|
+
it { should have_many(:content_builder_images) }
|
12
|
+
it { should belong_to(:content_builder_category) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'search' do
|
16
|
+
content = FactoryGirl.create(:content_builder)
|
17
|
+
|
18
|
+
it 'should return a searched content by title' do
|
19
|
+
output = RailsAdminContentBuilder::ContentBuilder.search(content.title).last
|
20
|
+
expect(output).to eq(content)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return a searched content by content' do
|
24
|
+
output = RailsAdminContentBuilder::ContentBuilder.search(content.content).last
|
25
|
+
expect(output).to eq(content)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'content_sanitized' do
|
30
|
+
it 'should return only tag "div p img figure figcaption a iframe"' do
|
31
|
+
@content_input = '<div></div><input/><mytag myattr="teste"></mytag><p></p><img/><figure></figure><figcaption></figcaption><a></a><iframe></iframe><textarea>'
|
32
|
+
@content_output = '<div></div><p></p><img><figure></figure><figcaption></figcaption><a></a><iframe></iframe>'
|
33
|
+
content = FactoryGirl.create(:content_builder, content: @content_input)
|
34
|
+
expect(content.content_sanitized).to eq(@content_output)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should return only attrs "src class alt href allowfullscreen frameborder height width"' do
|
38
|
+
@content_input = '<div class="test" data-method="test"></div><input/><p id="test"></p><img src="test" id="test"/><figure></figure><figcaption></figcaption><a href="#"></a><iframe></iframe><textarea>'
|
39
|
+
@content_output = '<div class="test"></div><p></p><img src="test"><figure></figure><figcaption></figcaption><a href="#"></a><iframe></iframe>'
|
40
|
+
content = FactoryGirl.create(:content_builder, content: @content_input)
|
41
|
+
expect(content.content_sanitized).to eq(@content_output)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|