curation_concerns 1.0.0.beta4 → 1.0.0.beta5

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/app/assets/stylesheets/curation_concerns/modules/forms.scss +16 -2
  4. data/app/controllers/concerns/curation_concerns/catalog_controller.rb +0 -5
  5. data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +0 -5
  6. data/app/helpers/curation_concerns/main_app_helpers.rb +1 -0
  7. data/app/helpers/curation_concerns/permissions_helper.rb +2 -4
  8. data/app/helpers/curation_concerns/rights_helper.rb +9 -0
  9. data/app/inputs/multi_value_select_input.rb +45 -0
  10. data/app/models/concerns/curation_concerns/collection.rb +0 -1
  11. data/app/presenters/curation_concerns/file_set_presenter.rb +4 -4
  12. data/app/presenters/curation_concerns/presents_attributes.rb +28 -2
  13. data/app/presenters/curation_concerns/work_show_presenter.rb +1 -8
  14. data/app/renderers/curation_concerns/renderers/attribute_renderer.rb +2 -33
  15. data/app/renderers/curation_concerns/renderers/faceted_attribute_renderer.rb +19 -0
  16. data/app/renderers/curation_concerns/renderers/linked_attribute_renderer.rb +20 -0
  17. data/app/renderers/curation_concerns/renderers/rights_attribute_renderer.rb +27 -0
  18. data/app/services/curation_concerns/actors/actor_factory.rb +1 -2
  19. data/app/services/rights_service.rb +11 -1
  20. data/app/views/curation_concerns/base/_attribute_rows.html.erb +3 -3
  21. data/app/views/curation_concerns/base/_attributes.html.erb +1 -1
  22. data/app/views/curation_concerns/base/_form_permission.html.erb +1 -1
  23. data/app/views/curation_concerns/base/_form_rights.html.erb +4 -2
  24. data/app/views/records/edit_fields/_default.html.erb +1 -1
  25. data/config/locales/curation_concerns.en.yml +2 -0
  26. data/curation_concerns.gemspec +1 -1
  27. data/lib/curation_concerns/configuration.rb +0 -1
  28. data/lib/curation_concerns/version.rb +1 -1
  29. data/lib/generators/curation_concerns/install_generator.rb +6 -3
  30. data/lib/generators/curation_concerns/templates/config/initializers/simple_form.rb +170 -0
  31. data/lib/generators/curation_concerns/templates/config/initializers/simple_form_bootstrap.rb +150 -0
  32. data/spec/inputs/multi_value_with_help_input_spec.rb +0 -15
  33. data/spec/presenters/curation_concerns/file_set_presenter_spec.rb +15 -1
  34. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +0 -11
  35. data/spec/renderers/curation_concerns/renderers/faceted_attribute_renderer_spec.rb +21 -0
  36. data/spec/renderers/curation_concerns/renderers/linked_attribute_renderer_spec.rb +21 -0
  37. data/spec/renderers/curation_concerns/renderers/rights_attribute_renderer_spec.rb +21 -0
  38. data/spec/services/rights_service_spec.rb +9 -3
  39. data/spec/views/curation_concerns/base/_form_rights_spec.rb +41 -0
  40. data/spec/views/curation_concerns/base/file_manager.html.erb_spec.rb +1 -1
  41. metadata +19 -20
  42. data/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb +0 -28
  43. data/app/actors/curation_concerns/actors/assign_identifier_actor.rb +0 -9
  44. data/app/actors/curation_concerns/actors/work_actor_behavior.rb +0 -12
  45. data/app/inputs/multi_value_with_help_input.rb +0 -8
  46. data/app/inputs/select_with_help_input.rb +0 -3
  47. data/app/inputs/select_with_modal_help_input.rb +0 -36
  48. data/app/inputs/with_help_icon.rb +0 -34
  49. data/app/search_builders/curation_concerns/search_builder.rb +0 -10
  50. data/spec/helpers/curation_concerns/permissions_helper_spec.rb +0 -12
  51. data/spec/inputs/select_with_help_input_spec.rb +0 -43
  52. data/spec/inputs/select_with_modal_help_input_spec.rb +0 -21
  53. data/spec/search_builders/curation_concerns/search_builder_spec.rb +0 -53
