thin_man 0.15.8 → 0.15.9

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: 6779a68452e92f36738fed109f92449110a66bcd
4
- data.tar.gz: 0ae8efe05b5928b498d40875dee75aab50eb1e07
3
+ metadata.gz: eb59b80ee372136c2d30ce71712bf3f70cda3432
4
+ data.tar.gz: d4756037bcad8774858773769303360c14bc702c
5
5
  SHA512:
6
- metadata.gz: b4ef51cf77238bdf29cad939d163dfe920bdc85541c27f8711c0e81eba46809e489dd19c64bdd522655026b924a60083e36a9e1b4e24a2b779725fae173510aa
7
- data.tar.gz: aa501036540e2b82d583d8ead1a4ad3c500972e475832e841ddb85c1a4345a07e5856bb3f625b98f6ad1376f25864d1a6a66e4004ecfa3eb2c547732027dbf3f
6
+ metadata.gz: e0f1ccf59e2f46bd89b15cab567ef5d3f8f527f96ca53075639bb35af30b55cf6338ebea55cca01cb106815ed67224aa56bd17f813dfdc81cf9925aa5e1e894c
7
+ data.tar.gz: 73dfdc654606498b54894f3277a9c23deec0d84baefc088d706d84143abaaaf846fcccdffaa50743fa84b91078df0fce1b67ce38207da63b91c3ee3de9c6f850
@@ -263,7 +263,7 @@ var initThinMan = function(){
263
263
  }),
264
264
  AjaxProgress: Class.extend({
265
265
  init: function(target,alt,progress_color){
266
- if(target.length > 0 && target.is(':visible')){
266
+ if(target.length > 0 && target.is(':visible') && target.css('display') != 'inline'){
267
267
  this.progress_target = target;
268
268
  } else if(typeof(alt) != 'undefined' && alt.is(':visible')) {
269
269
  this.progress_target = alt;
@@ -1,6 +1,6 @@
1
1
  module ThinMan
2
2
  module AjaxHelper
3
- def ajax_link(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil)
3
+ def ajax_link(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil)
4
4
  ajax_options = {
5
5
  'data-ajax-link' => true,
6
6
  'data-ajax-target' => target
@@ -11,12 +11,13 @@ module ThinMan
11
11
  ajax_options.merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present?
12
12
  ajax_options.merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present?
13
13
  ajax_options.merge!('data-progress-target' => progress_target) if progress_target.present?
14
+ ajax_options.merge!('data-progress-color' => progress_color) if progress_color.present?
14
15
  link_to(name,
15
16
  options,
16
17
  html_options.merge(ajax_options))
17
18
  end
18
19
 
19
- def ajax_link_now(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, http_method: nil, progress_target: nil)
20
+ def ajax_link_now(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, http_method: nil, progress_target: nil, progress_color: nil)
20
21
  ajax_options = {
21
22
  'data-ajax-link-now' => true,
22
23
  'data-ajax-target' => target
@@ -26,6 +27,7 @@ module ThinMan
26
27
  ajax_options.merge!('data-ajax-method' => http_method) if http_method.present?
27
28
  ajax_options.merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present?
28
29
  ajax_options.merge!('data-progress-target' => progress_target) if progress_target.present?
30
+ ajax_options.merge!('data-progress-color' => progress_color) if progress_color.present?
29
31
  link_to(name,
30
32
  options,
31
33
  html_options.merge(ajax_options))
@@ -46,7 +48,7 @@ module ThinMan
46
48
  html_options.merge(ajax_options))
47
49
  end
48
50
 
49
- def ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, container: nil, custom_progress: nil, no_mouse_click: nil, progress_target: nil)
51
+ def ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, container: nil, custom_progress: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil)
50
52
  ajax_options = {
51
53
  'data-ajax-form' => true,
52
54
  'data-ajax-target' => target
@@ -60,10 +62,11 @@ module ThinMan
60
62
  ajax_options.merge!('data-custom-progress' => custom_progress) if custom_progress.present?
61
63
  ajax_options.merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present?
62
64
  ajax_options.merge!('data-progress-target' => progress_target) if progress_target.present?
65
+ ajax_options.merge!('data-progress-color' => progress_color) if progress_color.present?
63
66
  ajax_options
64
67
  end
65
68
 
66
- def ajax_form_now(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, container: nil, custom_progress: nil, progress_target: nil)
69
+ def ajax_form_now(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, container: nil, custom_progress: nil, progress_target: nil, progress_color: nil)
67
70
  ajax_options = {
68
71
  'data-ajax-form-now' => true,
69
72
  'data-ajax-target' => target
@@ -76,10 +79,11 @@ module ThinMan
76
79
  ajax_options.merge!('data-reset-on-success' => reset_on_success) if reset_on_success.present?
77
80
  ajax_options.merge!('data-custom-progress' => custom_progress) if custom_progress.present?
78
81
  ajax_options.merge!('data-progress-target' => progress_target) if progress_target.present?
82
+ ajax_options.merge!('data-progress-color' => progress_color) if progress_color.present?
79
83
  ajax_options
80
84
  end
81
85
 
82
- def ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, no_mouse_click: nil, progress_target: nil)
86
+ def ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil)
83
87
  data_attrs = "data-ajax-form=true data-ajax-target=#{target}"
84
88
  data_attrs += " data-insert-method=#{insert_method}" if insert_method
85
89
  data_attrs += " data-sub-type=#{sub_class}" if sub_class
@@ -88,10 +92,11 @@ module ThinMan
88
92
  data_attrs += " data-error-target=#{error_target}" if error_target
89
93
  data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click
90
94
  data_attrs += " data-progress-target=#{progress_target}" if progress_target
95
+ data_attrs += " data-progress-color=#{progress_color}" if progress_color
91
96
  data_attrs
92
97
  end
93
98
 
94
- def ajax_form_now_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, progress_target: nil)
99
+ def ajax_form_now_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, progress_target: nil, progress_color: nil)
95
100
  data_attrs = "data-ajax-form-now=true data-ajax-target=#{target}"
96
101
  data_attrs += " data-insert-method=#{insert_method}" if insert_method
97
102
  data_attrs += " data-sub-type=#{sub_class}" if sub_class
@@ -99,10 +104,11 @@ module ThinMan
99
104
  data_attrs += " data-reset-on-success=#{reset_on_success}" if reset_on_success
100
105
  data_attrs += " data-error-target=#{error_target}" if error_target
101
106
  data_attrs += " data-progress-target=#{progress_target}" if progress_target
107
+ data_attrs += " data-progress-color=#{progress_color}" if progress_color
102
108
  data_attrs
103
109
  end
104
110
 
105
- def ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil)
111
+ def ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil)
106
112
  data_attrs = "data-ajax-link=true data-ajax-target=#{target}"
107
113
  data_attrs += " data-insert-method=#{insert_method}" if insert_method
108
114
  data_attrs += " data-ajax-method=#{http_method}" if http_method
@@ -110,6 +116,7 @@ module ThinMan
110
116
  data_attrs += " data-empty-on-success=#{empty_on_success}" if empty_on_success
111
117
  data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click
112
118
  data_attrs += " data-progress-target=#{progress_target}" if progress_target
119
+ data_attrs += " data-progress-color=#{progress_color}" if progress_color
113
120
  data_attrs
114
121
  end
115
122
 
@@ -1,3 +1,3 @@
1
1
  module ThinMan
2
- VERSION = "0.15.8"
2
+ VERSION = "0.15.9"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -2,8 +2,12 @@
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
4
  require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
- ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
6
5
  require "rails/test_help"
6
+ require 'minitest/unit'
7
+ require 'minitest/autorun'
8
+ require 'minitest/spec'
9
+ require 'minitest/pride'
10
+ require 'minitest/rails'
7
11
 
8
12
  Rails.backtrace_cleaner.remove_silencers!
9
13
 
@@ -1,7 +1,70 @@
1
1
  require 'test_helper'
2
2
 
3
- class ThinManTest < ActiveSupport::TestCase
4
- test "truth" do
5
- assert_kind_of Module, ThinMan
3
+ class ThinManTest < ActionView::TestCase
4
+ include ThinMan::AjaxHelper
5
+
6
+ def setup
7
+ @html_options = {class: 'test_class'}
8
+ @target = '#target_element'
9
+ @error_target = '#error_target'
10
+ @insert_method = 'append'
11
+ @empty_on_success = '#empty_me'
12
+ @http_method = 'PATCH'
13
+ @no_mouse_click = true
14
+ @progress_target = '#progress_element'
15
+ @progress_color = 'blue'
16
+
17
+ @replace_response = true
18
+ @no_confirm = true
19
+ @custom_progress = '#custom_progress'
20
+ end
21
+
22
+ it "generates ajax link hash" do
23
+ test_link = ajax_link('test link', "http://test.com", @html_options, @target, insert_method: @insert_method, empty_on_success: @empty_on_success, http_method: @http_method, no_mouse_click: @no_mouse_click, progress_target: @progress_target, progress_color: @progress_color)
24
+ test_link.must_match "data-ajax-link="
25
+ test_link.must_match(/class=.test_class./)
26
+ test_link.must_match "data-ajax-target=\"#{@target}\""
27
+ test_link.must_match "data-insert-method=\"#{@insert_method}\""
28
+ test_link.must_match "data-empty-on-success=\"#{@empty_on_success}\""
29
+ test_link.must_match "data-ajax-method=\"#{@http_method}\""
30
+ test_link.must_match "data-no-mouse-click=\"#{@no_mouse_click}\""
31
+ test_link.must_match "data-progress-target=\"#{@progress_target}\""
32
+ test_link.must_match "data-progress-color=\"#{@progress_color}\""
33
+ end
34
+
35
+ it "generates an instant link" do
36
+ test_link = ajax_link_now('test link', "http://test.com", @html_options, @target, insert_method: @insert_method, empty_on_success: @empty_on_success, http_method: @http_method, progress_target: @progress_target, progress_color: @progress_color)
37
+ test_link.must_match "data-ajax-link-now="
38
+ test_link.must_match(/class=.test_class./)
39
+ test_link.must_match "data-ajax-target=\"#{@target}\""
40
+ test_link.must_match "data-insert-method=\"#{@insert_method}\""
41
+ test_link.must_match "data-empty-on-success=\"#{@empty_on_success}\""
42
+ test_link.must_match "data-ajax-method=\"#{@http_method}\""
43
+ test_link.must_match "data-progress-target=\"#{@progress_target}\""
44
+ test_link.must_match "data-progress-color=\"#{@progress_color}\""
6
45
  end
