sufia 4.3.1 → 5.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -1
- data/Gemfile +10 -1
- data/History.md +14 -0
- data/LICENSE +15 -0
- data/README.md +7 -3
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia.js +17 -1
- data/app/assets/javascripts/sufia/batch_edit.js +28 -43
- data/app/assets/javascripts/sufia/edit_metadata.js +14 -9
- data/app/assets/javascripts/sufia/manage_repeating_fields.js +74 -0
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/assets/stylesheets/sufia/_batch-edit.scss +8 -0
- data/app/assets/stylesheets/sufia/_file-listing.scss +1 -1
- data/app/assets/stylesheets/sufia/_multi_value_fields.css.scss +67 -0
- data/app/controllers/concerns/sufia/breadcrumbs.rb +8 -3
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +5 -1
- data/app/helpers/generic_file_helper.rb +0 -9
- data/app/helpers/sufia/records_helper_behavior.rb +0 -14
- data/app/inputs/multi_value_input.rb +84 -0
- data/app/views/batch/_metadata.html.erb +4 -16
- data/app/views/batch/edit.html.erb +1 -1
- data/app/views/batch_edits/edit.html.erb +6 -10
- data/app/views/collections/_edit_descriptions.html.erb +1 -1
- data/app/views/collections/_form.html.erb +3 -3
- data/app/views/generic_files/_descriptions.html.erb +9 -7
- data/app/views/generic_files/_field_form.html.erb +23 -8
- data/app/views/generic_files/edit.html.erb +0 -1
- data/app/views/records/_edit_field.html.erb +19 -17
- data/app/views/records/_rights_modal.html.erb +1 -0
- data/app/views/records/edit_fields/_default.html.erb +12 -6
- data/app/views/records/edit_fields/_description.html.erb +3 -6
- data/app/views/records/edit_fields/_resource_type.html.erb +5 -4
- data/app/views/records/edit_fields/_rights.html.erb +2 -5
- data/app/views/records/edit_fields/_suffix.html.erb +0 -11
- data/app/views/records/edit_fields/_type.html.erb +2 -8
- data/config/initializers/simple_form.rb +167 -0
- data/config/initializers/simple_form_bootstrap.rb +137 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/locales/sufia.en.yml +2 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/batch_edits_controller_spec.rb +1 -0
- data/spec/controllers/generic_files_controller_spec.rb +26 -0
- data/spec/controllers/users_controller_spec.rb +4 -3
- data/spec/features/collection_spec.rb +7 -0
- data/spec/helpers/records_helper_spec.rb +0 -13
- data/spec/lib/sufia/breadcrumbs_spec.rb +46 -8
- data/spec/views/collections/_form.html.erb_spec.rb +0 -2
- data/sufia-models/app/models/concerns/sufia/user.rb +5 -0
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +9 -5
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia.gemspec +1 -0
- metadata +29 -9
- data/LICENSE.md +0 -14
- data/app/assets/javascripts/sufia/multiForm.js +0 -67
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
<div>
|
3
|
-
|
4
|
-
|
1
|
+
<div class='multi_value'>
|
2
|
+
<div class='listing'>
|
3
|
+
<%= f.input :resource_type, required: required, collection: Sufia.config.resource_types, input_html: { multiple: 'multiple', size: '7', class: 'form-control' } %>
|
4
|
+
<p class="help-block">You may select multiple types to apply <%= help_icon(:resource_type) %><p>
|
5
|
+
</div>
|
5
6
|
</div>
|
@@ -1,5 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<%= render partial: "records/edit_fields/suffix", locals: { key: key, index: index } %>
|
4
|
-
</div>
|
5
|
-
<div id="additional_<%= key %>_elements"></div>
|
1
|
+
<%= f.input :rights, as: :multi_value, required: required, collection: Sufia.config.cc_licenses, include_blank: true, input_html: { type: 'select', include_blank: true, selected: :blank, class: 'select optional form-control' } %>
|
2
|
+
<%= render partial: 'records/rights_modal' %>
|
@@ -1,8 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<p class="help-block">You may select multiple types to apply<p>
|
4
|
-
<%= f.select :resource_type, options_for_select(Sufia.config.resource_types.keys), {},
|
5
|
-
{multiple: true, size: 7} %>
|
6
|
-
<%= help_icon(:resource_type) %>
|
7
|
-
</div>
|
8
|
-
|
1
|
+
<% required = render_req && record.required?(key) %>
|
2
|
+
<%= render partial: "records/edit_fields/resource_type", locals: { record: record, f: f, required: required, key: key } %>
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'simple_form'
|
2
|
+
# Use this setup block to configure all options available in SimpleForm.
|
3
|
+
SimpleForm.setup do |config|
|
4
|
+
# Wrappers are used by the form builder to generate a
|
5
|
+
# complete input. You can remove any component from the
|
6
|
+
# wrapper, change the order or even add your own to the
|
7
|
+
# stack. The options given below are used to wrap the
|
8
|
+
# whole input.
|
9
|
+
config.wrappers :default, class: :input,
|
10
|
+
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
11
|
+
## Extensions enabled by default
|
12
|
+
# Any of these extensions can be disabled for a
|
13
|
+
# given input by passing: `f.input EXTENSION_NAME => false`.
|
14
|
+
# You can make any of these extensions optional by
|
15
|
+
# renaming `b.use` to `b.optional`.
|
16
|
+
|
17
|
+
# Determines whether to use HTML5 (:email, :url, ...)
|
18
|
+
# and required attributes
|
19
|
+
b.use :html5
|
20
|
+
|
21
|
+
# Calculates placeholders automatically from I18n
|
22
|
+
# You can also pass a string as f.input placeholder: "Placeholder"
|
23
|
+
b.use :placeholder
|
24
|
+
|
25
|
+
## Optional extensions
|
26
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
27
|
+
# to the input. If so, they will retrieve the values from the model
|
28
|
+
# if any exists. If you want to enable any of those
|
29
|
+
# extensions by default, you can change `b.optional` to `b.use`.
|
30
|
+
|
31
|
+
# Calculates maxlength from length validations for string inputs
|
32
|
+
b.optional :maxlength
|
33
|
+
|
34
|
+
# Calculates pattern from format validations for string inputs
|
35
|
+
b.optional :pattern
|
36
|
+
|
37
|
+
# Calculates min and max from length validations for numeric inputs
|
38
|
+
b.optional :min_max
|
39
|
+
|
40
|
+
# Calculates readonly automatically from readonly attributes
|
41
|
+
b.optional :readonly
|
42
|
+
|
43
|
+
## Inputs
|
44
|
+
b.use :label_input
|
45
|
+
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
46
|
+
b.use :error, wrap_with: { tag: :span, class: :error }
|
47
|
+
|
48
|
+
## full_messages_for
|
49
|
+
# If you want to display the full error message for the attribute, you can
|
50
|
+
# use the component :full_error, like:
|
51
|
+
#
|
52
|
+
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
53
|
+
end
|
54
|
+
|
55
|
+
# The default wrapper to be used by the FormBuilder.
|
56
|
+
config.default_wrapper = :default
|
57
|
+
|
58
|
+
# Define the way to render check boxes / radio buttons with labels.
|
59
|
+
# Defaults to :nested for bootstrap config.
|
60
|
+
# inline: input + label
|
61
|
+
# nested: label > input
|
62
|
+
config.boolean_style = :nested
|
63
|
+
|
64
|
+
# Default class for buttons
|
65
|
+
config.button_class = 'btn'
|
66
|
+
|
67
|
+
# Method used to tidy up errors. Specify any Rails Array method.
|
68
|
+
# :first lists the first message for each field.
|
69
|
+
# Use :to_sentence to list all errors for each field.
|
70
|
+
# config.error_method = :first
|
71
|
+
|
72
|
+
# Default tag used for error notification helper.
|
73
|
+
config.error_notification_tag = :div
|
74
|
+
|
75
|
+
# CSS class to add for error notification helper.
|
76
|
+
config.error_notification_class = 'error_notification'
|
77
|
+
|
78
|
+
# ID to add for error notification helper.
|
79
|
+
# config.error_notification_id = nil
|
80
|
+
|
81
|
+
# Series of attempts to detect a default label method for collection.
|
82
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
83
|
+
|
84
|
+
# Series of attempts to detect a default value method for collection.
|
85
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
86
|
+
|
87
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
88
|
+
# config.collection_wrapper_tag = nil
|
89
|
+
|
90
|
+
# You can define the class to use on all collection wrappers. Defaulting to none.
|
91
|
+
# config.collection_wrapper_class = nil
|
92
|
+
|
93
|
+
# You can wrap each item in a collection of radio/check boxes with a tag,
|
94
|
+
# defaulting to :span. Please note that when using :boolean_style = :nested,
|
95
|
+
# SimpleForm will force this option to be a label.
|
96
|
+
# config.item_wrapper_tag = :span
|
97
|
+
|
98
|
+
# You can define a class to use in all item wrappers. Defaulting to none.
|
99
|
+
# config.item_wrapper_class = nil
|
100
|
+
|
101
|
+
# How the label text should be generated altogether with the required text.
|
102
|
+
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
103
|
+
|
104
|
+
# You can define the class to use on all labels. Default is nil.
|
105
|
+
# config.label_class = nil
|
106
|
+
|
107
|
+
# You can define the default class to be used on forms. Can be overriden
|
108
|
+
# with `html: { :class }`. Defaulting to none.
|
109
|
+
# config.default_form_class = nil
|
110
|
+
|
111
|
+
# You can define which elements should obtain additional classes
|
112
|
+
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
113
|
+
|
114
|
+
# Whether attributes are required by default (or not). Default is true.
|
115
|
+
# config.required_by_default = true
|
116
|
+
|
117
|
+
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
118
|
+
# These validations are enabled in SimpleForm's internal config but disabled by default
|
119
|
+
# in this configuration, which is recommended due to some quirks from different browsers.
|
120
|
+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
121
|
+
# change this configuration to true.
|
122
|
+
config.browser_validations = false
|
123
|
+
|
124
|
+
# Collection of methods to detect if a file type was given.
|
125
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
126
|
+
|
127
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
128
|
+
# to match as key, and the input type that will be used when the field name
|
129
|
+
# matches the regexp as value.
|
130
|
+
# config.input_mappings = { /count/ => :integer }
|
131
|
+
|
132
|
+
# Custom wrappers for input types. This should be a hash containing an input
|
133
|
+
# type as key and the wrapper that will be used for all inputs with specified type.
|
134
|
+
# config.wrapper_mappings = { string: :prepend }
|
135
|
+
|
136
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
137
|
+
# override default inputs.
|
138
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
139
|
+
|
140
|
+
# Default priority for time_zone inputs.
|
141
|
+
# config.time_zone_priority = nil
|
142
|
+
|
143
|
+
# Default priority for country inputs.
|
144
|
+
# config.country_priority = nil
|
145
|
+
|
146
|
+
# When false, do not use translations for labels.
|
147
|
+
# config.translate_labels = true
|
148
|
+
|
149
|
+
# Automatically discover new inputs in Rails' autoload path.
|
150
|
+
# config.inputs_discovery = true
|
151
|
+
|
152
|
+
# Cache SimpleForm inputs discovery
|
153
|
+
# config.cache_discovery = !Rails.env.development?
|
154
|
+
|
155
|
+
# Default class for inputs
|
156
|
+
# config.input_class = nil
|
157
|
+
|
158
|
+
# Define the default class of the input wrapper of the boolean input.
|
159
|
+
config.boolean_label_class = 'checkbox'
|
160
|
+
|
161
|
+
# Defines if the default input wrapper class should be included in radio
|
162
|
+
# collection wrappers.
|
163
|
+
# config.include_default_input_wrapper_class = true
|
164
|
+
|
165
|
+
# Defines which i18n scope will be used in Simple Form.
|
166
|
+
# config.i18n_scope = 'simple_form'
|
167
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'simple_form'
|
2
|
+
# Use this setup block to configure all options available in SimpleForm.
|
3
|
+
SimpleForm.setup do |config|
|
4
|
+
config.error_notification_class = 'alert alert-danger'
|
5
|
+
config.button_class = 'btn btn-default'
|
6
|
+
config.boolean_label_class = nil
|
7
|
+
|
8
|
+
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
9
|
+
b.use :html5
|
10
|
+
b.use :placeholder
|
11
|
+
b.optional :maxlength
|
12
|
+
b.optional :pattern
|
13
|
+
b.optional :min_max
|
14
|
+
b.optional :readonly
|
15
|
+
b.use :label, class: 'control-label'
|
16
|
+
|
17
|
+
b.use :input, class: 'form-control'
|
18
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
19
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
20
|
+
end
|
21
|
+
|
22
|
+
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
23
|
+
b.use :html5
|
24
|
+
b.use :placeholder
|
25
|
+
b.optional :maxlength
|
26
|
+
b.optional :readonly
|
27
|
+
b.use :label, class: 'control-label'
|
28
|
+
|
29
|
+
b.use :input
|
30
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
31
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
32
|
+
end
|
33
|
+
|
34
|
+
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
35
|
+
b.use :html5
|
36
|
+
b.optional :readonly
|
37
|
+
|
38
|
+
b.wrapper tag: 'div', class: 'checkbox' do |ba|
|
39
|
+
ba.use :label_input
|
40
|
+
end
|
41
|
+
|
42
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
43
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
44
|
+
end
|
45
|
+
|
46
|
+
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
47
|
+
b.use :html5
|
48
|
+
b.optional :readonly
|
49
|
+
b.use :label, class: 'control-label'
|
50
|
+
b.use :input
|
51
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
52
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
53
|
+
end
|
54
|
+
|
55
|
+
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
56
|
+
b.use :html5
|
57
|
+
b.use :placeholder
|
58
|
+
b.optional :maxlength
|
59
|
+
b.optional :pattern
|
60
|
+
b.optional :min_max
|
61
|
+
b.optional :readonly
|
62
|
+
b.use :label, class: 'col-sm-3 control-label'
|
63
|
+
|
64
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
65
|
+
ba.use :input, class: 'form-control'
|
66
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
67
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
72
|
+
b.use :html5
|
73
|
+
b.use :placeholder
|
74
|
+
b.optional :maxlength
|
75
|
+
b.optional :readonly
|
76
|
+
b.use :label, class: 'col-sm-3 control-label'
|
77
|
+
|
78
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
79
|
+
ba.use :input
|
80
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
81
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
86
|
+
b.use :html5
|
87
|
+
b.optional :readonly
|
88
|
+
|
89
|
+
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
|
90
|
+
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
|
91
|
+
ba.use :label_input, class: 'col-sm-9'
|
92
|
+
end
|
93
|
+
|
94
|
+
wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
95
|
+
wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
100
|
+
b.use :html5
|
101
|
+
b.optional :readonly
|
102
|
+
|
103
|
+
b.use :label, class: 'col-sm-3 control-label'
|
104
|
+
|
105
|
+
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
106
|
+
ba.use :input
|
107
|
+
ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
108
|
+
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
113
|
+
b.use :html5
|
114
|
+
b.use :placeholder
|
115
|
+
b.optional :maxlength
|
116
|
+
b.optional :pattern
|
117
|
+
b.optional :min_max
|
118
|
+
b.optional :readonly
|
119
|
+
b.use :label, class: 'sr-only'
|
120
|
+
|
121
|
+
b.use :input, class: 'form-control'
|
122
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
123
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
124
|
+
end
|
125
|
+
|
126
|
+
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
127
|
+
# Check the Bootstrap docs (http://getbootstrap.com)
|
128
|
+
# to learn about the different styles for forms and inputs,
|
129
|
+
# buttons and other elements.
|
130
|
+
config.default_wrapper = :vertical_form
|
131
|
+
config.wrapper_mappings = {
|
132
|
+
check_boxes: :vertical_radio_and_checkboxes,
|
133
|
+
radio_buttons: :vertical_radio_and_checkboxes,
|
134
|
+
file: :vertical_file_input,
|
135
|
+
boolean: :vertical_boolean,
|
136
|
+
}
|
137
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
en:
|
2
|
+
simple_form:
|
3
|
+
"yes": 'Yes'
|
4
|
+
"no": 'No'
|
5
|
+
required:
|
6
|
+
text: 'required'
|
7
|
+
mark: '*'
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
9
|
+
# When using html, text and mark won't be used.
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
11
|
+
error_notification:
|
12
|
+
default_message: "Please review the problems below:"
|
13
|
+
# Examples
|
14
|
+
# labels:
|
15
|
+
# defaults:
|
16
|
+
# password: 'Password'
|
17
|
+
# user:
|
18
|
+
# new:
|
19
|
+
# email: 'E-mail to sign in.'
|
20
|
+
# edit:
|
21
|
+
# email: 'E-mail.'
|
22
|
+
# hints:
|
23
|
+
# defaults:
|
24
|
+
# username: 'User name to sign in.'
|
25
|
+
# password: 'No special characters, please.'
|
26
|
+
# include_blanks:
|
27
|
+
# defaults:
|
28
|
+
# age: 'Rather not say'
|
29
|
+
# prompts:
|
30
|
+
# defaults:
|
31
|
+
# age: 'Select your age'
|
data/config/locales/sufia.en.yml
CHANGED
data/lib/sufia/version.rb
CHANGED
@@ -35,6 +35,7 @@ describe BatchEditsController, :type => :controller do
|
|
35
35
|
end
|
36
36
|
it "should set the breadcrumb trail" do
|
37
37
|
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
38
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
38
39
|
get :edit
|
39
40
|
end
|
40
41
|
end
|
@@ -311,6 +311,10 @@ describe GenericFilesController, :type => :controller do
|
|
311
311
|
end
|
312
312
|
|
313
313
|
it 'renders the stats view' do
|
314
|
+
allow(controller.request).to receive(:referer).and_return('foo')
|
315
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
316
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
317
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.generic_file.browse_view'), Sufia::Engine.routes.url_helpers.generic_file_path(@generic_file.noid))
|
314
318
|
get :stats, id: @generic_file.noid
|
315
319
|
expect(response).to be_success
|
316
320
|
expect(response).to render_template(:stats)
|
@@ -525,6 +529,28 @@ describe GenericFilesController, :type => :controller do
|
|
525
529
|
end
|
526
530
|
end
|
527
531
|
|
532
|
+
describe "edit" do
|
533
|
+
let(:generic_file) do
|
534
|
+
GenericFile.new.tap do |gf|
|
535
|
+
gf.apply_depositor_metadata(@user)
|
536
|
+
gf.save!
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
after do
|
541
|
+
generic_file.destroy
|
542
|
+
end
|
543
|
+
|
544
|
+
it 'renders the edit view' do
|
545
|
+
allow(controller.request).to receive(:referer).and_return('foo')
|
546
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.title'), Sufia::Engine.routes.url_helpers.dashboard_index_path)
|
547
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.dashboard.my.files'), Sufia::Engine.routes.url_helpers.dashboard_files_path)
|
548
|
+
expect(controller).to receive(:add_breadcrumb).with(I18n.t('sufia.generic_file.browse_view'), Sufia::Engine.routes.url_helpers.generic_file_path(generic_file.noid))
|
549
|
+
get :edit, id: generic_file.noid
|
550
|
+
expect(response).to be_success
|
551
|
+
expect(response).to render_template(:edit)
|
552
|
+
end
|
553
|
+
end
|
528
554
|
describe "someone elses files" do
|
529
555
|
before do
|
530
556
|
f = GenericFile.new(pid: 'sufia:test5')
|
@@ -162,7 +162,7 @@ describe UsersController, :type => :controller do
|
|
162
162
|
s1 = double('one')
|
163
163
|
expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
|
164
164
|
expect(Sufia.queue).to receive(:push).with(s1).once
|
165
|
-
post :update, id: @user.user_key, user: { remove_avatar: true }
|
165
|
+
post :update, id: @user.user_key, user: { remove_avatar: 'true' }
|
166
166
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
167
167
|
expect(flash[:notice]).to include("Your profile has been updated")
|
168
168
|
expect(User.find_by_user_key(@user.user_key).avatar?).to be false
|
@@ -172,11 +172,12 @@ describe UsersController, :type => :controller do
|
|
172
172
|
s1 = double('one')
|
173
173
|
expect(UserEditProfileEventJob).to receive(:new).with(@user.user_key).and_return(s1)
|
174
174
|
expect(Sufia.queue).to receive(:push).with(s1).once
|
175
|
-
expect_any_instance_of(User).to receive(:populate_attributes).once
|
176
|
-
post :update, id: @user.user_key, user: { update_directory: true }
|
175
|
+
expect_any_instance_of(User).to receive(:populate_attributes).once.and_call_original
|
176
|
+
post :update, id: @user.user_key, user: { update_directory: 'true' }
|
177
177
|
expect(response).to redirect_to(@routes.url_helpers.profile_path(@user.to_param))
|
178
178
|
expect(flash[:notice]).to include("Your profile has been updated")
|
179
179
|
end
|
180
|
+
|
180
181
|
it "should set an social handles" do
|
181
182
|
expect(@user.twitter_handle).to be_blank
|
182
183
|
expect(@user.facebook_handle).to be_blank
|