<commit_before>describe ReportController do
  context "::Dashboards" do
    before do
      login_as user
      @db = FactoryGirl.create(:miq_widget_set,
                               :owner    => user.current_group,
                               :set_data => {:col1 => [], :col2 => [], :col3 => []})
    end

    context "#db_edit" do
      let(:user) { FactoryGirl.create(:user, :features => "db_edit") }

      it "dashboard owner remains unchanged" do
        allow(controller).to receive(:db_fields_validation)
        allow(controller).to receive(:replace_right_cell)
        owner = @db.owner
        new_hash = {:name => "New Name", :description => "New Description", :col1 => [1], :col2 => [], :col3 => []}
        current = {:name => "New Name", :description => "New Description", :col1 => [], :col2 => [], :col3 => []}
        controller.instance_variable_set(:@edit, :new => new_hash, :db_id => @db.id, :current => current)
        controller.instance_variable_set(:@_params, :id => @db.id, :button => "save")
        controller.db_edit
        expect(@db.owner.id).to eq(owner.id)
        expect(assigns(:flash_array).first[:message]).to include("saved")
        expect(controller.send(:flash_errors?)).not_to be_truthy
      end
    end
  end
end
<commit_msg>Use let and adapt name in dashboard spec<commit_after>describe ReportController do
  context "::Dashboards" do
    let(:miq_widget_set) { FactoryGirl.create(:miq_widget_set, :owner => user.current_group, :set_data => {:col1 => [], :col2 => [], :col3 => []}) }
    let(:user)           { FactoryGirl.create(:user, :features => "db_edit") }

    before do
      login_as user
    end

    context "#db_edit" do
      it "dashboard owner remains unchanged" do
        allow(controller).to receive(:db_fields_validation)
        allow(controller).to receive(:replace_right_cell)
        owner = miq_widget_set.owner
        new_hash = {:name => "<NAME>", :description => "New Description", :col1 => [1], :col2 => [], :col3 => []}
        current = {:name => "<NAME>", :description => "New Description", :col1 => [], :col2 => [], :col3 => []}
        controller.instance_variable_set(:@edit, :new => new_hash, :db_id => miq_widget_set.id, :current => current)
        controller.instance_variable_set(:@_params, :id => miq_widget_set.id, :button => "save")
        controller.db_edit
        expect(miq_widget_set.owner.id).to eq(owner.id)
        expect(assigns(:flash_array).first[:message]).to include("saved")
        expect(controller.send(:flash_errors?)).not_to be_truthy
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.16259216142801708, 'fraction_numerical': 0.007760962359332557, 'mean_word_length': 3.092063492063492, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2978497', 'n_tokens_mistral': 806, 'n_tokens_neox': 788, 'n_words': 169}