46
+
47
+ it "generates a delete link" do
48
+ test_link = ajax_delete('test link', "http://test.com", @html_options, @target, replace_response: @replace_response, no_confirm: @no_confirm, custom_progress: @custom_progress, no_mouse_click: @no_mouse_click)
49
+ test_link.must_match "data-ajax-delete="
50
+ test_link.must_match(/class=.test_class./)
51
+ test_link.must_match "data-ajax-target=\"#{@target}\""
52
+ test_link.must_match "data-replace-response=\"#{@replace_response}\""
53
+ test_link.must_match "data-no-confirm=\"#{@no_confirm}\""
54
+ test_link.must_match "data-custom-progress=\"#{@custom_progress}\""
55
+ test_link.must_match "data-no-mouse-click=\"#{@no_mouse_click}\""
56
+ end
57
+
58
+ it "generates ajax form hash" do
59
+ form_hash = ajax_form_hash(@target, error_target: @error_target, insert_method: @insert_method, empty_on_success: @empty_on_success, no_mouse_click: @no_mouse_click, progress_target: @progress_target, progress_color: @progress_color)
60
+ form_hash['data-ajax-form'].must_equal true
61
+ form_hash['data-ajax-target'].must_equal @target
62
+ form_hash['data-error-target'].must_equal @error_target
63
+ form_hash['data-insert-method'].must_equal @insert_method
64
+ form_hash['data-empty-on-success'].must_equal @empty_on_success
65
+ form_hash['data-no-mouse-click'].must_equal @no_mouse_click
66
+ form_hash['data-progress-target'].must_equal @progress_target
67
+ form_hash['data-progress-color'].must_equal @progress_color
68
+ end
69
+
7
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.8
4
+ version: 0.15.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut, Adam Bialek
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '3'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '3'
47
67
  description: 'A Rails library that makes web apps lively while keeping all the logic
48
68
  on the server. '
49
69
  email: