polygallery 0.3.3 → 0.3.4

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: d5677a62369074c87bcb244a40524461ef19e0ff
4
- data.tar.gz: cc56143ab682bc3d307573f4484c0b88e897370a
3
+ metadata.gz: 74d1166bebf3c13f615c587b375d373d4cafde1c
4
+ data.tar.gz: de5dc955a7c4adcc1a21adc0a22ae5b0acfd964f
5
5
  SHA512:
6
- metadata.gz: fa6d708ebf3b9be3852540dd193952016f102e56c88c423735fa770dbfd3c6b6ee52a5d7fc8e718dcfc274427fcea75f7324d6b6e796dd1968a3feef3d877c30
7
- data.tar.gz: c1f82b8cf65bed7f766f1c9db488eae729c21fd25f8bb6ecdc2fecf00f191b49d4542bd95fd08c45005927773c0c18df5fb67eb7f9b107270a0fb42208b81cea
6
+ metadata.gz: a99f2e27857b890a161b0eb7184e2519a37573826691e54658507f7aa0aebbd3e138acb351b071c770f1072cc90ae683b9414315a7fec1764bf0e9e6e1b13808
7
+ data.tar.gz: ce8354f4fdc4cf7e4825c4fd158542f0f55e6f04cf231382f5429c45821092f7445918201f4f0083eeb9095ff10145f2f900a6dd972e5b235fd99762e098961f
@@ -1,20 +1,27 @@
1
1
  require 'polygallery/factories'
2
2
  module Polygallery
3
3
  module CapybaraHelpers
4
+ def polyphoto_tr_selector(table_id='photos')
5
+ ".polygallery-cocoon-table##{table_id} tbody tr" end
6
+ def polyphoto_trs(table_id='photos')
7
+ all polyphoto_tr_selector(table_id) end
4
8
  def select_polyphoto_tr(i=0, table_id='photos')
5
- all(".polygallery-cocoon-table##{table_id} tbody tr").to_a[i] end
9
+ if i.is_a? String
10
+ table_id = i; i = 0 end
11
+ polyphoto_trs(table_id).to_a[i]
12
+ end
13
+ def add_polyphoto_btn_selector(table_id='photos')
14
+ '.add_fields[data-association-insertion-node="#' << table_id <<
15
+ ' .photo-receptacle"]' end
6
16
 
7
- def add_photo_to_form(table_id='photos', attrs=nil)
17
+ def add_polyphoto_to_form(table_id='photos', attrs=nil)
8
18
  unless table_id.is_a? String
9
19
  attrs = table_id; table_id = 'photos' end
10
20
  attrs ||= build :polygallery_photo
11
- tr_selector = ".polygallery-cocoon-table##{table_id} tbody tr"
12
- trs = all(tr_selector); last_tr = trs.last
21
+ trs = polyphoto_trs(table_id); last_tr = trs.last
13
22
  unless trs.length == 1 && last_tr.find('input[id$="_photo"]').value.blank?
14
- page.execute_script <<-SCRIPT
15
- $('.add_fields[data-association-insertion-node="##{table_id} .photo-receptacle"]').click();
16
- SCRIPT
17
- last_tr = all(tr_selector).last
23
+ page.execute_script "$('#{add_polyphoto_btn_selector table_id}').click();"
24
+ last_tr = polyphoto_trs(table_id).last
18
25
  end
19
26
  within last_tr do
20
27
  find('input[id$="_photo"]').set get_random_photo
@@ -23,7 +30,7 @@ module Polygallery
23
30
  end
24
31
  end
25
32
 
26
- def change_photo_in_form(photo_index=0, table_id='photos', file_to_use=nil)
33
+ def change_polyphoto_in_form(photo_index=0, table_id='photos', file_to_use=nil)
27
34
  if photo_index.is_a? File
28
35
  file_to_use = photo_index; photo_index = 0 end
29
36
  if table_id.is_a? File
@@ -31,20 +38,22 @@ module Polygallery
31
38
  if photo_index.is_a? String
32
39
  table_id = photo_index; photo_index = 0 end
33
40
  file_to_use ||= get_random_photo
34
- within select_polyphoto_tr(photo_index, table_id) do |tr|
35
- file_input = find('input[id$="_photo"]')
36
- file_input.set file_to_use
37
- yield(tr) if block_given?
41
+ within select_polyphoto_tr(photo_index, table_id) do
42
+ find('input[id$="_photo"]').set file_to_use
43
+ yield if block_given?
38
44
  end
39
45
  end
40
46
 
41
- def remove_photo_from_form(photo_index=0, table_id='photos')
47
+ def remove_polyphoto_from_form(photo_index=0, table_id='photos')
42
48
  if photo_index.is_a? String
43
49
  table_id = photo_index; photo_index = 0 end
44
- tr_selector = ".polygallery-cocoon-table##{table_id} tbody tr:nth-child(#{photo_index + 1})"
50
+ tr_selector = polyphoto_tr_selector(table_id) + ':visible'
45
51
  page.execute_script <<-SCRIPT
46
- $('#{tr_selector} .remove_fields').click();
52
+ setTimeout(function(){
53
+ $($('#{tr_selector}')[#{photo_index}]).find('.remove_fields').click();
54
+ }, 1);
47
55
  SCRIPT
56
+ sleep 0.005
48
57
  end
49
58
 
50
59
  end
@@ -1,3 +1,3 @@
1
1
  module Polygallery
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polygallery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - MacKinley Smith
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  version: '0'
343
343
  requirements: []
344
344
  rubyforge_project:
345
- rubygems_version: 2.2.2
345
+ rubygems_version: 2.4.8
346
346
  signing_key:
347
347
  specification_version: 4
348
348
  summary: Polymorphic galleries made simple.