* Prepare factories and associations for Users::DeleteActivity specs * Altered user associations, delete the needed associations in Users::DeleteActivity * Moved and refined user deletion spec * Removed useless commented user associations * Refactored BackupData factory * Refactored ProfilePin factory * Refactored Reaction factory * Fixed specs: Keep default _type in factories or specify it in tests * Ok, notes shouldn't be deleted on user deletion * Fixed creating reactable for specs * Specify commentable/commentable_type explicitly when creating data for tests * Fixed typo in the comments spec * Removed unnneeded space * Added aggregate_failures for testing user associations deletion * Keep feedback_messages while deleting user activities
40 lines
1.3 KiB
Ruby
40 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "OrganizationsUpdate", type: :request do
|
|
let(:user) { create(:user, :org_admin) }
|
|
let(:org_id) { user.organizations.first.id }
|
|
let(:article) { create(:article, user_id: user.id) }
|
|
let(:comment) { create(:comment, user_id: user.id, commentable: article) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
it "updates org color with proper params" do
|
|
put "/organizations/#{org_id}", params: {
|
|
organization: { id: org_id, text_color_hex: "#111111" }
|
|
}
|
|
expect(Organization.last.text_color_hex).to eq("#111111")
|
|
end
|
|
|
|
it "generates new secret" do
|
|
secret = Organization.last.secret
|
|
post "/organizations/generate_new_secret", params: {
|
|
organization: { id: org_id }
|
|
}
|
|
expect(Organization.last.secret).not_to eq(secret)
|
|
end
|
|
|
|
it "updates profile_updated_at" do
|
|
Organization.last.update_column(:profile_updated_at, 2.weeks.ago)
|
|
put "/organizations/#{org_id}", params: { organization: { id: org_id, text_color_hex: "#111111" } }
|
|
expect(Organization.last.profile_updated_at).to be > 2.minutes.ago
|
|
end
|
|
|
|
it "returns not_found if organization is missing" do
|
|
invalid_id = org_id + 100
|
|
expect do
|
|
put "/organizations/#{invalid_id}", params: { organization: { id: invalid_id, text_color_hex: "#111111" } }
|
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
|
end
|
|
end
|