Merge remote-tracking branch 'origin/main'

This commit is contained in:
Kay Faraday 2024-08-06 15:29:27 -07:00
commit 5c2c046a7a
10 changed files with 455 additions and 117 deletions

View File

@ -104,7 +104,7 @@ jobs:
yarn install --frozen-lockfile yarn install --frozen-lockfile
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
- name: stylelint - name: stylelint
uses: reviewdog/action-stylelint@v1.26.0 uses: reviewdog/action-stylelint@v1.28.0
with: with:
github_token: ${{ secrets.github_token }} github_token: ${{ secrets.github_token }}
reporter: github-pr-check reporter: github-pr-check

View File

@ -94,7 +94,7 @@ group :development, :test do
gem "rspec-mocks" gem "rspec-mocks"
gem "rspec-rails", "~> 6.1" gem "rspec-rails", "~> 6.1"
gem "rspec-sidekiq", "~> 5.0", require: false gem "rspec-sidekiq", "~> 5.0", require: false
gem "rubocop", "~> 1.64" gem "rubocop", "~> 1.65"
gem "rubocop-rails", "~> 2.25" gem "rubocop-rails", "~> 2.25"
gem "shoulda-matchers", "~> 6.2" gem "shoulda-matchers", "~> 6.2"
gem "simplecov", require: false gem "simplecov", require: false

View File

