redditor 0.1.0
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 +7 -0
- data/.gitignore +27 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +23 -0
- data/Guardfile +24 -0
- data/MIT-LICENSE +20 -0
- data/README.md +16 -0
- data/Rakefile +23 -0
- data/app/assets/images/redditor/.keep +0 -0
- data/app/assets/images/redditor/add_photo.png +0 -0
- data/app/assets/images/redditor/add_photo_big.png +0 -0
- data/app/assets/images/redditor/add_slider.png +0 -0
- data/app/assets/images/redditor/add_slider_big.png +0 -0
- data/app/assets/images/redditor/add_txt.png +0 -0
- data/app/assets/images/redditor/add_txt_big.png +0 -0
- data/app/assets/images/redditor/add_video.png +0 -0
- data/app/assets/images/redditor/add_video_big.png +0 -0
- data/app/assets/images/redditor/destroy_block_text.png +0 -0
- data/app/assets/images/redditor/move_handler.png +0 -0
- data/app/assets/images/redditor/no_format_text.png +0 -0
- data/app/assets/images/redditor/trash.png +0 -0
- data/app/assets/javascripts/fileapi/FileAPI.exif.js +59 -0
- data/app/assets/javascripts/fileapi/FileAPI.flash.image.swf +0 -0
- data/app/assets/javascripts/fileapi/FileAPI.flash.swf +0 -0
- data/app/assets/javascripts/fileapi/FileAPI.id3.js +67 -0
- data/app/assets/javascripts/fileapi/FileAPI.min.js +73 -0
- data/app/assets/javascripts/fileapi/fileapi.js.coffee.erb +12 -0
- data/app/assets/javascripts/fileapi/tmpl.js +35 -0
- data/app/assets/javascripts/fileapi/uploader.coffee +139 -0
- data/app/assets/javascripts/jquery-ui.min.js +12 -0
- data/app/assets/javascripts/redditor/application.js +14 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.exif.js +59 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.flash.image.swf +0 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.flash.swf +0 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.id3.js +67 -0
- data/app/assets/javascripts/redditor/fileapi/FileAPI.min.js +72 -0
- data/app/assets/javascripts/redditor/fileapi/README.md +724 -0
- data/app/assets/javascripts/redditor/fileapi/config.js.coffee.erb +5 -0
- data/app/assets/javascripts/redditor/fileapi/crossdomain.xml +19 -0
- data/app/assets/javascripts/redditor/fileapi/example.userpic.html +212 -0
- data/app/assets/javascripts/redditor/fileapi/index.html +548 -0
- data/app/assets/javascripts/redditor/fileapi/mailru.js +6 -0
- data/app/assets/javascripts/redditor/fileapi/mailru_front.js.coffee +143 -0
- data/app/assets/javascripts/redditor/fileapi/tmpl.js +35 -0
- data/app/assets/javascripts/redditor/fileapi/uploader.coffee +139 -0
- data/app/assets/javascripts/redditor/redditor.coffee +148 -0
- data/app/assets/stylesheets/redditor/application.css.scss +47 -0
- data/app/assets/stylesheets/redditor/fileapi/fileapi.css.scss +174 -0
- data/app/assets/stylesheets/redditor/fileapi/fileapi_front.css.scss +175 -0
- data/app/assets/stylesheets/redditor/redditor.css.scss +108 -0
- data/app/controllers/redditor/admin/base_controller.rb +18 -0
- data/app/controllers/redditor/admin/image_blocks_controller.rb +37 -0
- data/app/controllers/redditor/admin/images_controller.rb +33 -0
- data/app/controllers/redditor/admin/pages_controller.rb +15 -0
- data/app/controllers/redditor/admin/slider_blocks_controller.rb +32 -0
- data/app/controllers/redditor/admin/text_blocks_controller.rb +31 -0
- data/app/controllers/redditor/admin/video_blocks_controller.rb +31 -0
- data/app/controllers/redditor/application_controller.rb +4 -0
- data/app/helpers/redditor/application_helper.rb +4 -0
- data/app/helpers/redditor/fileapi_helper.rb +17 -0
- data/app/helpers/redditor/pages_helper.rb +24 -0
- data/app/models/redditor/content_block.rb +24 -0
- data/app/models/redditor/image.rb +29 -0
- data/app/models/redditor/page.rb +28 -0
- data/app/models/redditor/slider_block.rb +17 -0
- data/app/models/redditor/text_block.rb +20 -0
- data/app/models/redditor/video_block.rb +27 -0
- data/app/uploaders/redditor_uploader.rb +57 -0
- data/app/views/layouts/redditor/application.html.erb +15 -0
- data/app/views/redditor/admin/pages/_content_block.haml +16 -0
- data/app/views/redditor/admin/pages/_fileapi.erb +199 -0
- data/app/views/redditor/admin/pages/_image.haml +18 -0
- data/app/views/redditor/admin/pages/_page.haml +13 -0
- data/app/views/redditor/admin/pages/_slider_block.haml +16 -0
- data/app/views/redditor/admin/pages/_slider_block_image.haml +3 -0
- data/app/views/redditor/admin/pages/_text_block.haml +5 -0
- data/app/views/redditor/admin/pages/_validate.haml +4 -0
- data/app/views/redditor/admin/pages/_video_block.haml +19 -0
- data/app/views/redditor/admin/pages/_wrap_dd.haml +1 -0
- data/app/views/redditor/admin/pages/_wrapper.haml +3 -0
- data/app/views/redditor/admin/pages/new.js.coffee +7 -0
- data/app/views/redditor/admin/pages/new.js.erb +7 -0
- data/app/views/redditor/admin/pages/slider_block_image.js.coffee +2 -0
- data/app/views/redditor/admin/pages/wrapper.js.coffee +6 -0
- data/app/views/redditor/pages/_page.html.haml +1 -0
- data/app/views/redditor/slider_blocks/_slider_block.html.haml +2 -0
- data/app/views/redditor/slider_blocks/_slider_block_image.html.erb +3 -0
- data/app/views/redditor/text_blocks/_text_block.html.haml +1 -0
- data/app/views/redditor/video_blocks/_video_block.html.haml +2 -0
- data/bin/rails +8 -0
- data/config/locales/redditor.en.yml +20 -0
- data/config/locales/redditor.ru.yml +20 -0
- data/config/routes.rb +17 -0
- data/db/migrate/20130916155124_create_redditor_images.rb +15 -0
- data/db/migrate/20130916155156_create_redditor_pages.rb +12 -0
- data/db/migrate/20130916155219_create_redditor_slider_blocks.rb +11 -0
- data/db/migrate/20130916155239_create_redditor_text_blocks.rb +12 -0
- data/db/migrate/20130916155301_create_redditor_video_blocks.rb +14 -0
- data/lib/generators/redditor/views/views_generator.rb +17 -0
- data/lib/redditor/engine.rb +12 -0
- data/lib/redditor/has_redditor.rb +17 -0
- data/lib/redditor/version.rb +3 -0
- data/lib/redditor.rb +9 -0
- data/lib/tasks/redditor_tasks.rake +4 -0
- data/redditor.gemspec +38 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +17 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/admin/articles_controller.rb +23 -0
- data/spec/dummy/app/controllers/admin/base_controller.rb +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/article.rb +7 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/admin/articles/edit.html.haml +15 -0
- data/spec/dummy/app/views/articles/show.html.haml +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -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/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 +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -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 +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +10 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20130908123351_create_articles.rb +9 -0
- data/spec/dummy/db/schema.rb +76 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/articles_factory.rb +27 -0
- data/spec/factories/redditor/images_factory.rb +9 -0
- data/spec/factories/redditor/pages_factory.rb +37 -0
- data/spec/factories/redditor/sliders_factory.rb +9 -0
- data/spec/factories/redditor/texts_factory.rb +5 -0
- data/spec/factories/redditor/videos_factories.rb +7 -0
- data/spec/features/text_spec.rb +52 -0
- data/spec/features/video_spec.rb +52 -0
- data/spec/fixtures/test.jpg +0 -0
- data/spec/generators/views_generator_spec.rb +20 -0
- data/spec/models/article_spec.rb +40 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/views/article/show_spec.rb +22 -0
- metadata +480 -0
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: #EFEFEF;
|
|
8
|
+
color: #2E2F30;
|
|
9
|
+
text-align: center;
|
|
10
|
+
font-family: arial, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 25em;
|
|
15
|
+
margin: 4em auto 0 auto;
|
|
16
|
+
border: 1px solid #CCC;
|
|
17
|
+
border-right-color: #999;
|
|
18
|
+
border-left-color: #999;
|
|
19
|
+
border-bottom-color: #BBB;
|
|
20
|
+
border-top: #B00100 solid 4px;
|
|
21
|
+
border-top-left-radius: 9px;
|
|
22
|
+
border-top-right-radius: 9px;
|
|
23
|
+
background-color: white;
|
|
24
|
+
padding: 7px 4em 0 4em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 100%;
|
|
29
|
+
color: #730E15;
|
|
30
|
+
line-height: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body > p {
|
|
34
|
+
width: 33em;
|
|
35
|
+
margin: 0 auto 1em;
|
|
36
|
+
padding: 1em 0;
|
|
37
|
+
background-color: #F7F7F7;
|
|
38
|
+
border: 1px solid #CCC;
|
|
39
|
+
border-right-color: #999;
|
|
40
|
+
border-bottom-color: #999;
|
|
41
|
+
border-bottom-left-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
border-top-color: #DADADA;
|
|
44
|
+
color: #666;
|
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
|
|
50
|
+
<body>
|
|
51
|
+
<!-- This file lives in public/404.html -->
|
|
52
|
+
<div class="dialog">
|
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
55
|
+
</div>
|
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: #EFEFEF;
|
|
8
|
+
color: #2E2F30;
|
|
9
|
+
text-align: center;
|
|
10
|
+
font-family: arial, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 25em;
|
|
15
|
+
margin: 4em auto 0 auto;
|
|
16
|
+
border: 1px solid #CCC;
|
|
17
|
+
border-right-color: #999;
|
|
18
|
+
border-left-color: #999;
|
|
19
|
+
border-bottom-color: #BBB;
|
|
20
|
+
border-top: #B00100 solid 4px;
|
|
21
|
+
border-top-left-radius: 9px;
|
|
22
|
+
border-top-right-radius: 9px;
|
|
23
|
+
background-color: white;
|
|
24
|
+
padding: 7px 4em 0 4em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 100%;
|
|
29
|
+
color: #730E15;
|
|
30
|
+
line-height: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body > p {
|
|
34
|
+
width: 33em;
|
|
35
|
+
margin: 0 auto 1em;
|
|
36
|
+
padding: 1em 0;
|
|
37
|
+
background-color: #F7F7F7;
|
|
38
|
+
border: 1px solid #CCC;
|
|
39
|
+
border-right-color: #999;
|
|
40
|
+
border-bottom-color: #999;
|
|
41
|
+
border-bottom-left-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
border-top-color: #DADADA;
|
|
44
|
+
color: #666;
|
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
|
|
50
|
+
<body>
|
|
51
|
+
<!-- This file lives in public/422.html -->
|
|
52
|
+
<div class="dialog">
|
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
55
|
+
</div>
|
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background-color: #EFEFEF;
|
|
8
|
+
color: #2E2F30;
|
|
9
|
+
text-align: center;
|
|
10
|
+
font-family: arial, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div.dialog {
|
|
14
|
+
width: 25em;
|
|
15
|
+
margin: 4em auto 0 auto;
|
|
16
|
+
border: 1px solid #CCC;
|
|
17
|
+
border-right-color: #999;
|
|
18
|
+
border-left-color: #999;
|
|
19
|
+
border-bottom-color: #BBB;
|
|
20
|
+
border-top: #B00100 solid 4px;
|
|
21
|
+
border-top-left-radius: 9px;
|
|
22
|
+
border-top-right-radius: 9px;
|
|
23
|
+
background-color: white;
|
|
24
|
+
padding: 7px 4em 0 4em;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h1 {
|
|
28
|
+
font-size: 100%;
|
|
29
|
+
color: #730E15;
|
|
30
|
+
line-height: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body > p {
|
|
34
|
+
width: 33em;
|
|
35
|
+
margin: 0 auto 1em;
|
|
36
|
+
padding: 1em 0;
|
|
37
|
+
background-color: #F7F7F7;
|
|
38
|
+
border: 1px solid #CCC;
|
|
39
|
+
border-right-color: #999;
|
|
40
|
+
border-bottom-color: #999;
|
|
41
|
+
border-bottom-left-radius: 4px;
|
|
42
|
+
border-bottom-right-radius: 4px;
|
|
43
|
+
border-top-color: #DADADA;
|
|
44
|
+
color: #666;
|
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
|
|
50
|
+
<body>
|
|
51
|
+
<!-- This file lives in public/500.html -->
|
|
52
|
+
<div class="dialog">
|
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
54
|
+
</div>
|
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
FactoryGirl.define do
|
|
2
|
+
factory :article do
|
|
3
|
+
title "Test article"
|
|
4
|
+
|
|
5
|
+
factory :full_article do
|
|
6
|
+
association :page, factory: :full_page
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
factory :text_article do
|
|
10
|
+
association :page, factory: :text_page
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
factory :slider_article do
|
|
15
|
+
association :page, factory: :slider_page
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
factory :image_article do
|
|
19
|
+
association :page, factory: :image_page
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
factory :video_article do
|
|
23
|
+
association :page, factory: :video_page
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
FactoryGirl.define do
|
|
2
|
+
|
|
3
|
+
sequence(:image_name) { |n| "image name #{n}" }
|
|
4
|
+
|
|
5
|
+
factory :image, class: Redditor::Image do
|
|
6
|
+
description { generate(:image_name) }
|
|
7
|
+
src { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'fixtures', 'test.jpg')) }
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
FactoryGirl.define do
|
|
2
|
+
factory :page, class: Redditor::Page do
|
|
3
|
+
|
|
4
|
+
factory :full_page do
|
|
5
|
+
after(:create) do |page|
|
|
6
|
+
create(:slider, page: page, position: 1)
|
|
7
|
+
create(:text, page: page, position: 2)
|
|
8
|
+
create(:video, page: page, position: 3)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
factory :slider_page do
|
|
13
|
+
after(:create) do |page|
|
|
14
|
+
create(:slider, page: page, position: 1)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
factory :video_page do
|
|
19
|
+
after(:create) do |page|
|
|
20
|
+
create(:video, page: page, position: 1)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
factory :text_page do
|
|
25
|
+
after(:create) do |page|
|
|
26
|
+
create(:text, page: page, position: 1)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
factory :image_page do
|
|
31
|
+
after(:create) do |page|
|
|
32
|
+
create(:image, page: page, position: 1)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe "Text block" do
|
|
6
|
+
let(:article) { create(:article) }
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
clean_database
|
|
10
|
+
visit_article
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def visit_article() visit "/admin/articles/#{article.id}/edit"; end
|
|
14
|
+
def add_block() find_link(I18n.t("redditor.add.text_block")).click; end
|
|
15
|
+
def submit() find_button("Submit").click; end
|
|
16
|
+
def save_block() find_link("✔").click; end
|
|
17
|
+
def delete_block() find_link("✘").click; end
|
|
18
|
+
|
|
19
|
+
it "Saves text block to article", type: :feature, js: true do
|
|
20
|
+
add_block
|
|
21
|
+
page.find(".text-block-input").set("test text block")
|
|
22
|
+
submit
|
|
23
|
+
expect(page.find("textarea").value).to eq "test text block"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "Shows validation error if text block content is empty", type: :feature, js: true do
|
|
27
|
+
add_block
|
|
28
|
+
submit
|
|
29
|
+
expect(page.find(".errors")).to have_content "can't be blank"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "Deletes text block", type: :feature, js: true do
|
|
33
|
+
article.page.text_blocks.build(body: "123", position: 1).save
|
|
34
|
+
visit_article
|
|
35
|
+
delete_block
|
|
36
|
+
visit_article
|
|
37
|
+
text_value = begin
|
|
38
|
+
page.find("textarea").value
|
|
39
|
+
rescue
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
expect(text_value).to eq nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "Saves text block to article on save button", type: :feature, js: true do
|
|
46
|
+
add_block
|
|
47
|
+
page.find(".text-block-input").set("test text block")
|
|
48
|
+
save_block
|
|
49
|
+
visit_article
|
|
50
|
+
expect(page.find("textarea").value).to eq "test text block"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe "Video block" do
|
|
6
|
+
let(:article) { create(:article) }
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
clean_database
|
|
10
|
+
visit_article
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def visit_article() visit "/admin/articles/#{article.id}/edit"; end
|
|
14
|
+
def add_block() find_link(I18n.t("redditor.add.video_block")).click; end
|
|
15
|
+
def submit() find_button("Submit").click; end
|
|
16
|
+
def save_block() find_link("✔").click; end
|
|
17
|
+
def delete_block() find_link("✘").click; end
|
|
18
|
+
|
|
19
|
+
it "Saves video block to article", type: :feature, js: true do
|
|
20
|
+
add_block
|
|
21
|
+
page.find(".video-block-input").set("1"*11)
|
|
22
|
+
submit
|
|
23
|
+
expect(page.find("iframe").nil?).to eq false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "Shows validation error if youtube block url is empty or invalid", type: :feature, js: true do
|
|
27
|
+
add_block
|
|
28
|
+
submit
|
|
29
|
+
expect(page.find(".errors")).to have_content "is the wrong length"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "Deletes video block", type: :feature, js: true do
|
|
33
|
+
article.page.video_blocks.build(youtube: "1"*11, position: 1).save
|
|
34
|
+
visit_article
|
|
35
|
+
delete_block
|
|
36
|
+
visit_article
|
|
37
|
+
video_frame = begin
|
|
38
|
+
page.find("iframe")
|
|
39
|
+
rescue
|
|
40
|
+
nil
|
|
41
|
+
end
|
|
42
|
+
expect(video_frame).to eq nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "Saves video block to article on save button", type: :feature, js: true do
|
|
46
|
+
add_block
|
|
47
|
+
page.find(".video-block-input").set("1"*11)
|
|
48
|
+
save_block
|
|
49
|
+
visit_article
|
|
50
|
+
expect(page.find("iframe").nil?).to eq false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Redditor::Generators::ViewsGenerator do
|
|
6
|
+
include GeneratorSpec::TestCase
|
|
7
|
+
destination File.expand_path("../../../tmp", __FILE__)
|
|
8
|
+
|
|
9
|
+
before(:all) do
|
|
10
|
+
prepare_destination
|
|
11
|
+
run_generator
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
after(:all) { FileUtils.rm_rf 'tmp' }
|
|
15
|
+
|
|
16
|
+
it "generates views" do
|
|
17
|
+
assert_directory "app/views/redditor/admin/pages/_content_block.haml"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Article do
|
|
6
|
+
|
|
7
|
+
context "TEXT" do
|
|
8
|
+
let(:article) { create(:text_article) }
|
|
9
|
+
it "have valid number of text blocks from page" do
|
|
10
|
+
expect(article.page.content_blocks.count).to eq 1
|
|
11
|
+
expect(article.page.content_blocks.first.class.name).to eq "Redditor::TextBlock"
|
|
12
|
+
end
|
|
13
|
+
end # context "TEXT"
|
|
14
|
+
|
|
15
|
+
context "SLIDER" do
|
|
16
|
+
let(:article) { create(:slider_article) }
|
|
17
|
+
it "have valid number of slider blocks from page" do
|
|
18
|
+
expect(article.page.content_blocks.count).to eq 1
|
|
19
|
+
expect(article.page.content_blocks.first.images.count).to eq 3
|
|
20
|
+
end
|
|
21
|
+
end # context "SLIDER"
|
|
22
|
+
|
|
23
|
+
context "VIDEO" do
|
|
24
|
+
let(:article) { create(:video_article) }
|
|
25
|
+
it "have valid number of video blocks from page" do
|
|
26
|
+
expect(article.page.content_blocks.count).to eq 1
|
|
27
|
+
expect(article.page.content_blocks.first.class.name).to eq "Redditor::VideoBlock"
|
|
28
|
+
end
|
|
29
|
+
end # context "VIDEO"
|
|
30
|
+
|
|
31
|
+
context "FULL" do
|
|
32
|
+
let(:article) { create(:full_article) }
|
|
33
|
+
it "have valid number of blocks from page" do
|
|
34
|
+
expect(article.page.content_blocks.first.position).to eq 1
|
|
35
|
+
expect(article.page.content_blocks.last.position).to eq 3
|
|
36
|
+
expect(article.page.content_blocks.count).to eq 3
|
|
37
|
+
end
|
|
38
|
+
end # context "VIDEO"
|
|
39
|
+
|
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
|
3
|
+
|
|
4
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
|
5
|
+
require 'rspec/rails'
|
|
6
|
+
require 'rspec/autorun'
|
|
7
|
+
|
|
8
|
+
require 'factory_girl'
|
|
9
|
+
FactoryGirl.find_definitions
|
|
10
|
+
|
|
11
|
+
require 'generator_spec/test_case'
|
|
12
|
+
|
|
13
|
+
require 'capybara/rails'
|
|
14
|
+
require 'capybara/rspec'
|
|
15
|
+
require 'capybara/poltergeist'
|
|
16
|
+
|
|
17
|
+
Capybara.javascript_driver = :poltergeist
|
|
18
|
+
Capybara.default_wait_time = 10
|
|
19
|
+
|
|
20
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
21
|
+
# in spec/support/ and its subdirectories.
|
|
22
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
|
23
|
+
|
|
24
|
+
# Checks for pending migrations before tests are run.
|
|
25
|
+
# If you are not using ActiveRecord, you can remove this line.
|
|
26
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
|
27
|
+
|
|
28
|
+
def clean_database
|
|
29
|
+
Article.find_by_sql("delete from articles; delete from redditor_pages; delete from redditor_slider_blocks; delete from redditor_text_blocks; delete from redditor_video_pages; delete from redditor_images")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
RSpec.configure do |config|
|
|
33
|
+
# ## Mock Framework
|
|
34
|
+
#
|
|
35
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
36
|
+
#
|
|
37
|
+
# config.mock_with :mocha
|
|
38
|
+
# config.mock_with :flexmock
|
|
39
|
+
# config.mock_with :rr
|
|
40
|
+
|
|
41
|
+
config.after(:all) do
|
|
42
|
+
if Rails.env.test?
|
|
43
|
+
FileUtils.rm_rf(Dir["#{Rails.root}/public/uploads"])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
config.include FactoryGirl::Syntax::Methods
|
|
48
|
+
|
|
49
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
50
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
51
|
+
|
|
52
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
53
|
+
# examples within a transaction, remove the following line or assign false
|
|
54
|
+
# instead of true.
|
|
55
|
+
config.use_transactional_fixtures = false
|
|
56
|
+
|
|
57
|
+
# If true, the base class of anonymous controllers will be inferred
|
|
58
|
+
# automatically. This will be the default behavior in future versions of
|
|
59
|
+
# rspec-rails.
|
|
60
|
+
config.infer_base_class_for_anonymous_controllers = false
|
|
61
|
+
|
|
62
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
63
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
64
|
+
# the seed, which is printed after each run.
|
|
65
|
+
# --seed 1234
|
|
66
|
+
config.order = "random"
|
|
67
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "articles/show.html.haml" do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
assign(:article, create(:full_article))
|
|
7
|
+
render template: "articles/show"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "displays redditor text content" do
|
|
11
|
+
expect(rendered.index("text_block") > 0).to eq true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "displays redditor video content" do
|
|
15
|
+
expect(rendered.index("video_block") > 0).to eq true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "displays redditor slider content" do
|
|
19
|
+
expect(rendered.index("slider_block") > 0).to eq true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|