File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,14 +101,19 @@ class ParanoidConfiguredReset
101101 describe ".with_deleted" do
102102
103103 let ( :posts ) do
104- 2 . times { |i | ParanoidPost . create ( title : "testing #{ i } " ) }
104+ 2 . times . map { |i | ParanoidPost . create ( title : "testing #{ i } " ) }
105105 end
106106
107- before do
108- Mongoid . configure do |config |
109- config . try ( :allow_scopes_to_unset_default_scope= , true )
110- end
107+ around do |example |
108+ original_value = Mongoid . allow_scopes_to_unset_default_scope
109+ Mongoid . configure { |config | config . allow_scopes_to_unset_default_scope = true }
110+
111+ example . run
111112
113+ Mongoid . configure { |config | config . allow_scopes_to_unset_default_scope = original_value }
114+ end
115+
116+ before do
112117 posts . first . destroy
113118 end
114119
@@ -119,7 +124,7 @@ class ParanoidConfiguredReset
119124 it "returns the deleted documents" do
120125 expect ( with_deleted ) . to eq ( posts )
121126 end
122- end if respond_to? ( :allow_scopes_to_unset_default_scope= )
127+ end if Mongoid . respond_to? ( :allow_scopes_to_unset_default_scope= )
123128
124129 describe "#destroy!" do
125130
Original file line number Diff line number Diff line change 5858 Fish . fresh . with_deleted
5959 end
6060
61- if respond_to? ( :allow_scopes_to_unset_default_scope= )
62- before do
63- Mongoid . configure do |config |
64- config . try ( :allow_scopes_to_unset_default_scope= , true )
65- end
66-
67- it "removes only deleted_at from the selector" do
68- expect ( criteria . selector ) . to eq ( { "fresh" => true } )
69- end
61+ if Mongoid . respond_to? ( :allow_scopes_to_unset_default_scope= )
62+ around do |example |
63+ original_value = Mongoid . allow_scopes_to_unset_default_scope
64+ Mongoid . configure { |config | config . allow_scopes_to_unset_default_scope = true }
65+
66+ example . run
67+
68+ Mongoid . configure { |config | config . allow_scopes_to_unset_default_scope = original_value }
69+ end
70+
71+ it "removes only deleted_at from the selector" do
72+ expect ( criteria . selector ) . to eq ( { "fresh" => true } )
7073 end
7174 else
7275 it "raises an error if the feature is not supported" do
You can’t perform that action at this time.
0 commit comments