@ -87,8 +87,8 @@ GEM
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
minitest (>= 5.1) minitest (>= 5.1)
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.6) addressable (2.8.7)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2) ast (2.4.2)
base64 (0.2.0) base64 (0.2.0)
bcrypt (3.1.20) bcrypt (3.1.20)
@ -105,7 +105,7 @@ GEM
actionpack (>= 6.1) actionpack (>= 6.1)
activemodel (>= 6.1) activemodel (>= 6.1)
builder (3.3.0) builder (3.3.0)
bullet (7.1.6) bullet (7.2.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
uniform_notifier (~> 1.11) uniform_notifier (~> 1.11)
carrierwave (2.1.1) carrierwave (2.1.1)
@ -124,7 +124,7 @@ GEM
concurrent-ruby (1.3.3) concurrent-ruby (1.3.3)
connection_pool (2.4.1) connection_pool (2.4.1)
crass (1.0.6) crass (1.0.6)
cssbundling-rails (1.4.0) cssbundling-rails (1.4.1)
railties (>= 6.0.0) railties (>= 6.0.0)
csv (3.3.0) csv (3.3.0)
database_cleaner (2.0.2) database_cleaner (2.0.2)
@ -169,9 +169,9 @@ GEM
dry-logic (~> 1.4) dry-logic (~> 1.4)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
erubi (1.13.0) erubi (1.13.0)
et-orbi (1.2.7) et-orbi (1.2.11)
tzinfo tzinfo
excon (0.110.0) excon (0.111.0)
factory_bot (6.4.5) factory_bot (6.4.5)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
factory_bot_rails (6.4.3) factory_bot_rails (6.4.3)
@ -180,14 +180,14 @@ GEM
fake_email_validator (1.0.11) fake_email_validator (1.0.11)
activemodel activemodel
mail mail
faker (3.4.1) faker (3.4.2)
i18n (>= 1.8.11, < 2) i18n (>= 1.8.11, < 2)
ffi (1.16.3) ffi (1.16.3)
fog-aws (3.23.0) fog-aws (3.24.0)
fog-core (~> 2.1) fog-core (~> 2.1)
fog-json (~> 1.1) fog-json (~> 1.1)
fog-xml (~> 0.1) fog-xml (~> 0.1)
fog-core (2.4.0) fog-core (2.5.0)
builder builder
excon (~> 0.71) excon (~> 0.71)
formatador (>= 0.2, < 2.0) formatador (>= 0.2, < 2.0)
@ -201,8 +201,8 @@ GEM
fog-core fog-core
nokogiri (>= 1.5.11, < 2.0.0) nokogiri (>= 1.5.11, < 2.0.0)
formatador (1.1.0) formatador (1.1.0)
fugit (1.9.0) fugit (1.11.0)
et-orbi (~> 1, >= 1.2.7) et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4) raabro (~> 1.4)
glob (0.4.0) glob (0.4.0)
globalid (1.2.1) globalid (1.2.1)
@ -232,10 +232,10 @@ GEM
image_processing (1.12.2) image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5) mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3) ruby-vips (>= 2.0.17, < 3)
jsbundling-rails (1.3.0) jsbundling-rails (1.3.1)
railties (>= 6.0.0) railties (>= 6.0.0)
json (2.7.2) json (2.7.2)
json-schema (4.3.0) json-schema (4.3.1)
addressable (>= 2.8) addressable (>= 2.8)
jwt (2.8.2) jwt (2.8.2)
base64 base64
@ -271,14 +271,14 @@ GEM
method_source (1.1.0) method_source (1.1.0)
mime-types (3.5.2) mime-types (3.5.2)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2024.0604) mime-types-data (3.2024.0702)
mimemagic (0.4.3) mimemagic (0.4.3)
nokogiri (~> 1) nokogiri (~> 1)
rake rake
mini_magick (4.13.1) mini_magick (4.13.2)
mini_mime (1.1.5) mini_mime (1.1.5)
mini_portile2 (2.8.7) mini_portile2 (2.8.7)
minitest (5.24.0) minitest (5.24.1)
msgpack (1.7.2) msgpack (1.7.2)
multi_json (1.15.0) multi_json (1.15.0)
multi_xml (0.7.1) multi_xml (0.7.1)
@ -297,29 +297,30 @@ GEM
timeout timeout
net-smtp (0.5.0) net-smtp (0.5.0)
net-protocol net-protocol
nio4r (2.7.0) nio4r (2.7.3)
nokogiri (1.16.6) nokogiri (1.16.7)
mini_portile2 (~> 2.8.2) mini_portile2 (~> 2.8.2)
racc (~> 1.4) racc (~> 1.4)
oj (3.16.4) oj (3.16.4)
bigdecimal (>= 3.0) bigdecimal (>= 3.0)
openssl (3.2.0) openssl (3.2.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
parallel (1.24.0) parallel (1.25.1)
parser (3.3.2.0) parser (3.3.4.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
pg (1.5.6) pg (1.5.7)
pghero (3.5.0) pghero (3.5.0)
activerecord (>= 6) activerecord (>= 6)
prometheus-client (4.2.2) prometheus-client (4.2.3)
public_suffix (5.0.4) base64
public_suffix (6.0.1)
puma (6.4.2) puma (6.4.2)
nio4r (~> 2.0) nio4r (~> 2.0)
pundit (2.3.2) pundit (2.3.2)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
raabro (1.4.0) raabro (1.4.0)
racc (1.8.0) racc (1.8.1)
rack (2.2.9) rack (2.2.9)
rack-test (2.1.0) rack-test (2.1.0)
rack (>= 1.3) rack (>= 1.3)
@ -351,7 +352,7 @@ GEM
rails-i18n (7.0.9) rails-i18n (7.0.9)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8) railties (>= 6.0.0, < 8)
rails_admin (3.1.2) rails_admin (3.1.4)
activemodel-serializers-xml (>= 1.0) activemodel-serializers-xml (>= 1.0)
kaminari (>= 0.14, < 2.0) kaminari (>= 0.14, < 2.0)
nested_form (~> 0.3) nested_form (~> 0.3)
@ -374,8 +375,8 @@ GEM
responders (3.1.1) responders (3.1.1)
actionpack (>= 5.2) actionpack (>= 5.2)
railties (>= 5.2) railties (>= 5.2)
rexml (3.2.8) rexml (3.3.4)
strscan (>= 3.0.9) strscan
rolify (6.0.1) rolify (6.0.1)
rotp (6.3.0) rotp (6.3.0)
rouge (4.1.3) rouge (4.1.3)
@ -418,20 +419,20 @@ GEM
rspec-mocks (~> 3.0) rspec-mocks (~> 3.0)
sidekiq (>= 5, < 8) sidekiq (>= 5, < 8)
rspec-support (3.13.1) rspec-support (3.13.1)
rubocop (1.64.1) rubocop (1.65.1)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.3.0.2) parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0) rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3) rubocop-ast (1.32.0)
parser (>= 3.3.1.0) parser (>= 3.3.1.0)
rubocop-rails (2.25.0) rubocop-rails (2.25.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0) rubocop (>= 1.33.0, < 2.0)
@ -442,7 +443,7 @@ GEM
rubyzip (2.3.2) rubyzip (2.3.2)
rufus-scheduler (3.9.1) rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6) fugit (~> 1.1, >= 1.1.6)
sanitize (6.1.1) sanitize (6.1.2)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.12.0) nokogiri (>= 1.12.0)
sassc (2.4.0) sassc (2.4.0)
@ -453,14 +454,14 @@ GEM
sprockets (> 3.0) sprockets (> 3.0)
sprockets-rails sprockets-rails
tilt tilt
sentry-rails (5.17.3) sentry-rails (5.18.2)
railties (>= 5.0) railties (>= 5.0)
sentry-ruby (~> 5.17.3) sentry-ruby (~> 5.18.2)
sentry-ruby (5.17.3) sentry-ruby (5.18.2)
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
sentry-sidekiq (5.17.3) sentry-sidekiq (5.18.2)
sentry-ruby (~> 5.17.3) sentry-ruby (~> 5.18.2)
sidekiq (>= 3.0) sidekiq (>= 3.0)
shoulda-matchers (6.2.0) shoulda-matchers (6.2.0)
activesupport (>= 5.2.0) activesupport (>= 5.2.0)
@ -468,10 +469,10 @@ GEM
connection_pool (>= 2.2.5, < 3) connection_pool (>= 2.2.5, < 3)
rack (~> 2.0) rack (~> 2.0)
redis (>= 4.5.0, < 5) redis (>= 4.5.0, < 5)
sidekiq-scheduler (5.0.3) sidekiq-scheduler (5.0.6)
rufus-scheduler (~> 3.2) rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8) sidekiq (>= 6, < 8)
tilt (>= 1.4.0) tilt (>= 1.4.0, < 3)
simplecov (0.22.0) simplecov (0.22.0)
docile (~> 1.1) docile (~> 1.1)
simplecov-html (~> 0.11) simplecov-html (~> 0.11)
@ -487,7 +488,7 @@ GEM
sprockets (4.2.1) sprockets (4.2.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4) rack (>= 2.2.4, < 4)
sprockets-rails (3.5.1) sprockets-rails (3.5.2)
actionpack (>= 6.1) actionpack (>= 6.1)
activesupport (>= 6.1) activesupport (>= 6.1)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
@ -496,7 +497,7 @@ GEM
sysexits (1.2.0) sysexits (1.2.0)
temple (0.10.3) temple (0.10.3)
thor (1.3.1) thor (1.3.1)
tilt (2.3.0) tilt (2.4.0)
timeout (0.4.1) timeout (0.4.1)
tldv (0.1.0) tldv (0.1.0)
tldv-data (~> 1.0) tldv-data (~> 1.0)
@ -515,7 +516,7 @@ GEM
unf_ext (0.0.8.2) unf_ext (0.0.8.2)
unicode-display_width (2.5.0) unicode-display_width (2.5.0)
uniform_notifier (1.16.0) uniform_notifier (1.16.0)
view_component (3.12.1) view_component (3.13.0)
activesupport (>= 5.2.0, < 8.0) activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
method_source (~> 1.0) method_source (~> 1.0)
@ -530,7 +531,7 @@ GEM
websocket-driver (0.7.6) websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
zeitwerk (2.6.16) zeitwerk (2.6.17)
PLATFORMS PLATFORMS
ruby ruby
@ -598,7 +599,7 @@ DEPENDENCIES
rspec-mocks rspec-mocks
rspec-rails (~> 6.1) rspec-rails (~> 6.1)
rspec-sidekiq (~> 5.0) rspec-sidekiq (~> 5.0)
rubocop (~> 1.64) rubocop (~> 1.65)
rubocop-rails (~> 2.25) rubocop-rails (~> 2.25)
rubyzip (~> 2.3) rubyzip (~> 2.3)
sanitize sanitize

