Skip to content

Commit

Permalink
added rspec to check if 'Preserve owner?' checkbox is working
Browse files Browse the repository at this point in the history
  • Loading branch information
yrudman committed Dec 6, 2018
1 parent 3656c98 commit 75b8947
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/models/miq_report/import_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 75b8947

Please sign in to comment.