Skip to content

Commit

Permalink
Tests for activating lists, both your own and shared
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJackson-Oslo committed Jun 20, 2024
1 parent dfb83f9 commit c8dec6d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/requests/active_personal_space_lists_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe ActivePersonalSpaceList, type: :request do
let(:user) { Fabricate(:user) }
let(:users_space_list) { Fabricate(:personal_space_list, user:) }
let(:someone_elses_space_list) { Fabricate(:personal_space_list) }

before do
sign_in user
end

it "can activate and deactivate a list" do
expect(user.active_personal_space_list).to be_nil

post activate_personal_space_list_personal_space_list_path(id: users_space_list.id)
expect(user.reload.active_personal_space_list.personal_space_list_id).to be(users_space_list.id)

post deactivate_personal_space_list_personal_space_list_path(id: users_space_list.id)
expect(user.reload.active_personal_space_list).to be_nil
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,25 @@
expect(response).to redirect_to(personal_space_lists_path)
expect(someone_elses_data_on_space.reload.contact_status).to eq("said_no")
end

it "can activate and deactivate a list shared by someone, and have it removed if the list is no longer shared" do
expect(user.active_personal_space_list).to be_nil

post activate_personal_space_list_personal_space_list_path(id: someone_elses_space_list.id)
expect(user.reload.active_personal_space_list).to be_nil

someone_elses_space_list.start_sharing

post activate_personal_space_list_personal_space_list_path(id: someone_elses_space_list.id)
expect(user.reload.active_personal_space_list.personal_space_list_id).to be(someone_elses_space_list.id)

post deactivate_personal_space_list_personal_space_list_path(id: someone_elses_space_list.id)
expect(user.reload.active_personal_space_list).to be_nil

post activate_personal_space_list_personal_space_list_path(id: someone_elses_space_list.id)
expect(user.reload.active_personal_space_list.personal_space_list_id).to be(someone_elses_space_list.id)

someone_elses_space_list.stop_sharing
expect(user.reload.active_personal_space_list).to be_nil
end
end

0 comments on commit c8dec6d

Please sign in to comment.