@@ -0,0 +1,170 @@
1
+ # NOTE: This is a modified version of simple_form's default config file.
2
+ # The only changes were to move the input to after the hint and error.
3
+
4
+ # Use this setup block to configure all options available in SimpleForm.
5
+ SimpleForm.setup do |config|
6
+ # Wrappers are used by the form builder to generate a
7
+ # complete input. You can remove any component from the
8
+ # wrapper, change the order or even add your own to the
9
+ # stack. The options given below are used to wrap the
10
+ # whole input.
11
+ config.wrappers :default, class: :input,
12
+ hint_class: :field_with_hint,
13
+ error_class: :field_with_errors do |b|
14
+ ## Extensions enabled by default
15
+ # Any of these extensions can be disabled for a
16
+ # given input by passing: `f.input EXTENSION_NAME => false`.
17
+ # You can make any of these extensions optional by
18
+ # renaming `b.use` to `b.optional`.
19
+
20
+ # Determines whether to use HTML5 (:email, :url, ...)
21
+ # and required attributes
22
+ b.use :html5
23
+
24
+ # Calculates placeholders automatically from I18n
25
+ # You can also pass a string as f.input placeholder: "Placeholder"
26
+ b.use :placeholder
27
+
28
+ ## Optional extensions
29
+ # They are disabled unless you pass `f.input EXTENSION_NAME => true`
30
+ # to the input. If so, they will retrieve the values from the model
31
+ # if any exists. If you want to enable any of those
32
+ # extensions by default, you can change `b.optional` to `b.use`.
33
+
34
+ # Calculates maxlength from length validations for string inputs
35
+ b.optional :maxlength
36
+
37
+ # Calculates pattern from format validations for string inputs
38
+ b.optional :pattern
39
+
40
+ # Calculates min and max from length validations for numeric inputs
41
+ b.optional :min_max
42
+
43
+ # Calculates readonly automatically from readonly attributes
44
+ b.optional :readonly
45
+
46
+ ## Inputs
47
+ b.use :label
48
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
49
+ b.use :error, wrap_with: { tag: :span, class: :error }
50
+ b.use :input
51
+
52
+ ## full_messages_for
53
+ # If you want to display the full error message for the attribute, you can
54
+ # use the component :full_error, like:
55
+ #
56
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
57
+ end
58
+
59
+ # The default wrapper to be used by the FormBuilder.
60
+ config.default_wrapper = :default
61
+
62
+ # Define the way to render check boxes / radio buttons with labels.
63
+ # Defaults to :nested for bootstrap config.
64
+ # inline: input + label
65
+ # nested: label > input
66
+ config.boolean_style = :nested
67
+
68
+ # Default class for buttons
69
+ config.button_class = 'btn'
70
+
71
+ # Method used to tidy up errors. Specify any Rails Array method.
72
+ # :first lists the first message for each field.
73
+ # Use :to_sentence to list all errors for each field.
74
+ # config.error_method = :first
75
+
76
+ # Default tag used for error notification helper.
77
+ config.error_notification_tag = :div
78
+
79
+ # CSS class to add for error notification helper.
80
+ config.error_notification_class = 'error_notification'
81
+
82
+ # ID to add for error notification helper.
83
+ # config.error_notification_id = nil
84
+
85
+ # Series of attempts to detect a default label method for collection.
86
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
87
+
88
+ # Series of attempts to detect a default value method for collection.
89
+ # config.collection_value_methods = [ :id, :to_s ]
90
+
91
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
92
+ # config.collection_wrapper_tag = nil
93
+
94
+ # You can define the class to use on all collection wrappers. Defaulting to none.
95
+ # config.collection_wrapper_class = nil
96
+
97
+ # You can wrap each item in a collection of radio/check boxes with a tag,
98
+ # defaulting to :span.
99
+ # config.item_wrapper_tag = :span
100
+
101
+ # You can define a class to use in all item wrappers. Defaulting to none.
102
+ # config.item_wrapper_class = nil
103
+
104
+ # How the label text should be generated altogether with the required text.
105
+ config.label_text = ->(label, required, _) { "#{label} #{required}" }
106
+
107
+ # You can define the class to use on all labels. Default is nil.
108
+ # config.label_class = nil
109
+
110
+ # You can define the default class to be used on forms. Can be overriden
111
+ # with `html: { :class }`. Defaulting to none.
112
+ # config.default_form_class = nil
113
+
114
+ # You can define which elements should obtain additional classes
115
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
116
+
117
+ # Whether attributes are required by default (or not). Default is true.
118
+ # config.required_by_default = true
119
+
120
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
121
+ # These validations are enabled in SimpleForm's internal config but disabled by default
122
+ # in this configuration, which is recommended due to some quirks from different browsers.
123
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
124
+ # change this configuration to true.
125
+ config.browser_validations = false
126
+
127
+ # Collection of methods to detect if a file type was given.
128
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
129
+
130
+ # Custom mappings for input types. This should be a hash containing a regexp
131
+ # to match as key, and the input type that will be used when the field name
132
+ # matches the regexp as value.
133
+ # config.input_mappings = { /count/ => :integer }
134
+
135
+ # Custom wrappers for input types. This should be a hash containing an input
136
+ # type as key and the wrapper that will be used for all inputs with specified type.
137
+ # config.wrapper_mappings = { string: :prepend }
138
+
139
+ # Namespaces where SimpleForm should look for custom input classes that
140
+ # override default inputs.
141
+ # config.custom_inputs_namespaces << "CustomInputs"
142
+
143
+ # Default priority for time_zone inputs.
144
+ # config.time_zone_priority = nil
145
+
146
+ # Default priority for country inputs.
147
+ # config.country_priority = nil
148
+
149
+ # When false, do not use translations for labels.
150
+ # config.translate_labels = true
151
+
152
+ # Automatically discover new inputs in Rails' autoload path.
153
+ # config.inputs_discovery = true
154
+
155
+ # Cache SimpleForm inputs discovery
156
+ # config.cache_discovery = !Rails.env.development?
157
+
158
+ # Default class for inputs
159
+ # config.input_class = nil
160
+
161
+ # Define the default class of the input wrapper of the boolean input.
162
+ config.boolean_label_class = 'checkbox'
163
+
164
+ # Defines if the default input wrapper class should be included in radio
165
+ # collection wrappers.
166
+ # config.include_default_input_wrapper_class = true
167
+
168
+ # Defines which i18n scope will be used in Simple Form.
169
+ # config.i18n_scope = 'simple_form'
170
+ end
@@ -0,0 +1,150 @@
1
+ # NOTE: This is a modified version of simple_form's default config file.
2
+ # The only changes were to move the inputs to after the hints and errors.
3
+
4
+ # Use this setup block to configure all options available in SimpleForm.
5
+
6
+ SimpleForm.setup do |config|
7
+ config.error_notification_class = 'alert alert-danger'
8
+ config.button_class = 'btn btn-default'
9
+ config.boolean_label_class = nil
10
+
11
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
12
+ b.use :html5
13
+ b.use :placeholder
14
+ b.optional :maxlength
15
+ b.optional :pattern
16
+ b.optional :min_max
17
+ b.optional :readonly
18
+ b.use :label, class: 'control-label'
19
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
20
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
21
+ b.use :input, class: 'form-control'
22
+ end
23
+
24
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
25
+ b.use :html5
26
+ b.use :placeholder
27
+ b.optional :maxlength
28
+ b.optional :readonly
29
+ b.use :label, class: 'control-label'
30
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
31
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
32
+ b.use :input
33
+ end
34
+
35
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
36
+ b.use :html5
37
+ b.optional :readonly
38
+
39
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
40
+ ba.use :label_input
41
+ end
42
+
43
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
44
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
45
+ end
46
+
47
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
48
+ b.use :html5
49
+ b.optional :readonly
50
+ b.use :label, class: 'control-label'
51
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
52
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
53
+ b.use :input
54
+ end
55
+
56
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
57
+ b.use :html5
58
+ b.use :placeholder
59
+ b.optional :maxlength
60
+ b.optional :pattern
61
+ b.optional :min_max
62
+ b.optional :readonly
63
+ b.use :label, class: 'col-sm-3 control-label'
64
+
65
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
66
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
67
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
68
+ ba.use :input, class: 'form-control'
69
+ end
70
+ end
71
+
72
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
73
+ b.use :html5
74
+ b.use :placeholder
75
+ b.optional :maxlength
76
+ b.optional :readonly
77
+ b.use :label, class: 'col-sm-3 control-label'
78
+
79
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
80
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
81
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
82
+ ba.use :input
83
+ end
84
+ end
85
+
86
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
87
+ b.use :html5
88
+ b.optional :readonly
89
+
90
+ b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
91
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
92
+ ba.use :label_input
93
+ end
94
+
95
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
96
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
97
+ end
98
+ end
99
+
100
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
101
+ b.use :html5
102
+ b.optional :readonly
103
+
104
+ b.use :label, class: 'col-sm-3 control-label'
105
+
106
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
107
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
108
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
109
+ ba.use :input
110
+ end
111
+ end
112
+
113
+ config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
114
+ b.use :html5
115
+ b.use :placeholder
116
+ b.optional :maxlength
117
+ b.optional :pattern
118
+ b.optional :min_max
119
+ b.optional :readonly
120
+ b.use :label, class: 'sr-only'
121
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
122
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
123
+ b.use :input, class: 'form-control'
124
+ end
125
+
126
+ config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
127
+ b.use :html5
128
+ b.optional :readonly
129
+ b.use :label, class: 'control-label'
130
+ b.wrapper tag: 'div', class: 'form-inline' do |ba|
131
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
132
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
133
+ ba.use :input, class: 'form-control'
134
+ end
135
+ end
136
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
137
+ # Check the Bootstrap docs (http://getbootstrap.com)
138
+ # to learn about the different styles for forms and inputs,
139
+ # buttons and other elements.
140
+ config.default_wrapper = :vertical_form
141
+ config.wrapper_mappings = {
142
+ check_boxes: :vertical_radio_and_checkboxes,
143
+ radio_buttons: :vertical_radio_and_checkboxes,
144
+ file: :vertical_file_input,
145
+ boolean: :vertical_boolean,
146
+ datetime: :multi_select,
147
+ date: :multi_select,
148
+ time: :multi_select
149
+ }
150
+ end
@@ -13,20 +13,5 @@ describe 'MultiValueWithHelpInput', type: :input do
13
13
  'The language of the file content.'
