refinerycms-page-images 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +20 -9
- data/Gemfile +22 -51
- data/Rakefile +2 -0
- data/app/assets/javascripts/refinery/page-image-picker.js.erb +173 -150
- data/app/assets/stylesheets/refinery/page-image-picker.css.scss +6 -0
- data/app/views/refinery/admin/pages/tabs/_images.html.erb +2 -1
- data/app/views/refinery/admin/pages/tabs/_images_field.html.erb +15 -3
- data/config/locales/bg.yml +1 -0
- data/config/locales/cs.yml +1 -0
- data/config/locales/de.yml +3 -1
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +19 -0
- data/config/locales/fr.yml +1 -0
- data/config/locales/ja.yml +18 -0
- data/config/locales/nl.yml +1 -0
- data/config/locales/pt-BR.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/lib/generators/refinery/templates/config/initializers/refinery/page_images.rb.erb +2 -0
- data/lib/refinery/page_images.rb +15 -2
- data/lib/refinery/page_images/configuration.rb +25 -1
- data/lib/refinery/page_images/engine.rb +17 -19
- data/lib/refinery/page_images/extension.rb +2 -2
- data/readme.md +48 -2
- data/refinerycms-page-images.gemspec +7 -8
- data/spec/factories/page-images.rb +2 -2
- data/spec/features/attach_page_images_spec.rb +58 -0
- data/spec/lib/refinery/initializer_spec.rb +42 -0
- data/spec/models/refinery/blog_spec.rb +3 -3
- data/spec/models/refinery/page_spec.rb +26 -16
- data/spec/spec_helper.rb +21 -46
- metadata +43 -82
- data/spec/requests/attach_page_images_spec.rb +0 -29
- data/spec/support/database_cleaner.rb +0 -17
- data/spec/support/devise.rb +0 -8
- data/spec/support/refinery.rb +0 -6
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "attach page images" do
|
4
|
+
refinery_login_with :refinery_user
|
5
|
+
|
6
|
+
# No-op block : use default configuration by default
|
7
|
+
let(:configure) {}
|
8
|
+
let(:create_page) { FactoryGirl.create(:page) }
|
9
|
+
let(:navigate_to_edit) { click_link "Edit this page" }
|
10
|
+
let(:page_images_tab_id) { "#custom_#{::I18n.t(:'refinery.plugins.refinery_page_images.tab_name')}_tab" }
|
11
|
+
|
12
|
+
let(:setup_and_visit) do
|
13
|
+
configure
|
14
|
+
create_page
|
15
|
+
visit refinery.admin_pages_path
|
16
|
+
navigate_to_edit
|
17
|
+
end
|
18
|
+
|
19
|
+
it "shows images tab" do
|
20
|
+
setup_and_visit
|
21
|
+
within page_images_tab_id do
|
22
|
+
page.should have_content("Images")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# This spec actually is broken in a way because Add Image link would
|
27
|
+
# be visible to capybara even if we don't click on Images tab.
|
28
|
+
it "shows add image link" do
|
29
|
+
setup_and_visit
|
30
|
+
within page_images_tab_id do
|
31
|
+
click_link "Images"
|
32
|
+
end
|
33
|
+
|
34
|
+
page.should have_content("Add Image")
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with caption and WYSIWYG disabled" do
|
38
|
+
let(:configure) do
|
39
|
+
Refinery::PageImages.config.wysiwyg = false
|
40
|
+
Refinery::PageImages.config.captions = true
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:create_page) { FactoryGirl.create(:page_with_image) }
|
44
|
+
let(:navigate_to_edit) { page.find('a[tooltip="Edit this page"]').click }
|
45
|
+
|
46
|
+
it "shows a plain textarea when editing caption", js: true do
|
47
|
+
setup_and_visit
|
48
|
+
page.find("#{page_images_tab_id} a").click
|
49
|
+
image_li_tag = page.find("#page_images li:first-child")
|
50
|
+
|
51
|
+
image_li_tag.hover
|
52
|
+
within(image_li_tag) { page.find('img.caption').click }
|
53
|
+
|
54
|
+
page.find('.ui-dialog textarea').should be_visible
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Refinery::PageImages::Engine do
|
4
|
+
before(:all) do
|
5
|
+
class Refinery::PageImages::EnableForMock
|
6
|
+
class Model; end
|
7
|
+
class Tab; end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
Refinery::PageImages.instance_eval { remove_const(:EnableForMock) }
|
13
|
+
end
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
Refinery::PageImages.config.stub(:enable_for).and_return(enable_for_config)
|
17
|
+
end
|
18
|
+
|
19
|
+
def enable_for_config
|
20
|
+
[{ :model => 'Refinery::PageImages::EnableForMock::Model',
|
21
|
+
:tab => 'Refinery::PageImages::EnableForMock::Tab' }]
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "attach initializer" do
|
25
|
+
it "calls attach on all configured model" do
|
26
|
+
Refinery::PageImages.config.stub(:enable_for).and_return(enable_for_config)
|
27
|
+
|
28
|
+
Refinery::PageImages::EnableForMock::Model.should_receive(:has_many_page_images).once
|
29
|
+
Refinery::Page.should_not_receive(:has_many_page_images)
|
30
|
+
ActionDispatch::Reloader.prepare!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "attach_initialize_tabs!" do
|
35
|
+
it "registers tabs for all configured engine" do
|
36
|
+
Refinery::PageImages::EnableForMock::Tab.should_receive(:register).once
|
37
|
+
Refinery::Pages::Tab.should_not_receive(:register)
|
38
|
+
Refinery::PageImages::Engine.initialize_tabs!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
module Refinery
|
4
4
|
describe BlogPost do
|
5
5
|
it "should not have images" do
|
6
|
-
blog =
|
6
|
+
blog = FactoryGirl.create(:blog_post)
|
7
7
|
blog.images.count.should == 0
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should have images" do
|
11
|
-
blog =
|
11
|
+
blog = FactoryGirl.create(:blog_post_with_image)
|
12
12
|
blog.images.count.should == 1
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
15
15
|
end if defined?(Refinery::Blog::Post)
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
module Refinery
|
4
4
|
describe Page do
|
5
5
|
it "can have images added" do
|
6
|
-
page =
|
6
|
+
page = FactoryGirl.create(:page)
|
7
7
|
page.images.count.should eq(0)
|
8
8
|
|
9
|
-
page.images <<
|
9
|
+
page.images << FactoryGirl.create(:image)
|
10
10
|
page.images.count.should eq(1)
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#images_attributes=" do
|
14
14
|
it "adds images" do
|
15
|
-
page =
|
16
|
-
image =
|
15
|
+
page = FactoryGirl.create(:page)
|
16
|
+
image = FactoryGirl.create(:image)
|
17
17
|
|
18
18
|
page.images.count.should == 0
|
19
19
|
page.update_attributes({:images_attributes => {"0" => {"id" => image.id}}})
|
@@ -22,14 +22,17 @@ module Refinery
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "deletes specific images" do
|
25
|
-
page =
|
26
|
-
images = [
|
25
|
+
page = FactoryGirl.create(:page)
|
26
|
+
images = [FactoryGirl.create(:image), FactoryGirl.create(:image)]
|
27
27
|
page.images = images
|
28
28
|
|
29
|
+
page_image_to_keep = page.image_pages.find do |image_page|
|
30
|
+
image_page.image_id == images.first.id
|
31
|
+
end
|
29
32
|
page.update_attributes(:images_attributes => {
|
30
33
|
"0" => {
|
31
|
-
"id" =>
|
32
|
-
"image_page_id" =>
|
34
|
+
"id" => page_image_to_keep.image_id.to_s,
|
35
|
+
"image_page_id" => page_image_to_keep.id
|
33
36
|
},
|
34
37
|
})
|
35
38
|
|
@@ -37,8 +40,8 @@ module Refinery
|
|
37
40
|
end
|
38
41
|
|
39
42
|
it "deletes all images" do
|
40
|
-
page =
|
41
|
-
images = [
|
43
|
+
page = FactoryGirl.create(:page)
|
44
|
+
images = [FactoryGirl.create(:image), FactoryGirl.create(:image)]
|
42
45
|
page.images = images
|
43
46
|
|
44
47
|
page.update_attributes(:images_attributes => {"0" => {"id"=>""}})
|
@@ -47,18 +50,25 @@ module Refinery
|
|
47
50
|
end
|
48
51
|
|
49
52
|
it "reorders images" do
|
50
|
-
page =
|
51
|
-
images = [
|
53
|
+
page = FactoryGirl.create(:page)
|
54
|
+
images = [FactoryGirl.create(:image), FactoryGirl.create(:image)]
|
52
55
|
page.images = images
|
53
56
|
|
57
|
+
first_page_image = page.image_pages.find do |image_page|
|
58
|
+
image_page.image_id == images.first.id
|
59
|
+
end
|
60
|
+
second_page_image = page.image_pages.find do |image_page|
|
61
|
+
image_page.image_id == images.second.id
|
62
|
+
end
|
63
|
+
|
54
64
|
page.update_attributes(:images_attributes => {
|
55
65
|
"0" => {
|
56
|
-
"id" =>
|
57
|
-
"image_page_id" =>
|
66
|
+
"id" => second_page_image.image_id,
|
67
|
+
"image_page_id" => second_page_image.id,
|
58
68
|
},
|
59
69
|
"1" => {
|
60
|
-
"id" =>
|
61
|
-
"image_page_id" =>
|
70
|
+
"id" => first_page_image.image_id,
|
71
|
+
"image_page_id" => first_page_image.id,
|
62
72
|
},
|
63
73
|
})
|
64
74
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,56 +1,31 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
# Configure Rails Environment
|
4
|
+
ENV["RAILS_ENV"] ||= 'test'
|
6
5
|
|
7
|
-
|
6
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
require 'rspec/rails'
|
9
|
+
require 'capybara/rspec'
|
10
|
+
require 'factory_girl_rails'
|
12
11
|
|
13
|
-
|
12
|
+
Rails.backtrace_cleaner.remove_silencers!
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
# set javascript driver for capybara
|
23
|
-
Capybara.javascript_driver = :selenium
|
24
|
-
end
|
25
|
-
|
26
|
-
def each_run
|
27
|
-
ActiveSupport::Dependencies.clear
|
28
|
-
|
29
|
-
FactoryGirl.reload
|
30
|
-
|
31
|
-
# Requires supporting files with custom matchers and macros, etc,
|
32
|
-
# in ./support/ and its subdirectories including factories.
|
33
|
-
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
|
34
|
-
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
35
|
-
}.flatten.sort.each do |support_file|
|
36
|
-
require support_file
|
37
|
-
end
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.mock_with :rspec
|
16
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
17
|
+
config.filter_run :focus => true
|
18
|
+
config.run_all_when_everything_filtered = true
|
38
19
|
end
|
39
20
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
# Loading more in this block will cause your tests to run faster. However,
|
44
|
-
# if you change any configuration or code from libraries loaded here, you'll
|
45
|
-
# need to restart spork for it take effect.
|
46
|
-
setup_environment
|
47
|
-
end
|
21
|
+
# set javascript driver for capybara
|
22
|
+
require 'capybara/poltergeist'
|
23
|
+
Capybara.javascript_driver = :poltergeist
|
48
24
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
each_run
|
25
|
+
# Requires supporting files with custom matchers and macros, etc,
|
26
|
+
# in ./support/ and its subdirectories including factories.
|
27
|
+
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
|
28
|
+
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
29
|
+
}.flatten.sort.each do |support_file|
|
30
|
+
require support_file
|
56
31
|
end
|
metadata
CHANGED
@@ -1,64 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-page-images
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 2.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Philip Arndt
|
14
8
|
- David Jones
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: refinerycms-pages
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
27
18
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 0
|
34
|
-
version: 2.0.0
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.1.0
|
35
21
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: refinerycms-testing
|
39
22
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
requirements:
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
43
25
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
- 0
|
49
|
-
- 0
|
50
|
-
version: 2.0.0
|
51
|
-
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
description: Page Images Engine for Refinery CMS
|
54
|
-
email: dave@resolvedigital.com
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.1.0
|
28
|
+
description: Attach images to pages ins Refinery CMS
|
29
|
+
email: info@refinerycms.com
|
55
30
|
executables: []
|
56
|
-
|
57
31
|
extensions: []
|
58
|
-
|
59
32
|
extra_rdoc_files: []
|
60
|
-
|
61
|
-
files:
|
33
|
+
files:
|
62
34
|
- .gitignore
|
63
35
|
- .travis.yml
|
64
36
|
- Gemfile
|
@@ -73,7 +45,9 @@ files:
|
|
73
45
|
- config/locales/cs.yml
|
74
46
|
- config/locales/de.yml
|
75
47
|
- config/locales/en.yml
|
48
|
+
- config/locales/es.yml
|
76
49
|
- config/locales/fr.yml
|
50
|
+
- config/locales/ja.yml
|
77
51
|
- config/locales/nl.yml
|
78
52
|
- config/locales/pt-BR.yml
|
79
53
|
- config/locales/ru.yml
|
@@ -93,54 +67,41 @@ files:
|
|
93
67
|
- refinerycms-page-images.gemspec
|
94
68
|
- script/rails
|
95
69
|
- spec/factories/page-images.rb
|
70
|
+
- spec/features/attach_page_images_spec.rb
|
71
|
+
- spec/lib/refinery/initializer_spec.rb
|
96
72
|
- spec/models/refinery/blog_spec.rb
|
97
73
|
- spec/models/refinery/page_spec.rb
|
98
|
-
- spec/requests/attach_page_images_spec.rb
|
99
74
|
- spec/spec_helper.rb
|
100
|
-
- spec/support/database_cleaner.rb
|
101
|
-
- spec/support/devise.rb
|
102
|
-
- spec/support/refinery.rb
|
103
75
|
- tasks/rspec.rake
|
104
|
-
homepage: http://github.com/
|
105
|
-
licenses:
|
106
|
-
|
76
|
+
homepage: http://github.com/refinery/refinerycms-page-images
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
107
80
|
post_install_message:
|
108
81
|
rdoc_options: []
|
109
|
-
|
110
|
-
require_paths:
|
82
|
+
require_paths:
|
111
83
|
- lib
|
112
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
none: false
|
123
|
-
requirements:
|
124
|
-
- - ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
hash: 3
|
127
|
-
segments:
|
128
|
-
- 0
|
129
|
-
version: "0"
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
130
94
|
requirements: []
|
131
|
-
|
132
95
|
rubyforge_project:
|
133
|
-
rubygems_version:
|
96
|
+
rubygems_version: 2.0.6
|
134
97
|
signing_key:
|
135
|
-
specification_version:
|
136
|
-
summary: Page Images
|
137
|
-
test_files:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Page Images extension for Refinery CMS
|
100
|
+
test_files:
|
138
101
|
- spec/factories/page-images.rb
|
102
|
+
- spec/features/attach_page_images_spec.rb
|
103
|
+
- spec/lib/refinery/initializer_spec.rb
|
139
104
|
- spec/models/refinery/blog_spec.rb
|
140
105
|
- spec/models/refinery/page_spec.rb
|
141
|
-
- spec/requests/attach_page_images_spec.rb
|
142
106
|
- spec/spec_helper.rb
|
143
|
-
- spec/support/database_cleaner.rb
|
144
|
-
- spec/support/devise.rb
|
145
|
-
- spec/support/refinery.rb
|
146
107
|
has_rdoc:
|