View File

@ -15,9 +15,9 @@ module Retrospring
def year = 2024 def year = 2024
def month = 3 def month = 8
def day = 19 def day = 6
def patch = 0 def patch = 0

View File

@ -5,17 +5,76 @@ module UseCase
class Answers < UseCase::DataExport::Base class Answers < UseCase::DataExport::Base
def files = { def files = {
"answers.json" => json_file!( "answers.json" => json_file!(
answers: user.answers.map(&method(:collect_answer)) answers: user.answers.map(&method(:collect_answer)),
) ),
} }
def collect_answer(answer) def collect_answer(answer)
{}.tap do |h| {}.tap do |h|
column_names(::Answer).each do |field| column_names(::Answer).each do |field|
h[field] = answer[field] h[field] = answer[field]
h[:related] = related_fields(answer)
end end
end end
end end
def related_fields(answer) = {
question: question_for(answer),
comments: comments_for(answer),
}
def question_for(answer)
return unless answer.question
question = answer.question
{}.tap do |q|
q.merge!(
id: nil,
anonymous: false,
generated: false,
direct: false,
author: nil,
content: nil,
created_at: nil,
)
%i[id direct content created_at].each do |field|
q[field] = question[field]
end
if question.generated?
q[:generated] = true
q[:anonymous] = true
elsif question.author_is_anonymous
q[:anonymous] = true
else
q[:author] = lean_user(question.user)
end
end
end
def comments_for(answer) = [].tap do |c|
next if answer.comments.empty?
answer.comments.order(:created_at).each do |comment|
c << {
id: comment.id,
author: lean_user(comment.user),
smile_count: comment.smile_count,
content: comment.content,
created_at: comment.created_at,
}
end
end
def lean_user(user)
return unless user
{
id: user.id,
screen_name: user.screen_name,
}
end
end end
end end
end end

View File

@ -3,20 +3,24 @@
module UseCase module UseCase
module DataExport module DataExport
class Theme < UseCase::DataExport::Base class Theme < UseCase::DataExport::Base
include ThemeHelper
MODEL_FIELDS = %i[id user_id created_at updated_at].freeze
def files def files
return {} unless user.theme return {} unless user.theme
{ {
"theme.json" => json_file!( "theme.json" => json_file!(
theme: theme_data theme: theme_data,
) ),
} }
end end
def theme_data def theme_data
{}.tap do |obj| {}.tap do |obj|
column_names(::Theme).each do |field| (column_names(::Theme) - MODEL_FIELDS).each do |field|
obj[field] = user.theme[field] obj[field] = "##{get_hex_color_from_theme_value(user.theme[field])}"
end end
end end
end end

View File

@ -8,10 +8,10 @@
}, },
"dependencies": { "dependencies": {
"@fontsource/lexend": "^4.5.15", "@fontsource/lexend": "^4.5.15",
"@fortawesome/fontawesome-free": "^6.5.2", "@fortawesome/fontawesome-free": "^6.6.0",
"@github/hotkey": "^3.1.1", "@github/hotkey": "^3.1.1",
"@hotwired/stimulus": "^3.2.2", "@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo-rails": "^8.0.4", "@hotwired/turbo-rails": "^8.0.5",
"@melloware/coloris": "^0.24.0", "@melloware/coloris": "^0.24.0",
"@popperjs/core": "^2.11", "@popperjs/core": "^2.11",
"@rails/request.js": "^0.0.9", "@rails/request.js": "^0.0.9",
@ -21,10 +21,10 @@
"croppr": "^2.3.1", "croppr": "^2.3.1",
"i18n-js": "^4.0", "i18n-js": "^4.0",
"js-cookie": "2.2.1", "js-cookie": "2.2.1",
"sass": "^1.77.6", "sass": "^1.77.8",
"sweetalert": "1.1.3", "sweetalert": "1.1.3",
"toastify-js": "^1.12.0", "toastify-js": "^1.12.0",
"typescript": "^5.5.2", "typescript": "^5.5.4",
"yarn": "^1.22.22" "yarn": "^1.22.22"
}, },
"devDependencies": { "devDependencies": {

View File

@ -9,15 +9,15 @@ describe UseCase::DataExport::Answers, :data_export do
it "returns an empty set of answers" do it "returns an empty set of answers" do
expect(json_file("answers.json")).to eq( expect(json_file("answers.json")).to eq(
{ {
answers: [] answers: [],
} },
) )
end end
end end
context "when user has made some answer" do context "when user has made some answer" do
let!(:answer) do let!(:answer) do
travel_to(Time.utc(2022, 12, 10, 13, 37, 42)) { FactoryBot.create(:answer, user:, content: "Yay, data export!") } travel_to(Time.utc(2022, 12, 10, 13, 37, 42)) { FactoryBot.create(:answer, user:, content: "Yay, data export!", question: FactoryBot.build(:question, content: "awoo?")) }
end end
it "returns the answers as json" do it "returns the answers as json" do
@ -34,9 +34,280 @@ describe UseCase::DataExport::Answers, :data_export do
updated_at: "2022-12-10T13:37:42.000Z", updated_at: "2022-12-10T13:37:42.000Z",
smile_count: 0, smile_count: 0,
pinned_at: nil, pinned_at: nil,
related: {
question: {
id: answer.question.id,
anonymous: true,
generated: false,
direct: true,
author: nil,
content: "awoo?",
created_at: "2022-12-10T13:37:42.000Z",
},
comments: [],
},
} }
] ],
} },
)
end
end
context "when user has made plenty of answers to many different question types" do
let(:other_user) { FactoryBot.create(:user, screen_name: "TomTurbo") }
let!(:questions) do
[
travel_to(Time.utc(2024, 8, 6, 13, 12, 0)) { FactoryBot.create(:question, user: other_user, content: "Sieben Zwiebeln sieden Bienen auf Trieben", author_is_anonymous: false, direct: false) },
travel_to(Time.utc(2024, 8, 6, 13, 37, 42)) { FactoryBot.create(:question, user:, content: "Direct question from myself, to myself!", author_is_anonymous: false, direct: true) },
travel_to(Time.utc(2024, 8, 6, 13, 37, 42)) { FactoryBot.create(:question, user:, content: "The funny lasaganga in oven question", author_is_anonymous: true, direct: true, author_identifier: "justask") },
travel_to(Time.utc(2024, 8, 6, 13, 37, 42)) { FactoryBot.create(:question, user:, content: "Export is ready", author_is_anonymous: true, direct: true, author_identifier: "retrospring_exporter") },
travel_to(Time.utc(2024, 8, 6, 13, 37, 50)) { FactoryBot.create(:question, user:, content: "delete your account", author_is_anonymous: true, direct: true) }
]
end
let!(:answers) do
questions.map.with_index do |question, i|
travel_to(Time.utc(2024, 8, 6, 13, 37, i)) do
FactoryBot.create(:answer, user:, content: "Yay, data export!", question:)
end
end
end
let!(:answer_with_unknown_question) do
travel_to(Time.utc(2024, 8, 6, 13, 38, 0)) do
FactoryBot.create(:answer, user:, content: "aeeeugh???").tap { _1.update_column(:question_id, 666) } # rubocop:disable Rails/SkipsModelValidations
end
end
it "returns the answers as json" do
expect(json_file("answers.json")).to eq(
{
answers: [
{
id: answers[0].id,
content: "Yay, data export!",
question_id: questions[0].id,
comment_count: 0,
user_id: user.id,
created_at: "2024-08-06T13:37:00.000Z",
updated_at: "2024-08-06T13:37:00.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: {
id: questions[0].id,
anonymous: false,
generated: false,
direct: false,
author: {
id: other_user.id,
screen_name: "TomTurbo",
},
content: "Sieben Zwiebeln sieden Bienen auf Trieben",
created_at: "2024-08-06T13:12:00.000Z",
},
comments: [],
},
},
{
id: answers[1].id,
content: "Yay, data export!",
question_id: questions[1].id,
comment_count: 0,
user_id: user.id,
created_at: "2024-08-06T13:37:01.000Z",
updated_at: "2024-08-06T13:37:01.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: {
id: questions[1].id,
anonymous: false,
generated: false,
direct: true,
author: {
id: user.id,
screen_name: user.screen_name,
},
content: "Direct question from myself, to myself!",
created_at: "2024-08-06T13:37:42.000Z",
},
comments: [],
},
},
{
id: answers[2].id,
content: "Yay, data export!",
question_id: questions[2].id,
comment_count: 0,
user_id: user.id,
created_at: "2024-08-06T13:37:02.000Z",
updated_at: "2024-08-06T13:37:02.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: {
id: questions[2].id,
anonymous: true,
generated: true,
direct: true,
author: nil,
content: "The funny lasaganga in oven question",
created_at: "2024-08-06T13:37:42.000Z",
},
comments: [],
},
},
{
id: answers[3].id,
content: "Yay, data export!",
question_id: questions[3].id,
comment_count: 0,
user_id: user.id,
created_at: "2024-08-06T13:37:03.000Z",
updated_at: "2024-08-06T13:37:03.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: {
id: questions[3].id,
anonymous: true,
generated: true,
direct: true,
author: nil,
content: "Export is ready",
created_at: "2024-08-06T13:37:42.000Z",
},
comments: [],
},
},
{
id: answers[4].id,
content: "Yay, data export!",
question_id: questions[4].id,
comment_count: 0,
user_id: user.id,
created_at: "2024-08-06T13:37:04.000Z",
updated_at: "2024-08-06T13:37:04.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: {
id: questions[4].id,
anonymous: true,
generated: false,
direct: true,
author: nil,
content: "delete your account",
created_at: "2024-08-06T13:37:50.000Z",
},
comments: [],
},
},
{
id: answer_with_unknown_question.id,
content: "aeeeugh???",
question_id: 666,
comment_count: 0,
user_id: user.id,
created_at: "2024-08-06T13:38:00.000Z",
updated_at: "2024-08-06T13:38:00.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: nil,
comments: [],
},
}
],
},
)
end
end
context "when user has made an answers that received comments" do
let(:other_user) { FactoryBot.create(:user, screen_name: "TomTurbo") }
let!(:question) do
travel_to(Time.utc(2024, 8, 6, 13, 12, 0)) { FactoryBot.create(:question, user: other_user, content: "Sieben Zwiebeln sieden Bienen auf Trieben", author_is_anonymous: false, direct: false) }
end
let!(:answer) do
travel_to(Time.utc(2024, 8, 6, 13, 38, 0)) { FactoryBot.create(:answer, user:, content: "Interessante Frage", question:) }
end
let!(:comments) do
[
travel_to(Time.utc(2024, 8, 6, 13, 40, 0)) { FactoryBot.create(:comment, user:, answer:, content: "Kein Kommentar") },
travel_to(Time.utc(2024, 8, 6, 13, 42, 0)) { FactoryBot.create(:comment, user:, answer:, content: "Sehr witzig") },
travel_to(Time.utc(2024, 8, 6, 13, 41, 0)) { FactoryBot.create(:comment, user: other_user, answer:, content: "Jo eh.", smile_count: 1) }
]
end
it "returns the answers as json" do
expect(json_file("answers.json")).to eq(
{
answers: [
{
id: answer.id,
content: "Interessante Frage",
question_id: answer.question.id,
comment_count: 3,
user_id: user.id,
created_at: "2024-08-06T13:38:00.000Z",
updated_at: "2024-08-06T13:38:00.000Z",
smile_count: 0,
pinned_at: nil,
related: {
question: {
id: answer.question.id,
anonymous: false,
generated: false,
direct: false,
author: {
id: other_user.id,
screen_name: "TomTurbo",
},
content: "Sieben Zwiebeln sieden Bienen auf Trieben",
created_at: "2024-08-06T13:12:00.000Z",
},
comments: [
{
id: comments[0].id,
author: {
id: user.id,
screen_name: user.screen_name,
},
smile_count: 0,
content: "Kein Kommentar",
created_at: "2024-08-06T13:40:00.000Z",
},
{
id: comments[2].id,
author: {
id: other_user.id,
screen_name: other_user.screen_name,
},
smile_count: 1,
content: "Jo eh.",
created_at: "2024-08-06T13:41:00.000Z",
},
{
id: comments[1].id,
author: {
id: user.id,
screen_name: user.screen_name,
},
smile_count: 0,
content: "Sehr witzig",
created_at: "2024-08-06T13:42:00.000Z",
}
],
},
}
],
},
) )
end end
end end

