clark_kent 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/clark_kent/reports_controller.rb +0 -1
  3. data/app/views/clark_kent/report_filters/_form.html.erb +9 -10
  4. data/app/views/clark_kent/report_filters/_index.html.erb +1 -1
  5. data/app/views/clark_kent/reports/_edit.html.erb +7 -12
  6. data/app/views/clark_kent/reports/_object_filter.html.erb +6 -1
  7. data/lib/clark_kent/version.rb +1 -1
  8. data/test/controllers/clark_kent/reports_controller_test.rb +60 -60
  9. data/test/dummy/db/test.sqlite3 +0 -0
  10. data/test/dummy/log/test.log +6927 -0
  11. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-tbw_tK_xY7S5MbnQdpN44EzoLlr38dGccFJ9OTbxnY.cache +1 -0
  12. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0q3992U6xCfifmQYOI2Waqp6QQGyBbcM3j7Nhtl4HU8.cache +0 -0
  13. data/test/dummy/tmp/cache/assets/sprockets/v3.0/14hBuzKo8VFDSI9U23qPSCtOvb-djpSYfndvECpitV8.cache +0 -0
  14. data/test/dummy/tmp/cache/assets/sprockets/v3.0/2P91XnWme5n0yEMC8-AwmASu9jAZ5VMPDVwfZmPAhcs.cache +0 -0
  15. data/test/dummy/tmp/cache/assets/sprockets/v3.0/2ZXmQy6WZeji8LMCJLbMjGK1VJbkNRF2lC7MAI07cvc.cache +1 -0
  16. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5k7OtUEslUWi1MkCA5Kmc7rHAU0hWPFaSUcq7j8-doc.cache +1 -0
  17. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6e3-8lJQHaB2tpaemkQBoG8j1IXYd2T7R0hxB6RUry0.cache +1 -0
  18. data/test/dummy/tmp/cache/assets/sprockets/v3.0/BOXckJswXOmYIFOmyN_i44U-bY_U4-c-kE1Gk-rPlA8.cache +1 -0
  19. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Br0JlF7EfKjFrhWBfcqOj-sdtnNCHJLRFqPNY1mM5l0.cache +1 -0
  20. data/test/dummy/tmp/cache/assets/sprockets/v3.0/GSlw-mT--yR76-3Q9MUh6AOvIB8p5JRCbOYnb5bDyzI.cache +1 -0
  21. data/test/dummy/tmp/cache/assets/sprockets/v3.0/H0ZpixREXT2i1zQ82nkmYZzok2oXmJ5Z0tYH21Ag6hg.cache +0 -0
  22. data/test/dummy/tmp/cache/assets/sprockets/v3.0/HuyKNAYEnPs4OFAHZ6YQZ3VSrTaxZe0Ra_fNZLbeXDw.cache +1 -0
  23. data/test/dummy/tmp/cache/assets/sprockets/v3.0/I20Hfwlj9bANRe97xPjNWAbtnTWBWhiAlPdMO_j0ktM.cache +0 -0
  24. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JbcAACpMmVlknG104wCtLY73aNeelGB5NNPiF4uDf5s.cache +0 -0
  25. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Kn1tegghiey48SiIH6w4tiWY3Prk58yzxzlhdEWvjrk.cache +0 -0
  26. data/test/dummy/tmp/cache/assets/sprockets/v3.0/NSNaeVG8YOVpuk6ZXd-Wgb3KIbu7rwVKMVH_L17X7bA.cache +0 -0
  27. data/test/dummy/tmp/cache/assets/sprockets/v3.0/O8akbUwAbmIKY-AhITimq-JDQ6IgsO3Hvq2v5etufFw.cache +0 -0
  28. data/test/dummy/tmp/cache/assets/sprockets/v3.0/QFhmcCsJ5yFlk5v0gmM51ZDiTZV92igXtiScIngdFMk.cache +1 -0
  29. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SP99tSgcYiJIx2KM12C0FnnXucDnvQ53-Z2aJFro-PU.cache +0 -0
  30. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SnU3WeG9WD2u9ObM6eJPhNVI-AR0kTW9EjvVtdsmBYU.cache +0 -0
  31. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TKNXein9fms2hyVGgBUTpbFU4IzJrA4H2uVv1TvRy8s.cache +1 -0
  32. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UGBHtggSaDhQVXh82S85XGM4XLPrNcA9oGk5imyLQso.cache +1 -0
  33. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UVeH93rELRBawlPCnRGGJP4tRFjy_dH7wicU_ZbrCDM.cache +1 -0
  34. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UwMFS8rJmeOVTOPUAsy5rBsPqe-mwJgvTSCg-8xwSK8.cache +0 -0
  35. data/test/dummy/tmp/cache/assets/sprockets/v3.0/X1pDD1_Im8Jyti817p7q6enVK8MjNPsLCoZ_c8hG2fs.cache +1 -0
  36. data/test/dummy/tmp/cache/assets/sprockets/v3.0/XGAUd4zdycHNjgugiwtNoIzH7Rye3BmjHFqOL3pkrhg.cache +0 -0
  37. data/test/dummy/tmp/cache/assets/sprockets/v3.0/XtN1zYSzj7nMrKARGZJk3aBoAkOvTRo2e2mfBW4jB6o.cache +0 -0
  38. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZZG2BX3ZNKeB05plv8lIMy-z0yF_KnHRwVS-uMtpcrE.cache +1 -0
  39. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Zo-Gv5yCgWm4ckuzHH4U1SjFs_tYPZVWEGXpoBgZeYU.cache +1 -0
  40. data/test/dummy/tmp/cache/assets/sprockets/v3.0/bR-gDb8oK48ZYrZSIeamJnm4H0noAKvPys1zAPml46I.cache +1 -0
  41. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c0fZzpmetAbdlEG8jam5O6N3N3wiVzKXR_lCIY6kCTA.cache +0 -0
  42. data/test/dummy/tmp/cache/assets/sprockets/v3.0/cwN5IE5m4V3MoUFZd0am5HQjaHydW8ySLOSbOwc4ChY.cache +0 -0
  43. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dKk5D4vEs4pKkbGWK8CqDojCmwIkp_WDwK4-4Ejmtoo.cache +1 -0
  44. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dwXsOetUlrT7c2kTk4ADNmZoNvC5otpVOxTNLw_EVVM.cache +1 -0
  45. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +0 -0
  46. data/test/dummy/tmp/cache/assets/sprockets/v3.0/i2JEwS23sj58zy4o0tjAF4yI2VN9AexaUB0DIWcaiTw.cache +0 -0
  47. data/test/dummy/tmp/cache/assets/sprockets/v3.0/kBovyixgNRk3E-gAuk5uGtcVaFQK9QrI0eDTLbFiB9c.cache +1 -0
  48. data/test/dummy/tmp/cache/assets/sprockets/v3.0/kXxL0BxZJ_YjZc12TBmBBynUmAr_07HvO_ZvDNfPBFE.cache +1 -0
  49. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mXL70cyqA-IuZlTlRDqoP_QDPgxcUNIvHjrE9-nkF0k.cache +0 -0
  50. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nQh7J8iLgW3j3-evMg5iclK6Ph4j4agDPZbAb2D1cpY.cache +0 -0
  51. data/test/dummy/tmp/cache/assets/sprockets/v3.0/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +0 -0
  52. data/test/dummy/tmp/cache/assets/sprockets/v3.0/oqA7W6o9dYAG75KmI0M7fPUKSEn3B8qAGD5mL9R7FT8.cache +0 -0
  53. data/test/dummy/tmp/cache/assets/sprockets/v3.0/qDTX9x3gssugNMYBtUCEPsx25Z7T_Vi76vbJyG6w5jg.cache +1 -0
  54. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tFi4IIk7HxeTEe8QM0tfFxtvthId0aM6b83iqEjJAoc.cache +0 -0
  55. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tPF6H9NRpGO3whu2y5_e_R_1EACKdCwu5437D83qJT0.cache +0 -0
  56. data/test/dummy/tmp/cache/assets/sprockets/v3.0/wWEACjGoHremcmCG6pA981DR6b1PCvGKfvJuJbYIqBQ.cache +0 -0
  57. data/test/dummy/tmp/cache/assets/sprockets/v3.0/x1pNHYQUCVLQm2-2eBri2T7gxgLTBDez3d7ao8etFX4.cache +0 -0
  58. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yEHhEsjQv9j3w1E8HZSLNeJ3FwxVJY02gIUVtdy9sQ4.cache +0 -0
  59. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/4XCNdiFuH04rCo6S1nqBL9ewrpO2zFV__aEi0rIj3tk.cache +0 -0
  60. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/5q2RKsPFL6nGwx70pB_BqYVk2biW-zxcH8U4HK4cclc.cache +1 -0
  61. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/6Jx9bePjgMCpzSNagH6CMdVcPZs_a_fGaH_ODy5FXVM.cache +0 -0
  62. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/830T8v1iYB_MYNYM0TOBxkqJUxJhJpOg-ybmh6WZHuU.cache +1 -0
  63. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/BmDBpZkHnavjNvo6F7veRtRRJYx6LfTUNRzVKxS9_HA.cache +1 -0
  64. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/JbcAACpMmVlknG104wCtLY73aNeelGB5NNPiF4uDf5s.cache +0 -0
  65. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/LyQKDrCggYRGSzI0x_bvkklFwP5t6oKF77Fc1Goj-vg.cache +0 -0
  66. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/O8akbUwAbmIKY-AhITimq-JDQ6IgsO3Hvq2v5etufFw.cache +0 -0
  67. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/UwMFS8rJmeOVTOPUAsy5rBsPqe-mwJgvTSCg-8xwSK8.cache +0 -0
  68. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/dETjTCSXBJ7R-3H56WOm5CaSL0tq0iP-qh6aSGc66LA.cache +1 -0
  69. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/eyfMBGFry1DCxGIX2jD2W0xNF6ORKmhqrvTFBPg3Zbg.cache +0 -0
  70. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/frkYnjqyWlbodavhpEyN-n1SbGE7OB70b1w-npVXgq8.cache +0 -0
  71. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +0 -0
  72. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/jEP_ROSBHw39QJaHs3MRMowIkvLxr6G4ju-ZdAWuvIk.cache +1 -0
  73. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/kT5Z2_-XVYh5NDVcPTTWAGqkB0jWV8iXNlLPYAeD8u8.cache +1 -0
  74. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/nHxflTtD4WOiUHeWPi9XRXpbZ91URARDShhAvVjvxG8.cache +0 -0
  75. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +0 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/tPF6H9NRpGO3whu2y5_e_R_1EACKdCwu5437D83qJT0.cache +0 -0
  77. data/test/test_helper.rb +4 -5
  78. metadata +194 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1602aef2a067c09bd335e26d9e81044e7aab0d9e
4
- data.tar.gz: 86c09aa7f1519452e5eb73c9e898ce16a616cf8b
3
+ metadata.gz: 946b82a5e471b450c9c62dd81a3bfeee3b00dda8
4
+ data.tar.gz: 17d1d6d74996eff40d562da68ca0c70db7d442ca
5
5
  SHA512:
6
- metadata.gz: 5a07ab29841ddfbd24bcba27e3f89bc95c906123768c090fe2250f2b7c40635f7bf4658877d826d7d8ff19ba295c80cadecd90e9dca095f58f9ae7cfa4718e6c
7
- data.tar.gz: c1b02256030c39ee13716f5c3b3457dc6e9fa97bd45f7124fbf206a3f7613d2fba1508d940b888c6637503a2de26714b1772726f18d6b80ae1e7336487b6859a
6
+ metadata.gz: 4677bcc4135ee9f7f17b86e645b3fce7cd43a597490632449ed9ccb0177ddfedda804985e3e11df08fb7027c8fb4ecfa50fb3897db33b6d0184b2b1662b3885f
7
+ data.tar.gz: cdb0ad4ec67d5296f3c2d4d5a3890df1896f4c2cfd6c58d93ba4ba696157446e1004d5cf2b323d49685d18e7434c34529997d0e21e07d20f54d8fa025832d7a0
@@ -1,6 +1,5 @@
1
1
  class ClarkKent::ReportsController < ClarkKent::ApplicationController
2
2
  require 'csv'
3
- respond_to :html, :csv
4
3
  before_filter :get_these_params, :prepare_filters
5
4
 
6
5
  def set_manage_tab
@@ -14,19 +14,16 @@
14
14
  sub_type: "AddALineForm",
15
15
  ajax_target: report_filter.new_record? ? "#report_filter_list_#{dom_id(report_filter.filterable)}" : "#report_filter_#{report_filter.id}",
16
16
  insert_method: report_filter.new_record? ? 'append' : 'html',
17
- container: "#new_report_filter_container_#{dom_id(report_filter.filterable)}",
17
+ container: dom_target(report_filter.filterable, :new_report_filter_container),
18
18
  ajax_flash: true } } do |f| %>
19
19
  <div class="ih-span one-third">
20
20
  <%= f.input :filterable_id, as: :hidden %>
21
21
  <%= f.input :filterable_type, as: :hidden %>
22
22
  <% if report_filter.new_record? %>
23
23
  <%= f.input :filter_name, collection: report_filter.filterable.available_filter_options,
24
- input_html: {
25
- data: {
26
- revealer: 'true',
27
- sub_type: 'FormFieldRevealer',
28
- revealer_children_id: "filter_value_options_#{report_filter.object_id}" },
29
- id: "report_filter_filter_name_#{report_filter.object_id}"},
24
+ input_html:
25
+ revealer("filter_value_options_#{report_filter.object_id}", highlander: true).merge(
26
+ id: "report_filter_filter_name_#{report_filter.object_id}"),
30
27
  include_blank: false %>
31
28
  <% else %>
32
29
  <div class="ih-row quiet">Filter Name</div>
@@ -34,9 +31,9 @@
34
31
  <% end %>
35
32
  </div>
36
33
  <% if report_filter.new_record? %>
37
- <div class="ih-span one-third" data-revealer-target="filter_value_options_<%= report_filter.object_id %>">
34
+ <div class="ih-span one-third" <%= revealer_target_attrs("filter_value_options_#{report_filter.object_id}") %>>
38
35
  <% report_filter.filterable.available_filters.each do |name,label| %>
39
- <div data-revealer_id="filter_value_options_<%= report_filter.object_id %>" data-revealer-trigger="<%= name %>" id="filter_value_options_<%= name %>">
36
+ <div <%= revealer_option_attrs("filter_value_options_#{report_filter.object_id}", trigger: name) %> id="filter_value_options_<%= name %>">
40
37
  <%= render partial: report_filter.filterable.filter_kind(name) + '_edit', locals: {f: f, report_filter: report_filter, name: name} %>
41
38
  </div>
42
39
  <% end %>
@@ -48,7 +45,9 @@
48
45
  <% end %>
49
46
  <div class="ih-span right margin-top">
50
47
  <%= f.button :submit %>
51
- <% unless report_filter.new_record? %>
48
+ <% if report_filter.new_record? %>
49
+ &nbsp; <a <%= emptier dom_target(report_filter.filterable, :new_report_filter_container) %>> cancel </a>
50
+ <% else %>
52
51
  &nbsp; <%= link_to 'cancel', report_filter_url(report_filter),
53
52
  data: {ajax_link: "true", ajax_target: "#report_filter_#{report_filter.id}"} %>
54
53
  &nbsp; <%= link_to '&otimes;'.html_safe, report_filter_url(report_filter), class: "delete", data: {ajax_delete: "true", ajax_target: "#report_filter_#{report_filter.id}" }, tabindex: "-1" %>
@@ -10,7 +10,7 @@
10
10
  <%= link_to 'Add a Filter', new_report_filter_url(filterable_id: filterable.id, filterable_type: filterable.class.name), class: 'btn btn-primary', data: {ajax_link: "true", ajax_target: "#new_report_filter_container_#{dom_id(filterable)}" } %>
11
11
  </div>
12
12
 
13
- <div id="new_report_filter_container_<%= dom_id(filterable) %>" class="ih-row margin-top">
13
+ <div id="<%= dom_id filterable, :new_report_filter_container %>" class="ih-row margin-top">
14
14
 
15
15
  </div>
16
16
  </div>
@@ -1,9 +1,5 @@
1
1
  <div class="ih-row">
2
- <%= simple_form_for @report, html: @report.persisted? ? {
3
- data: {
4
- ajax_form: true,
5
- ajax_target: '#report_info_container' }
6
- } : {} do |f| %>
2
+ <%= simple_form_for @report, html: @report.persisted? ? ajax_form_hash( '#report_info_container' ) : {} do |f| %>
7
3
  <div class="ih-span one-quarter">
8
4
  <%= f.input :name %>
9
5
  </div>
@@ -17,21 +13,21 @@
17
13
  <div class="ih-row">sharing</div>
18
14
  <div class="ih-row">
19
15
  <%= f.input :sharing_scope_type, collection: ClarkKent::SharingScopeKind.select_options_for_user(current_user),
20
- input_html: {data: {revealer: true, sub_type: "FormFieldRevealer", revealer_children_id: "sharing_options"}},
16
+ input_html: revealer("sharing_options", highlander: true),
21
17
  label: false, include_blank: false %>
22
18
  </div>
23
- <div class="ih-row" data-revealer-target="sharing_options">
24
- <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: current_user.id}, wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => ClarkKent.user_class_name, id: "sharing_options_#{ClarkKent.user_class_name}"} %>
19
+ <div class="ih-row" <%= revealer_target_attrs("sharing_options") %>>
20
+ <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: current_user.id}, wrapper_html: revealer_option("sharing_options", trigger: ClarkKent.user_class_name).merge(id: "sharing_options_#{ClarkKent.user_class_name}") %>
25
21
  <% ClarkKent::SharingScopeKind.custom_for_user(current_user).each do |sharing_scope_kind| %>
26
22
  <% if sharing_scope_kind.associated_containers_for(current_user).respond_to? :each %>
27
23
  <%= f.input :sharing_scope_id, collection: sharing_scope_kind.associated_containers_for(current_user), label: false, include_blank: false,
28
- wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => sharing_scope_kind.class_name, id: "sharing_options_#{sharing_scope_kind.class_name}"} %>
24
+ wrapper_html: revealer_option("sharing_options", trigger: sharing_scope_kind.class_name).merge(id: "sharing_options_#{sharing_scope_kind.class_name}") %>
29
25
  <% else %>
30
- <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: sharing_scope_kind.associated_containers_for(current_user).id}, wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => sharing_scope_kind.associated_containers_for(current_user).class.name, id: "sharing_options_#{sharing_scope_kind.associated_containers_for(current_user).class.name}"} %>
26
+ <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: sharing_scope_kind.associated_containers_for(current_user).id}, wrapper_html: revealer_option("sharing_options", trigger: sharing_scope_kind.associated_containers_for(current_user).class.name).merge(id: "sharing_options_#{sharing_scope_kind.associated_containers_for(current_user).class.name}") %>
31
27
  <% end %>
32
28
  <% end %>
33
29
  <%= f.input :sharing_scope_id, as: :hidden, input_html: {value: ''},
34
- wrapper_html: {'data-revealer_id' => "sharing_options", 'data-revealer-trigger' => "", id: "sharing_options_"} %>
30
+ wrapper_html: revealer_option("sharing_options", trigger: "").merge(id: "sharing_options_") %>
35
31
  </div>
36
32
  </div>
37
33
  <div class="ih-span one-quarter margin-top right">
@@ -39,7 +35,6 @@
39
35
  <%= f.button :submit %>
40
36
  <% unless @report.new_record? %>
41
37
  &nbsp; <%= ajax_link 'cancel', report_url(@report), {class: 'right'}, "#report_info_container" %>
42
- }
43
38
  </div>
44
39
  <div class="ih-row right">or</div>
45
40
  <div class="ih-row">
@@ -3,7 +3,12 @@
3
3
  <%= filter.param.humanize %>
4
4
  </div>
5
5
  <div class="ih-row">
6
- <% options = @filter_collections.send(filter.collection) %>
6
+ <% options = case filter.collection.class.name
7
+ when 'String', 'Symbol'
8
+ @filter_collections.send(filter.collection)
9
+ when 'Array'
10
+ filter.collection
11
+ end %>
7
12
  <%= select_tag filter.param,
8
13
  options_from_collection_for_select(
9
14
  options,
@@ -1,3 +1,3 @@
1
1
  module ClarkKent
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -1,75 +1,75 @@
1
1
  require 'test_helper'
2
2
 
3
- module ClarkKent
4
- class ReportsControllerTest < ActionController::TestCase
5
- setup do
6
- @report = ClarkKent::Report.first
7
- @routes = Engine.routes
8
- @current_user = User.first
9
- end
3
+ describe ClarkKent::ReportsController do
4
+ setup do
5
+ @routes = ClarkKent::Engine.routes
6
+ end
10
7
 
11
- test "should get index" do
12
- get :index, current_user_id: @current_user.id
13
- assert_response :success
14
- end
8
+ before do
9
+ @report = ClarkKent::Report.first
10
+ @current_user = User.first
11
+ end
15
12
 
16
- test "should get new" do
17
- get :new, current_user_id: @current_user.id
18
- assert_response :success
19
- end
13
+ test "should get index" do
14
+ get :index, current_user_id: @current_user.id
15
+ assert_response :success
16
+ end
20
17
 
21
- test "should create report" do
22
- assert_difference('Report.count') do
23
- post :create,
24
- report: {
25
- name: 'delete me', resource_type: @report.resource_type,
26
- sharing_scope_id: @report.sharing_scope_id, sharing_scope_type: @report.sharing_scope_type },
27
- current_user_id: @current_user.id
28
- end
29
- report = Report.find_by(name: 'delete me')
30
- report.destroy
31
- assert_response :success
32
- end
18
+ test "should get new" do
19
+ get :new, current_user_id: @current_user.id
20
+ assert_response :success
21
+ end
33
22
 
34
- test "should show report" do
35
- get :show, id: @report, current_user_id: @current_user.id
36
- assert_response :success
37
- end
23
+ test "should create report" do
24
+ post :create,
25
+ report: {
26
+ name: 'delete me', resource_type: @report.resource_type,
27
+ sharing_scope_id: @report.sharing_scope_id, sharing_scope_type: @report.sharing_scope_type },
28
+ current_user_id: @current_user.id
29
+ report = ClarkKent::Report.find_by(name: 'delete me')
30
+ report.wont_be_nil
31
+ report.destroy
32
+ assert_response :success
33
+ end
38
34
 
39
- test "should show report results" do
40
- get :show, id: @report, current_user_id: @current_user.id, run_report: true, created_at_until: Date.today, created_at_from: Date.yesterday
41
- assert_response :success
42
- assert_not_nil assigns(:rows)
43
- @response.body.must_match 'Guitar strings'
44
- end
35
+ test "should show report" do
36
+ get :show, id: @report, current_user_id: @current_user.id
37
+ assert_response :success
38
+ end
45
39
 
46
- test "should show report run errors" do
47
- get :show, id: @report, current_user_id: @current_user.id, run_report: true
48
- assert_response :success
49
- @response.body.must_match 'At least one date range is required.'
50
- end
40
+ test "should show report results" do
41
+ get :show, id: @report, current_user_id: @current_user.id, run_report: true, created_at_until: Date.today, created_at_from: Date.yesterday
42
+ assert_response :success
43
+ assert_not_nil assigns(:rows)
44
+ @response.body.must_match 'Guitar strings'
45
+ end
51
46
 
52
- test "should get edit" do
53
- get :edit, id: @report, current_user_id: @current_user.id
54
- assert_response :success
55
- end
47
+ test "should show report run errors" do
48
+ get :show, id: @report, current_user_id: @current_user.id, run_report: true
49
+ assert_response :success
50
+ @response.body.must_match 'At least one date range is required.'
51
+ end
56
52
 
57
- test "should update report" do
58
- patch :update, id: @report,
59
- report: {
60
- name: @report.name, resource_type: @report.resource_type,
61
- sharing_scope_id: @report.sharing_scope_id, sharing_scope_type: @report.sharing_scope_type },
62
- current_user_id: @current_user.id
63
- assert_response :success
64
- end
53
+ test "should get edit" do
54
+ get :edit, id: @report, current_user_id: @current_user.id
55
+ assert_response :success
56
+ end
65
57
 
66
- test "should destroy report" do
67
- report = Report.create(name: 'delete me', resource_type: 'Order')
68
- assert_difference('Report.count', -1) do
69
- delete :destroy, id: report, current_user_id: @current_user.id
70
- end
58
+ test "should update report" do
59
+ patch :update, id: @report,
60
+ report: {
61
+ name: @report.name, resource_type: @report.resource_type,
62
+ sharing_scope_id: @report.sharing_scope_id, sharing_scope_type: @report.sharing_scope_type },
63
+ current_user_id: @current_user.id
64
+ assert_response :success
65
+ end
71
66
 
72
- assert_redirected_to reports_path
67
+ test "should destroy report" do
68
+ report = ClarkKent::Report.create(name: 'delete me', resource_type: 'Order')
69
+ assert_difference('ClarkKent::Report.count', -1) do
70
+ delete :destroy, id: report, current_user_id: @current_user.id
73
71
  end
72
+
73
+ assert_redirected_to reports_path
74
74
  end
75
75
  end
Binary file