14
14
  )
15
15
  end
16
-
17
- it 'renders help icon' do
18
- expect(subject).to have_selector('a[data-toggle=popover][data-original-title=Language]')
19
- expect(subject).to have_selector('a[data-toggle=popover][data-content="The language of the file content."]')
20
- expect(subject).to have_selector('i.help-icon')
21
- end
22
- end
23
-
24
- context "when the field doesn't have a translation" do
25
- let(:field) { :date_modified }
26
- it 'renders help icon' do
27
- expect(subject).to have_selector('a[data-toggle=popover][data-original-title="Date modified"]')
28
- expect(subject).to have_selector('a[data-toggle=popover][data-content="Date modified"]')
29
- expect(subject).to have_selector('i.help-icon')
30
- end
31
16
  end
32
17
  end
@@ -4,8 +4,9 @@ describe CurationConcerns::FileSetPresenter do
4
4
  let(:solr_document) { SolrDocument.new("title_tesim" => ["foo bar"],
5
5
  "human_readable_type_tesim" => ["File Set"],
6
6
  "mime_type_ssi" => 'image/jpeg',
7
+ 'label_tesim' => ['one', 'two'],
7
8
  "has_model_ssim" => ["FileSet"]) }
8
- let(:ability) { nil }
9
+ let(:ability) { double }
9
10
  let(:presenter) { described_class.new(solr_document, ability) }
10
11
 
11
12
  describe "#to_s" do
@@ -63,4 +64,17 @@ describe CurationConcerns::FileSetPresenter do
63
64
  expect(presenter.fetch("has_model_ssim")).to eq ["FileSet"]
64
65
  end
65
66
  end
67
+
68
+ describe "#link_name" do
69
+ subject { presenter.link_name }
70
+ context "when it's readable" do
71
+ before { allow(ability).to receive(:can?).and_return(true) }
72
+ it { is_expected.to eq 'one' }
73
+ end
74
+
75
+ context "when it's not readable" do
76
+ before { allow(ability).to receive(:can?).and_return(false) }
77
+ it { is_expected.to eq 'File' }
78
+ end
79
+ end
66
80
  end
@@ -51,17 +51,6 @@ describe CurationConcerns::WorkShowPresenter do
51
51
  end
52
52
  end
53
53
 
54
- describe "#file_presenters" do
55
- let(:obj) { create(:work_with_ordered_files) }
56
- let(:attributes) { obj.to_solr }
57
-
58
- it "displays them in order" do
59
- expect(obj.ordered_member_ids).not_to eq obj.member_ids
60
- expect(Deprecation).to receive(:warn)
61
- expect(presenter.file_presenters.map(&:id)).to eq obj.ordered_member_ids
62
- end
63
- end
64
-
65
54
  describe "#work_presenters" do
