blacklight-spotlight 0.26.0 → 0.26.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7796437b15cb33ea287b007cfdc234f32dbf4ebb
4
- data.tar.gz: 14073a32190fea37021fa92b517d12511f22c02b
3
+ metadata.gz: fb87cc0336538721053f1ae27eb72f144a749e34
4
+ data.tar.gz: 7f6f669a329a037b4837b425e0f794d3e00ed237
5
5
  SHA512:
6
- metadata.gz: 5e44725a667615c9270a471493e28d1e79c20d52b5606d66e57faf62a2ef276941f7afc86df470a0f946c816d5cecbcfb71c4619f15d7db1764023765da238e3
7
- data.tar.gz: c0b91e1e8d835c5e96c444eab21c1d56be0e3755cb382d81683564d15214010f8ddc1452163dc6f1dfc7e560390de5d8ac868bad9adaf034633ebd180fad5de9
6
+ metadata.gz: d79777da225046b586c153aa3f0401b25c50ce3c9e3189ad22eea395c28615a03a30e7aa4625303e2bb69416c374ffefee60f78d053ec0c5ebbe685e8e737d7a
7
+ data.tar.gz: fb37ce544eeb851a99b06327a54493b6b929f5cdddff430c32a35345fb25a8ee7ff26a3ce7da73367060a1dd851ac8397ec4aa74fe6e63c7c7390dbbc22032b4
@@ -9,6 +9,8 @@ module Spotlight
9
9
  # explicit options support better subclassing
10
10
  load_and_authorize_resource through: :exhibit, instance_name: :resource, through_association: :resources
11
11
 
12
+ helper_method :resource_class
13
+
12
14
  def new
13
15
  add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), exhibit_root_path(@exhibit)
14
16
  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
@@ -22,6 +24,7 @@ module Spotlight
22
24
  if @resource.save_and_index
23
25
  redirect_to spotlight.admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
24
26
  else
27
+ flash[:error] = @resource.errors.full_messages.to_sentence if @resource.errors.present?
25
28
  render action: 'new'
26
29
  end
27
30
  end
@@ -1,3 +1,3 @@
1
1
  module Spotlight
2
- VERSION = '0.26.0'.freeze
2
+ VERSION = '0.26.1'.freeze
3
3
  end
@@ -52,12 +52,21 @@ describe Spotlight::ResourcesController, type: :controller do
52
52
 
53
53
  describe 'POST create' do
54
54
  let(:blacklight_solr) { double }
55
+ let(:invalid_resource) { Spotlight::Resource.new.tap { |x| x.errors.add(:url, 'is invalid') } }
55
56
  it 'create a resource' do
56
- expect_any_instance_of(Spotlight::Resource).to receive(:reindex_later)
57
+ expect_any_instance_of(Spotlight::Resource).to receive(:reindex_later).and_return(true)
57
58
  allow_any_instance_of(Spotlight::Resource).to receive(:blacklight_solr).and_return blacklight_solr
58
59
  post :create, params: { exhibit_id: exhibit, resource: { url: 'info:uri' } }
59
60
  expect(assigns[:resource]).to be_persisted
60
61
  end
62
+
63
+ it 'adds errors to the flash message' do
64
+ allow_any_instance_of(Spotlight::Resource).to receive_messages(save: false)
65
+ allow_any_instance_of(Spotlight::Resource).to receive(:errors).and_return invalid_resource.errors
66
+ post :create, params: { exhibit_id: exhibit, resource: { url: 'info:uri' } }
67
+ expect(assigns[:resource]).not_to be_persisted
68
+ expect(flash[:error]).to include 'Url is invalid'
69
+ end
61
70
  end
62
71
 
63
72
  describe 'POST reindex_all' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-08-12 00:00:00.000000000 Z
14
+ date: 2016-08-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails