Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Zanders committed May 23, 2024
1 parent 92a8327 commit 3264517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion spec/controllers/projects/queries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
let(:query_id) { "42" }

before do
allow(Queries::Projects::ProjectQuery).to receive(:find).with(query_id).and_return(query)
scope = instance_double(ActiveRecord::Relation)
allow(Queries::Projects::ProjectQuery).to receive(:visible).and_return(scope)
allow(scope).to receive(:find).with(query_id).and_return(query)

login_as user
end
Expand Down
12 changes: 10 additions & 2 deletions spec/helpers/menus/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@
Queries::Projects::ProjectQuery.create!(name: "Other user query", user: build(:user))
end

shared_let(:public_query) do
Queries::Projects::ProjectQuery.create!(name: "Public query", user: build(:user), public: true)
end

subject(:first_level_menu_items) { instance.first_level_menu_items }

it "returns 3 menu groups" do
it "returns 4 menu groups" do
expect(first_level_menu_items).to all(be_a(OpenProject::Menu::MenuGroup))
expect(first_level_menu_items.length).to eq(3)
expect(first_level_menu_items.length).to eq(4)
end

describe "children items" do
Expand All @@ -66,6 +70,10 @@
it "doesn't contain item for other user query" do
expect(children_menu_items).not_to include(have_attributes(title: "Other user query"))
end

it "contains item for public query" do
expect(children_menu_items).to include(have_attributes(title: "Public query"))
end
end

describe "selected children items" do
Expand Down

0 comments on commit 3264517

Please sign in to comment.