diff --git a/spec/models/miq_report/import_export_spec.rb b/spec/models/miq_report/import_export_spec.rb index 320807039ba7..cb653a770196 100644 --- a/spec/models/miq_report/import_export_spec.rb +++ b/spec/models/miq_report/import_export_spec.rb @@ -25,6 +25,29 @@ subject { MiqReport.import_from_hash(@new_report, @options) } + context "report access" do + before do + @some_group = FactoryGirl.create(:miq_group) + @some_user = FactoryGirl.create(:user) + @new_report["MiqReport"]["miq_group_id"] = @some_group.id + @new_report["MiqReport"]["user_id"] = @some_user.id + end + + it "preserves group and user when :preserve_owner is true" do + @options[:preserve_owner] = true + imported_report, _ = subject + expect(imported_report["miq_group_id"]).to eq(@some_group.id) + expect(imported_report["user_id"]).to eq(@some_user.id) + end + + it "overrides group and user when :preserve_owner is false" do + @options[:preserve_owner] = false + imported_report, _ = subject + expect(imported_report["miq_group_id"]).to eq(@user.current_group_id) + expect(imported_report["user_id"]).to eq(@user.id) + end + end + context "new report" do before { @old_report.destroy }