View File

@ -2,7 +2,8 @@
require "rails_helper" require "rails_helper"
describe UseCase::DataExport::Theme, :data_export do describe UseCase::DataExport::Theme,
:data_export do
include ActiveSupport::Testing::TimeHelpers include ActiveSupport::Testing::TimeHelpers
context "when user doesn't have a theme" do context "when user doesn't have a theme" do
@ -13,8 +14,14 @@ describe UseCase::DataExport::Theme, :data_export do
context "when user has a theme" do context "when user has a theme" do
let!(:theme) do let!(:theme) do
travel_to(Time.utc(2022, 12, 10, 13, 37, 42)) do travel_to(Time.utc(2022,
FactoryBot.create(:theme, user:) 12,
10,
13,
37,
42,)) do
FactoryBot.create(:theme,
user:,)
end end
end end
@ -22,36 +29,32 @@ describe UseCase::DataExport::Theme, :data_export do
expect(json_file("theme.json")).to eq( expect(json_file("theme.json")).to eq(
{ {
theme: { theme: {
id: theme.id, background_color: "#c6c5eb",
user_id: user.id, body_text: "#333333",
primary_color: 9342168, danger_color: "#d98b8b",
primary_text: 16777215, danger_text: "#ffffff",
danger_color: 14257035, dark_color: "#666666",
danger_text: 16777215, dark_text: "#eeeeee",
success_color: 12573067, info_color: "#8bd9d9",
success_text: 16777215, info_text: "#ffffff",
warning_color: 14261899, input_color: "#f0edf4",
warning_text: 16777215, input_placeholder: "#6c757d",
info_color: 9165273, input_text: "#666666",
info_text: 16777215, light_color: "#f8f9fa",
dark_color: 6710886, light_text: "#000000",
dark_text: 15658734, muted_text: "#333333",
raised_background: 16777215, primary_color: "#8e8cd8",
raised_text: 3355443, primary_text: "#ffffff",
background_color: 13026795, raised_accent: "#f7f7f7",
body_text: 3355443, raised_accent_text: "#333333",
muted_text: 3355443, raised_background: "#ffffff",
created_at: "2022-12-10T13:37:42.000Z", raised_text: "#333333",
updated_at: "2022-12-10T13:37:42.000Z", success_color: "#bfd98b",
input_color: 15789556, success_text: "#ffffff",
input_text: 6710886, warning_color: "#d99e8b",
raised_accent: 16250871, warning_text: "#ffffff",
raised_accent_text: 3355443, },
light_color: 16316922, },
light_text: 0,
input_placeholder: 7107965
}
}
) )
end end
end end

View File

@ -195,10 +195,10 @@
resolved "https://registry.yarnpkg.com/@fontsource/lexend/-/lexend-4.5.15.tgz#ee033b850224d05b665d6661bf8d32c950f166bb" resolved "https://registry.yarnpkg.com/@fontsource/lexend/-/lexend-4.5.15.tgz#ee033b850224d05b665d6661bf8d32c950f166bb"
integrity sha512-6edLmDmte8pJWtQ1NIahcJq0iWlf6b0/JLwkd7WbDQ3C5tZWnxjvbP4RSklMv4MPzGjpuYuYnc+QANbjUws1oA== integrity sha512-6edLmDmte8pJWtQ1NIahcJq0iWlf6b0/JLwkd7WbDQ3C5tZWnxjvbP4RSklMv4MPzGjpuYuYnc+QANbjUws1oA==
"@fortawesome/fontawesome-free@^6.5.2": "@fortawesome/fontawesome-free@^6.6.0":
version "6.5.2" version "6.6.0"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.2.tgz#310fe90cb5a8dee9698833171b98e7835404293d" resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.6.0.tgz#0e984f0f2344ee513c185d87d77defac4c0c8224"
integrity sha512-hRILoInAx8GNT5IMkrtIt9blOdrqHOnPBH+k70aWUAqPZPgopb9G5EQJFpaBx/S8zp2fC+mPW349Bziuk1o28Q== integrity sha512-60G28ke/sXdtS9KZCpZSHHkCbdsOGEhIUGlwq6yhY74UpTiToIh8np7A8yphhM4BWsvNFtIvLpi4co+h9Mr9Ow==
"@github/hotkey@^3.1.1": "@github/hotkey@^3.1.1":
version "3.1.1" version "3.1.1"
@ -210,18 +210,18 @@
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608" resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608"
integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A== integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==
"@hotwired/turbo-rails@^8.0.4": "@hotwired/turbo-rails@^8.0.5":
version "8.0.4" version "8.0.5"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.4.tgz#d224f524a9e33fe687cec5d706054eb6fe13fa5b" resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-8.0.5.tgz#18c2f0e4f7f952307650308590edf5eb9544b0d3"
integrity sha512-GHCv5+B2VzYZZvMFpg/g9JLx/8pl/8chcubSB7T+Xn1zYOMqAKB6cT80vvWUzxdwfm/2KfaRysfDz+BmvtjFaw== integrity sha512-1A9G9u28IRAl0C57z8Ka3AhNPyJdwfOrbjr+ABZk2ZEUw2QO7cJ0pgs77asUj2E/tzn1PgrxrSVu24W+1Q5uBA==
dependencies: dependencies:
"@hotwired/turbo" "^8.0.4" "@hotwired/turbo" "^8.0.5"
"@rails/actioncable" "^7.0" "@rails/actioncable" "^7.0"
"@hotwired/turbo@^8.0.4": "@hotwired/turbo@^8.0.5":
version "8.0.4" version "8.0.5"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.4.tgz#5c5361c06a37cdf10dcba4223f1afd0ca1c75091" resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.5.tgz#abae6dad018a891e4286e87fa0959217e3866d5a"
integrity sha512-mlZEFUZrJnpfj+g/XeCWWuokvQyN68WvM78JM+0jfSFc98wegm259vCbC1zSllcspRwbgXK31ibehCy5PA78/Q== integrity sha512-TdZDA7fxVQ2ZycygvpnzjGPmFq4sO/E2QVg+2em/sJ3YTSsIWVEis8HmWlumz+c9DjWcUkcCuB+muF08TInpAQ==
"@humanwhocodes/config-array@^0.11.14": "@humanwhocodes/config-array@^0.11.14":
version "0.11.14" version "0.11.14"
@ -2262,10 +2262,10 @@ safe-regex-test@^1.0.0:
get-intrinsic "^1.1.3" get-intrinsic "^1.1.3"
is-regex "^1.1.4" is-regex "^1.1.4"
sass@^1.77.6: sass@^1.77.8:
version "1.77.6" version "1.77.8"
resolved "https://registry.yarnpkg.com/sass/-/sass-1.77.6.tgz#898845c1348078c2e6d1b64f9ee06b3f8bd489e4" resolved "https://registry.yarnpkg.com/sass/-/sass-1.77.8.tgz#9f18b449ea401759ef7ec1752a16373e296b52bd"
integrity sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q== integrity sha512-4UHg6prsrycW20fqLGPShtEvo/WyHRVRHwOP4DzkUrObWoWI05QBSfzU71TVB7PFaL104TwNaHpjlWXAZbQiNQ==
dependencies: dependencies:
chokidar ">=3.0.0 <4.0.0" chokidar ">=3.0.0 <4.0.0"
immutable "^4.0.0" immutable "^4.0.0"
@ -2665,10 +2665,10 @@ typed-array-length@^1.0.4:
for-each "^0.3.3" for-each "^0.3.3"
is-typed-array "^1.1.9" is-typed-array "^1.1.9"
typescript@^5.5.2: typescript@^5.5.4:
version "5.5.2" version "5.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.2.tgz#c26f023cb0054e657ce04f72583ea2d85f8d0507" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
integrity sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew== integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==
unbox-primitive@^1.0.2: unbox-primitive@^1.0.2:
version "1.0.2" version "1.0.2"