66
55
  let(:obj) { create(:work_with_file_and_work) }
67
56
  let(:attributes) { obj.to_solr }
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurationConcerns::Renderers::FacetedAttributeRenderer do
4
+ let(:field) { :name }
5
+ let(:renderer) { described_class.new(field, ['Bob', 'Jessica']) }
6
+
7
+ describe "#attribute_to_html" do
8
+ subject { Nokogiri::HTML(renderer.render) }
9
+ let(:expected) { Nokogiri::HTML(tr_content) }
10
+
11
+ let(:tr_content) {%(
12
+ <tr><th>Name</th>
13
+ <td><ul class='tabular'>
14
+ <li class="attribute name"><a href="/catalog?f%5Bname_sim%5D%5B%5D=Bob">Bob</a></li>
15
+ <li class="attribute name"><a href="/catalog?f%5Bname_sim%5D%5B%5D=Jessica">Jessica</a></li>
16
+ </ul></td></tr>
17
+ )}
18
+ it { expect(renderer).not_to be_microdata(field) }
19
+ it { expect(subject).to be_equivalent_to(expected) }
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurationConcerns::Renderers::LinkedAttributeRenderer do
4
+ let(:field) { :name }
5
+ let(:renderer) { described_class.new(field, ['Bob', 'Jessica']) }
6
+
7
+ describe "#attribute_to_html" do
8
+ subject { Nokogiri::HTML(renderer.render) }
9
+ let(:expected) { Nokogiri::HTML(tr_content) }
10
+
11
+ let(:tr_content) {
12
+ "<tr><th>Name</th>\n" \
13
+ "<td><ul class='tabular'>" \
14
+ "<li class=\"attribute name\"><a href=\"/catalog?q=Bob&amp;search_field=name\">Bob</a></li>\n" \
15
+ "<li class=\"attribute name\"><a href=\"/catalog?q=Jessica&amp;search_field=name\">Jessica</a></li>\n" \
16
+ "</ul></td></tr>"
17
+ }
18
+ it { expect(renderer).not_to be_microdata(field) }
19
+ it { expect(subject).to be_equivalent_to(expected) }
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurationConcerns::Renderers::RightsAttributeRenderer do
4
+ let(:field) { :rights }
5
+ let(:renderer) { described_class.new(field, ['http://creativecommons.org/licenses/by/3.0/us/', 'http://creativecommons.org/licenses/by-nd/3.0/us/']) }
6
+
7
+ describe "#attribute_to_html" do
8
+ subject { Nokogiri::HTML(renderer.render) }
9
+ let(:expected) { Nokogiri::HTML(tr_content) }
10
+
11
+ let(:tr_content) {
12
+ "<tr><th>Rights</th>\n" \
13
+ "<td><ul class='tabular'>\n" \
14
+ "<li class=\"attribute rights\"><a href=\"http://creativecommons.org/licenses/by/3.0/us/\" target=\"_blank\">Attribution 3.0 United States</a></li>\n" \
15
+ "<li class=\"attribute rights\"><a href=\"http://creativecommons.org/licenses/by-nd/3.0/us/\" target=\"_blank\">Attribution-NoDerivs 3.0 United States</a></li>\n" \
16
+ "</ul></td></tr>"
17
+ }
18
+ it { expect(renderer).not_to be_microdata(field) }
19
+ it { expect(subject).to be_equivalent_to(expected) }
20
+ end
21
+ end
@@ -7,13 +7,19 @@ describe RightsService do
7
7
  stub_const("Qa::Authorities::LocalSubauthority::AUTHORITIES_CONFIG", qa_fixtures)
