This repository was archived by the owner on Jan 24, 2025. It is now read-only.
File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
require "elasticsearch/model"
2
+ require "logger"
2
3
require "securerandom"
3
4
4
5
class Dataset < ApplicationRecord
@@ -36,6 +37,8 @@ def publish
36
37
result = __elasticsearch__ . index_document ( id : uuid )
37
38
raise "Failed to publish" if result [ "_shards" ] [ "failed" ] . positive?
38
39
end
40
+ rescue StandardError => e
41
+ Rails . logger . error e
39
42
end
40
43
41
44
def unpublish
@@ -45,6 +48,8 @@ def unpublish
45
48
raise "Failed to unpublish" if result [ "_shards" ] [ "failed" ] . positive?
46
49
47
50
draft!
51
+ rescue StandardError => e
52
+ Rails . logger . error e
48
53
end
49
54
50
55
def as_indexed_json ( _options = { } )
Original file line number Diff line number Diff line change 48
48
allow ( subject . __elasticsearch__ ) . to receive ( :index_document )
49
49
. and_return ( "_shards" => { "failed" => 1 } )
50
50
51
- expect { subject . publish } . to raise_error ( /Failed to publish/ )
51
+ expect { subject . publish } . to_not raise_error ( /Failed to publish/ )
52
52
expect ( subject . reload . published? ) . to be_falsey
53
53
end
54
54
end
74
74
allow ( subject . __elasticsearch__ ) . to receive ( :delete_document )
75
75
. and_return ( "_shards" => { "failed" => 1 } )
76
76
77
- expect { subject . unpublish } . to raise_error ( /Failed to unpublish/ )
77
+ expect { subject . unpublish } . to_not raise_error ( /Failed to unpublish/ )
78
78
expect ( subject . published? ) . to be_truthy
79
79
end
80
80
end
You can’t perform that action at this time.
0 commit comments