hydra-editor 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Y2E0MWY5ZTZhYzFhMDg4ZDk0ZTBmZmMwMzJjYzBkMTk1ZTYwNGRjNw==
5
- data.tar.gz: !binary |-
6
- OWMyNzUyYzFmOWYxMTEwZGY5YWZhNWI1MjI2MzZmMDI4YjA4ZDdmOA==
2
+ SHA1:
3
+ metadata.gz: 693381922df32a3e9b427e823df2cb5ca4294671
4
+ data.tar.gz: aa9137e5123dc8a8785b9d90c5d5ddb64327beda
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NWQxNGM1OThhOGY3YjMwY2I1YzE3ZjZiYjAxYTAyNjdhOGQ1NjIwMGQ2ODk1
10
- MzgyMzg5NzU1NTIyNGYyYmJkNmI3NWE5MmQ5MDE4ZTY2MjdmOWE3M2YzNTEx
11
- OWE5MTI1NDc1OTMyNjI3ZmFhZTQzNGVkMDg3MTZmZWRjNGY3NWI=
12
- data.tar.gz: !binary |-
13
- ZGJiZGQyZmYzOGE0N2QxZmM1NWFkYjBiY2NmMmM1MjNmZmUwZjYyYTc4Yzc3
14
- ZjZiOTMxZWEwNTJkYmRlNzc1ZGI0MzQxMmUyYmQyNDlkMDZjZDk1MTUzMDk4
15
- YzczNmJmYTM5YTM4ZmRkYzNmZDkyOTE2MzE5NGI2Y2Y4ZGQ0MDE=
6
+ metadata.gz: 9dc2258a9cdb3388c9cdad0eaa450def128bc0a2ce71a2792d5a0388de15bef7e45f6458fa1ba07e392e3bace542d520527d9fbb5640d9891143e9901709bacb
7
+ data.tar.gz: 4c0b0aee0c443adcbe18218711791e38ac688d6fb1368ce75bf53d5a350d6e25f5718e8ebbf2f46f30e3eedef308c83cfe75a71a00b037bc4d53794a21f42887
data/README.md CHANGED
@@ -12,6 +12,8 @@ And to config/routes.rb add:
12
12
  mount HydraEditor::Engine => '/'
13
13
  ```
14
14
 
15
+ (Note: You do not have to mount the engine if you do not intend to use the engine's default routes.)
16
+
15
17
  In your initialization set ```HydraEditor.models```
16
18
 
17
19
  ```ruby
@@ -24,14 +26,15 @@ You can customize the names of your fields/models by adding to your translation
24
26
  ```yaml
25
27
  # config/locales/en.yml
26
28
  en:
27
- hydra:
28
- field_label:
29
- source2: "Alternate Source"
30
- dateCreated: "Date Created"
31
- dateAvailable: "Date Available"
32
- model_label:
33
- PdfModel: "PDF"
34
- RecordedAudio: "audio"
29
+ hydra_editor:
30
+ form:
31
+ field_label:
32
+ source2: "Alternate Source"
33
+ dateCreated: "Date Created"
34
+ dateAvailable: "Date Available"
35
+ model_label:
36
+ PdfModel: "PDF"
37
+ RecordedAudio: "audio"
35
38
 
36
39
  ```
37
40
 
@@ -46,6 +49,21 @@ Add the javascript by adding this line to your app/assets/javascript/application
46
49
  ```
47
50
 
48
51
  Add the stylesheets by adding this line to your app/assets/stylesheets/application.css:
52
+
49
53
  ```css
50
54
  *= require hydra-editor/hydra-editor
51
55
  ```
56
+
57
+ ## Other customizations
58
+
59
+ By default hydra-editor provides a RecordsController with :new, :create, :edit, and :update actions implemented in the included RecordsControllerBehavior module, and a RecordsHelper module with methods implemented in RecordsHelperBehavior. If you are mounting the engine and using its routes, you can override the controller behaviors by creating your own RecordsController:
60
+
61
+ ```ruby
62
+ class RecordsController < ApplicationController
63
+ include RecordsControllerBehavior
64
+
65
+ # You custom code
66
+ end
67
+ ```
68
+
69
+ If you are not mounting the engine or using its default routes, you can include RecordsControllerBehavior in your own controller and add the appropriate routes to your app's config/routes.rb.
@@ -1,25 +1,31 @@
1
1
  module RecordsControllerBehavior
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_filter :load_and_authorize_record, only: [:edit, :update]
6
+ end
7
+
2
8
  def new
3
9
  authorize! :create, ActiveFedora::Base
4
10
  unless has_valid_type?
5
- render 'choose_type'
11
+ render 'records/choose_type'
6
12
  return
7
13
  end
8
14
 
9
15
  @record = params[:type].constantize.new
10
16
  initialize_fields
17
+ render 'records/new'
11
18
  end
12
19
 
13
20
  def edit
14
- @record = ActiveFedora::Base.find(params[:id], cast: true)
15
- authorize! :edit, @record
16
21
  initialize_fields
22
+ render 'records/edit'
17
23
  end
18
24
 
19
25
  def create
20
26
  authorize! :create, ActiveFedora::Base
21
27
  unless has_valid_type?
22
- redirect_to hydra_editor.new_record_path, :flash=> {error: "Lost the type"}
28
+ redirect_to(respond_to?(:hydra_editor) ? hydra_editor.new_record_path : new_record_path, flash: {error: "Lost the type"})
23
29
  return
24
30
  end
25
31
  @record = params[:type].constantize.new
@@ -27,10 +33,10 @@ module RecordsControllerBehavior
27
33
 
28
34
  respond_to do |format|
29
35
  if @record.save
30
- format.html { redirect_to main_app.catalog_path(@record), notice: 'Object was successfully created.' }
31
- # ActiveFedora::Base#to_json causes a circular reference. Do somethign easy
36
+ format.html { redirect_to redirect_after_create, notice: 'Object was successfully created.' }
37
+ # ActiveFedora::Base#to_json causes a circular reference. Do something easy
32
38
  data = @record.terms_for_editing.inject({}) { |h,term| h[term] = @record[term]; h }
33
- format.json { render json: data, status: :created, location: hydra_editor.record_path(@record) }
39
+ format.json { render json: data, status: :created, location: redirect_after_create }
34
40
  else
35
41
  format.html { render action: "new" }
36
42
  format.json { render json: @record.errors, status: :unprocessable_entity }
@@ -40,12 +46,10 @@ module RecordsControllerBehavior
40
46
  end
41
47
 
42
48
  def update
43
- @record = ActiveFedora::Base.find(params[:id], cast: true)
44
- authorize! :update, @record
45
49
  set_attributes
46
50
  respond_to do |format|
47
51
  if @record.save
48
- format.html { redirect_to main_app.catalog_path(@record), notice: 'Object was successfully updated.' }
52
+ format.html { redirect_to redirect_after_update, notice: 'Object was successfully updated.' }
49
53
  format.json { head :no_content }
50
54
  else
51
55
  format.html { render action: "edit" }
@@ -56,11 +60,33 @@ module RecordsControllerBehavior
56
60
 
57
61
  protected
58
62
 
63
+ def load_and_authorize_record
64
+ load_record
65
+ authorize_record!
66
+ end
67
+
68
+ def load_record
69
+ @record = ActiveFedora::Base.find(params[:id], cast: true)
70
+ end
71
+
72
+ def authorize_record!
73
+ authorize! params[:action].to_sym, @record
74
+ end
75
+
59
76
  # Override this method if you want to set different metadata on the object
60
77
  def set_attributes
61
78
  @record.attributes = params[ActiveModel::Naming.singular(@record)]
62
79
  end
63
80
 
81
+ # Override to redirect to an alternate location after create
82
+ def redirect_after_create
83
+ main_app.catalog_path @record
84
+ end
85
+
86
+ # Override to redirect to an alternate location after update
87
+ def redirect_after_update
88
+ main_app.catalog_path @record
89
+ end
64
90
 
65
91
  def has_valid_type?
66
92
  HydraEditor.models.include? params[:type]
@@ -1,15 +1,15 @@
1
1
  module RecordsHelperBehavior
2
2
 
3
3
  def metadata_help(key)
4
- I18n.t("hydra.metadata_help.#{key}", default: key.to_s.humanize)
4
+ I18n.t("hydra_editor.form.metadata_help.#{key}", default: key.to_s.humanize)
5
5
  end
6
6
 
7
7
  def field_label(key)
8
- I18n.t("hydra.field_label.#{key}", default: key.to_s.humanize)
8
+ I18n.t("hydra_editor.form.field_label.#{key}", default: key.to_s.humanize)
9
9
  end
10
10
 
11
11
  def model_label(key)
12
- I18n.t("hydra.model_label.#{key}", default: key.to_s.humanize)
12
+ I18n.t("hydra_editor.form.model_label.#{key}", default: key.to_s.humanize)
13
13
  end
14
14
 
15
15
  def object_type_options
@@ -32,6 +32,23 @@ module RecordsHelperBehavior
32
32
  more_or_less_button(key, 'remover', '-')
33
33
  end
34
34
 
35
+ def record_form_action_url(record)
36
+ router = respond_to?(:hydra_editor) ? hydra_editor : self
37
+ record.new_record? ? router.records_path : router.record_path(record)
38
+ end
39
+
40
+ def new_record_title
41
+ I18n.t('hydra_editor.new.title') % model_label(params[:type])
42
+ end
43
+
44
+ def edit_record_title
45
+ I18n.t('hydra_editor.edit.title') % render_record_title
46
+ end
47
+
48
+ def render_record_title
49
+ Array(@record.title).first
50
+ end
51
+
35
52
  private
36
53
 
37
54
  def render_edit_field_partial_with_action(action, key, locals)
@@ -1,11 +1,14 @@
1
- <%= bootstrap_form_for record, :url=>record.new_record? ? hydra_editor.records_path : hydra_editor.record_path(record), html: {:class => 'form-inline editor'} do |f| %>
1
+ <%= bootstrap_form_for record, url: record_form_action_url(record), html: {:class => 'form-inline editor'} do |f| %>
2
2
  <div id="descriptions_display">
3
- <h2 class="non lower">Descriptions <small class="pull-right"><span class="error">*</span> indicates required fields</small> </h2>
3
+ <h2 class="non lower">
4
+ <%= t('hydra_editor.form.title') %>
5
+ <small class="pull-right"><span class="error">*</span> <%= t('hydra_editor.form.required_fields') %></small>
6
+ </h2>
4
7
  <div class="well">
5
8
  <% f.object.terms_for_editing.each do |term| %>
6
- <%= render :partial => "records/edit_field", :locals => {:f =>f, :render_req => true, :key => term } %>
9
+ <%= render :partial => "records/edit_field", :locals => {:f => f, :render_req => true, :key => term } %>
7
10
  <% end %>
8
- </div><!-- /well -->
11
+ </div> <!-- /well -->
9
12
  </div>
10
13
  <%= hidden_field_tag :type, params[:type] %>
11
14
  <%= f.actions do %>
@@ -1,8 +1,7 @@
1
- <h1>Create a new record</h1>
2
-
3
- <%= bootstrap_form_tag hydra_editor.new_record_path, :method=>:get do |f| %>
1
+ <h1><%= t('hydra_editor.choose_type.title') %></h1>
2
+ <%= bootstrap_form_tag new_hydra_editor_record_path, :method => :get do |f| %>
4
3
  <%= bootstrap_select_tag :type, options_for_select(object_type_options) %>
5
4
  <%= bootstrap_actions do %>
6
- <%= bootstrap_submit_tag 'Next'%>
5
+ <%= bootstrap_submit_tag 'Next' %>
7
6
  <% end %>
8
7
  <% end %>
@@ -1,3 +1,3 @@
1
- <h1>Edit <%= Array(@record.title).first %></h1>
2
- <%= render :partial=>'form', locals: {record: @record} %>
1
+ <h1><%= edit_record_title %></h1>
2
+ <%= render :partial=>'records/form', locals: {record: @record} %>
3
3
 
@@ -1,2 +1,2 @@
1
- <h1>Create a new <%= model_label(params[:type]) %> record</h1>
2
- <%= render :partial=>'form', locals: {record: @record} %>
1
+ <h1><%= new_record_title %></h1>
2
+ <%= render :partial=>'records/form', locals: {record: @record} %>
@@ -0,0 +1,11 @@
1
+ en:
2
+ hydra_editor:
3
+ choose_type:
4
+ title: 'Create a New Record'
5
+ edit:
6
+ title: 'Edit %s'
7
+ form:
8
+ title: 'Descriptions'
9
+ required_fields: 'indicates required fields'
10
+ new:
11
+ title: 'Create a New %s Record'
@@ -1,3 +1,3 @@
1
1
  module HydraEditor
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,20 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.13
20
20
  - - <
@@ -24,7 +24,7 @@ dependencies:
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.13
30
30
  - - <
@@ -34,126 +34,126 @@ dependencies:
34
34
  name: bootstrap_forms
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - '>='
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ! '>='
44
+ - - '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: active-fedora
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ! '>='
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 6.3.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ! '>='
58
+ - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: 6.3.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: sqlite3
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ! '>='
65
+ - - '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ! '>='
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec-rails
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ! '>='
79
+ - - '>='
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ! '>='
86
+ - - '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: capybara
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ! '>='
93
+ - - '>='
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ! '>='
100
+ - - '>='
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: sqlite3
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ! '>='
107
+ - - '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ! '>='
114
+ - - '>='
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: blacklight
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - ! '>='
121
+ - - '>='
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - ! '>='
128
+ - - '>='
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: devise
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - ! '>='
135
+ - - '>='
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - ! '>='
142
+ - - '>='
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: hydra-head
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
- - - ! '>='
149
+ - - '>='
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - ! '>='
156
+ - - '>='
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  description: A basic Dublin Core metadata editor for hydra-head
@@ -179,6 +179,7 @@ files:
179
179
  - app/views/records/edit_fields/_default.html.erb
180
180
  - app/views/records/edit_fields/_suffix.html.erb
181
181
  - app/views/records/new.html.erb
182
+ - config/locales/hydra_editor.yml
182
183
  - config/routes.rb
183
184
  - lib/hydra-editor.rb
184
185
  - lib/hydra_editor/engine.rb
@@ -186,15 +187,6 @@ files:
186
187
  - lib/tasks/hydra-editor_tasks.rake
187
188
  - Rakefile
188
189
  - README.md
189
- - spec/controllers/records_controller_spec.rb
190
- - spec/factories/users.rb
191
- - spec/helpers/records_helper_spec.rb
192
- - spec/models/bookmark_spec.rb
193
- - spec/spec_helper.rb
194
- - spec/support/audio.rb
195
- - spec/support/dummy_generator.rb
196
- - spec/support/Gemfile
197
- - spec/support/lib/generators/test_app_generator.rb
198
190
  homepage: http://github.com/projecthydra/hydra-editor
199
191
  licenses: []
200
192
  metadata: {}
@@ -204,27 +196,18 @@ require_paths:
204
196
  - lib
205
197
  required_ruby_version: !ruby/object:Gem::Requirement
206
198
  requirements:
207
- - - ! '>='
199
+ - - '>='
208
200
  - !ruby/object:Gem::Version
209
201
  version: '0'
210
202
  required_rubygems_version: !ruby/object:Gem::Requirement
211
203
  requirements:
212
- - - ! '>='
204
+ - - '>='
213
205
  - !ruby/object:Gem::Version
214
206
  version: '0'
215
207
  requirements: []
216
208
  rubyforge_project:
217
- rubygems_version: 2.1.4
209
+ rubygems_version: 2.0.6
218
210
  signing_key:
219
211
  specification_version: 4
220
212
  summary: A basic Dublin Core metadata editor for hydra-head
221
- test_files:
222
- - spec/controllers/records_controller_spec.rb
223
- - spec/factories/users.rb
224
- - spec/helpers/records_helper_spec.rb
225
- - spec/models/bookmark_spec.rb
226
- - spec/spec_helper.rb
227
- - spec/support/audio.rb
228
- - spec/support/dummy_generator.rb
229
- - spec/support/Gemfile
230
- - spec/support/lib/generators/test_app_generator.rb
213
+ test_files: []
@@ -1,101 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RecordsController do
4
- describe "an admin" do
5
- before do
6
- HydraEditor.models = ['Audio', 'Pdf']
7
- @user = FactoryGirl.create(:admin)
8
- sign_in @user
9
- end
10
- describe "who goes to the new page" do
11
- it "should be successful" do
12
- get :new
13
- response.should be_successful
14
- response.should render_template(:choose_type)
15
- end
16
- it "should be successful" do
17
- get :new, :type=>'Audio'
18
- response.should be_successful
19
- response.should render_template(:new)
20
- end
21
- end
22
-
23
- describe "creating a new record" do
24
- before do
25
- stub_audio = Audio.new(pid: 'test:6')
26
- stub_audio.stub(:persisted?).and_return(true)
27
- Audio.should_receive(:new).and_return(stub_audio)
28
- stub_audio.should_receive(:save).and_return(true)
29
- end
30
- it "should be successful" do
31
- post :create, :type=>'Audio', :audio=>{:title=>"My title"}
32
- response.should redirect_to("/catalog/#{assigns[:record].id}")
33
- assigns[:record].title.should == ['My title']
34
- end
35
- it "should be successful with json" do
36
- post :create, :type=>'Audio', :audio=>{:title=>"My title"}, :format=>:json
37
- response.status.should == 201
38
- end
39
- describe "when set_attributes is overloaded" do
40
- class RecordsController
41
- def set_attributes
42
- super
43
- @record.inner_object.pid = 'tufts:0001'
44
- end
45
- end
46
- it "should run set_attributes" do
47
- post :create, :type=>'Audio', :audio=>{:title=>"My title"}
48
- response.should redirect_to("/catalog/#{assigns[:record].id}")
49
- assigns[:record].pid.should == 'tufts:0001'
50
- end
51
- end
52
- end
53
-
54
- describe "editing a record" do
55
- before do
56
- @audio = Audio.new(title: 'My title2', pid: 'test:7')
57
- ActiveFedora::Base.should_receive(:find).with('test:7', cast:true).and_return(@audio)
58
- controller.should_receive(:authorize!).with(:edit, @audio)
59
- end
60
- it "should be successful" do
61
- get :edit, :id=>@audio.pid
62
- response.should be_successful
63
- assigns[:record].title.should == ['My title2']
64
- end
65
- end
66
-
67
- describe "updating a record" do
68
- before do
69
- @audio = Audio.new(title: 'My title2', pid: 'test:7')
70
- @audio.stub(:persisted?).and_return(true)
71
- @audio.should_receive(:save).and_return(true)
72
- ActiveFedora::Base.should_receive(:find).with('test:7', cast:true).and_return(@audio)
73
- controller.should_receive(:authorize!).with(:update, @audio)
74
- end
75
- it "should be successful" do
76
- put :update, :id=>@audio, :audio=>{:title=>"My title 3"}
77
- response.should redirect_to("/catalog/#{assigns[:record].id}")
78
- assigns[:record].title.should == ['My title 3']
79
- end
80
- it "should be successful with json" do
81
- put :update, :id=>@audio, :audio=>{:title=>"My title"}, :format=>:json
82
- response.status.should == 204
83
- end
84
-
85
- end
86
- end
87
-
88
-
89
- describe "a user without create ability" do
90
- before do
91
- @user = FactoryGirl.create(:user)
92
- sign_in @user
93
- controller.current_ability.cannot :create, ActiveFedora::Base
94
- end
95
- describe "who goes to the new page" do
96
- it "should not be allowed" do
97
- lambda { get :new }.should raise_error CanCan::AccessDenied
98
- end
99
- end
100
- end
101
- end
@@ -1,13 +0,0 @@
1
- require 'factory_girl'
2
-
3
- FactoryGirl.define do
4
- factory :user do
5
- sequence :email do |n|
6
- "person#{n}@example.com"
7
- end
8
- password 'password'
9
- factory :admin do
10
- #admin true
11
- end
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RecordsHelper do
4
- it "should have object_type_options" do
5
- HydraEditor.models = ['Audio', 'Pdf']
6
- I18n.stub(:t).with("hydra.model_label.Audio", default: 'Audio').and_return('Audio')
7
- I18n.stub(:t).with("hydra.model_label.Pdf", default: 'Pdf').and_return('PDF')
8
- helper.object_type_options.should == {'Audio' => 'Audio', 'PDF' => 'Pdf'}
9
- end
10
-
11
- it "draws add button" do
12
- helper.add_field(:test).should ==
13
- "<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\">+<span class=\"accessible-hidden\">add another test</span></button>"
14
- end
15
-
16
- it "draws subtract button" do
17
- helper.subtract_field(:test).should ==
18
- "<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\">-<span class=\"accessible-hidden\">add another test</span></button>"
19
- end
20
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bookmark do
4
- it "should be success" do
5
- true.should be_true
6
- end
7
- end
@@ -1,23 +0,0 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
- require 'rspec/rails'
4
- require 'rspec/autorun'
5
- require 'factory_girl_rails'
6
-
7
- FactoryGirl.definition_file_paths = ["#{File.dirname(__FILE__)}/factories"]
8
- FactoryGirl.find_definitions
9
-
10
- Rails.backtrace_cleaner.remove_silencers!
11
- # Load support files
12
-
13
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
-
15
- RSpec.configure do |config|
16
- config.include Devise::TestHelpers, :type => :controller
17
- config.use_transactional_fixtures = true
18
- config.infer_base_class_for_anonymous_controllers = false
19
- config.order = "random"
20
-
21
- # see https://github.com/rails/journey/issues/39
22
- config.before(:each, :type=>"controller") { @routes = HydraEditor::Engine.routes }
23
- end
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '3.2.13'
4
- gem 'sqlite3'
5
-
6
- gem 'blacklight'
7
- gem 'hydra-head'
8
- gem 'hydra-editor', path: '../../'
9
-
10
-
11
- gem "factory_girl_rails"
12
- gem 'rspec-rails'
@@ -1,18 +0,0 @@
1
- # A class just for testing
2
- class Audio < ActiveFedora::Base
3
- include Hydra::ModelMixins::RightsMetadata
4
-
5
- # Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
6
- has_metadata "rightsMetadata", type: Hydra::Datastream::RightsMetadata
7
-
8
- # Tufts specific needed metadata streams
9
- has_metadata "descMetadata", :type => ActiveFedora::QualifiedDublinCoreDatastream
10
-
11
- validates_presence_of :title#, :creator, :description
12
-
13
- delegate_to "descMetadata", [:title, :creator, :description, :subject]
14
-
15
- def terms_for_editing
16
- [:title, :creator, :description, :subject]
17
- end
18
- end
@@ -1,26 +0,0 @@
1
- # From: https://gist.github.com/stas/4131823
2
- require 'rails/generators'
3
- require 'rails/generators/rails/plugin_new/plugin_new_generator'
4
-
5
- class DummyGenerator < Rails::Generators::PluginNewGenerator
6
-
7
- def self.default_source_root
8
- Rails::Generators::PluginNewGenerator.default_source_root
9
- end
10
-
11
- def do_nothing
12
- end
13
-
14
- alias :create_root :do_nothing
15
- alias :create_root_files :do_nothing
16
- alias :create_app_files :do_nothing
17
- alias :create_config_files :do_nothing
18
- alias :create_lib_files :do_nothing
19
- alias :create_public_stylesheets_files :do_nothing
20
- alias :create_javascript_files :do_nothing
21
- alias :create_script_files :do_nothing
22
- alias :update_gemfile :do_nothing
23
- alias :create_test_files :do_nothing
24
- alias :finish_template :do_nothing
25
-
26
- end
@@ -1,26 +0,0 @@
1
- require 'rails/generators'
2
-
3
- class TestAppGenerator < Rails::Generators::Base
4
- #source_root File.expand_path("../../../../support", __FILE__)
5
-
6
- def add_routes
7
- insert_into_file "config/routes.rb", :after => '.draw do' do
8
- "\n mount HydraEditor::Engine => \"/\""
9
-
10
- end
11
- end
12
-
13
- # def copy_test_models
14
- # copy_file "app/models/sample.rb"
15
- # copy_file "app/models/solr_document.rb"
16
- # copy_file "db/migrate/20111101221803_create_searches.rb"
17
- # end
18
-
19
- # def copy_rspec_rake_task
20
- # copy_file "lib/tasks/rspec.rake"
21
- # end
22
-
23
- # def copy_hydra_config
24
- # copy_file "config/initializers/hydra_config.rb"
25
- # end
26
- end