8
8
  end
9
9
 
10
- describe "#select_options" do
10
+ describe "#select_active_options" do
11
11
  it "returns active terms" do
12
- expect(described_class.select_options).to include(["First Active Term", "demo_id_01"], ["Second Active Term", "demo_id_02"])
12
+ expect(described_class.select_active_options).to include(["First Active Term", "demo_id_01"], ["Second Active Term", "demo_id_02"])
13
13
  end
14
14
 
15
15
  it "does not return inactive terms" do
16
- expect(described_class.select_options).not_to include(["Third is an Inactive Term", "demo_id_03"], ["Fourth is an Inactive Term", "demo_id_04"])
16
+ expect(described_class.select_active_options).not_to include(["Third is an Inactive Term", "demo_id_03"], ["Fourth is an Inactive Term", "demo_id_04"])
17
+ end
18
+ end
19
+
20
+ describe "#select_all_options" do
21
+ it "returns both active and inactive terms" do
22
+ expect(described_class.select_all_options).to include(["Fourth is an Inactive Term", "demo_id_04"], ["First Active Term", "demo_id_01"])
17
23
  end
18
24
  end
19
25
 
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'curation_concerns/base/_form_rights.html.erb' do
4
+ let(:curation_concern) { GenericWork.new }
5
+ let(:form) { CurationConcerns::Forms::WorkForm.new(curation_concern, nil) }
6
+ let(:form_template) do
7
+ %(
8
+ <%= simple_form_for [main_app, @form] do |f| %>
9
+ <%= render "curation_concerns/base/form_rights", f: f, curation_concern: curation_concern %>
10
+ <% end %>
11
+ )
12
+ end
13
+
14
+ before do
15
+ qa_fixtures = { local_path: File.expand_path('../../../../fixtures/authorities', __FILE__) }
16
+ stub_const("Qa::Authorities::LocalSubauthority::AUTHORITIES_CONFIG", qa_fixtures)
17
+ end
18
+
19
+ context "when active and inactive rights are associated with a work" do
20
+ before do
21
+ curation_concern.rights = ['demo_id_01', 'demo_id_04']
22
+ assign(:form, form)
23
+ render inline: form_template, locals: { curation_concern: curation_concern }
24
+ end
25
+
26
+ it 'will only include active values if the current value is active' do
27
+ expect(rendered).not_to have_xpath('//div/ul/li[1]/select/option[@value="demo_id_04"]')
28
+ expect(rendered).not_to have_xpath('//div/ul/li[1]/select/option[text()="Fourth is an Inactive Term"]')
29
+ end
30
+
31
+ it 'will always include the current value as an option' do
32
+ expect(rendered).to have_xpath('//div/ul/li[2]/select/option[@value="demo_id_04" and @selected="selected"]')
33
+ expect(rendered).to have_xpath('//div/ul/li[2]/select/option[text()="Fourth is an Inactive Term"]')
34
+ end
35
+
36
+ it 'only offers active values to add to a work' do
37
+ expect(rendered).not_to have_xpath('//div/ul/li[3]/select/option[@value="demo_id_04"]')
38
+ expect(rendered).not_to have_xpath('//div/ul/li[3]/select/option[text()="Fourth is an Inactive Term"]')
39
+ end
40
+ end
41
+ end
@@ -9,7 +9,7 @@ RSpec.describe "curation_concerns/base/file_manager.html.erb" do
9
9
  id: "test",
10
10
  title_tesim: "Test",
11
11
  thumbnail_path_ss: "/test/image/path.jpg",
12
- label_tesim: "file_name.tif"
12
+ label_tesim: ["file_name.tif"]
13
13
  )
14
14
  )
15
15
  end