diff options
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | app/assets/javascripts/app/views/aspects_dropdown_view.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/app/views/publisher/aspect_selector_view.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/mobile/publisher.js | 70 | ||||
-rw-r--r-- | app/assets/stylesheets/_mixins.scss | 20 | ||||
-rw-r--r-- | app/assets/stylesheets/aspects.scss | 15 | ||||
-rw-r--r-- | app/assets/stylesheets/mobile/mobile.scss | 34 | ||||
-rw-r--r-- | app/assets/stylesheets/mobile/settings.scss | 4 | ||||
-rw-r--r-- | app/views/aspects/_aspect_dropdown.mobile.haml | 29 | ||||
-rw-r--r-- | app/views/publisher/_publisher.mobile.haml | 30 | ||||
-rw-r--r-- | docker/develop/Dockerfile | 2 | ||||
-rw-r--r-- | docker/develop/docker-compose.yml | 11 | ||||
-rwxr-xr-x | docker/develop/docker-entrypoint.sh | 27 | ||||
-rw-r--r-- | features/mobile/posts_from_main_page.feature | 22 | ||||
-rw-r--r-- | features/step_definitions/aspects_steps.rb | 17 | ||||
-rwxr-xr-x | script/diaspora-dev | 70 | ||||
-rw-r--r-- | spec/workers/check_birthday_spec.rb | 15 | ||||
-rw-r--r-- | spec/workers/queue_users_for_removal_spec.rb | 4 |
18 files changed, 277 insertions, 104 deletions
diff --git a/Changelog.md b/Changelog.md index 54a27b64c..60c334f4f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -62,6 +62,7 @@ We use yarn to install the frontend dependencies now, so you need to have that i * Add support for directly paste images to upload them [#8237](https://github.com/diaspora/diaspora/pull/8237) * Add support for webp images and convert new png/jpg to webp to save space and bandwidth [#8358](https://github.com/diaspora/diaspora/pull/8358) * Show total and active pods count in the pods list for podmins [#8383](https://github.com/diaspora/diaspora/pull/8383) +* Allow to select multiple aspects when posting on mobile [#8217](https://github.com/diaspora/diaspora/pull/8217) # 0.7.18.1 diff --git a/app/assets/javascripts/app/views/aspects_dropdown_view.js b/app/assets/javascripts/app/views/aspects_dropdown_view.js index ae9d7d897..df7c4d690 100644 --- a/app/assets/javascripts/app/views/aspects_dropdown_view.js +++ b/app/assets/javascripts/app/views/aspects_dropdown_view.js @@ -27,16 +27,14 @@ app.views.AspectsDropdown = app.views.Base.extend({ }, // change class and text of the dropdown button - _updateButton: function(inAspectClass) { - var button = this.$('.btn.dropdown-toggle'), + _updateButton: function() { + let button = this.$(".btn.dropdown-toggle"), selectedAspects = this.$(".dropdown-menu > li.selected").length, buttonText; if (selectedAspects === 0) { - button.removeClass(inAspectClass).addClass('btn-default'); buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects"); } else { - button.removeClass('btn-default').addClass(inAspectClass); if (selectedAspects === 1) { buttonText = this.$(".dropdown-menu > li.selected .text").first().text(); } else { diff --git a/app/assets/javascripts/app/views/publisher/aspect_selector_view.js b/app/assets/javascripts/app/views/publisher/aspect_selector_view.js index 5e65e63ec..40e9e51dd 100644 --- a/app/assets/javascripts/app/views/publisher/aspect_selector_view.js +++ b/app/assets/javascripts/app/views/publisher/aspect_selector_view.js @@ -31,7 +31,7 @@ app.views.PublisherAspectSelector = app.views.AspectsDropdown.extend({ } this._updateSelectedAspectIds(); - this._updateButton('btn-default'); + this._updateButton(); // update the globe or lock icon var icon = this.$("#visibility-icon"); @@ -48,7 +48,7 @@ app.views.PublisherAspectSelector = app.views.AspectsDropdown.extend({ updateAspectsSelector: function(ids){ this._selectAspects(ids); this._updateSelectedAspectIds(); - this._updateButton('btn-default'); + this._updateButton(); }, // take care of the form fields that will indicate the selected aspects diff --git a/app/assets/javascripts/mobile/publisher.js b/app/assets/javascripts/mobile/publisher.js index 9bac0f0bf..b7d566452 100644 --- a/app/assets/javascripts/mobile/publisher.js +++ b/app/assets/javascripts/mobile/publisher.js @@ -48,4 +48,74 @@ $(document).ready(function(){ }); new Diaspora.MarkdownEditor("#status_message_text"); + + $(".dropdown-menu > li").bind("tap click", function(evt) { + let target = $(evt.target).closest("li"); + + // visually toggle the aspect selection + if (target.is(".radio")) { + _toggleRadio(target); + } else if (target.is(".aspect-selector")) { + // don't close the dropdown + evt.stopPropagation(); + _toggleCheckbox(target); + } + + _updateSelectedAspectIds(); + _updateButton(); + + // update the globe or lock icon + let icon = $("#visibility-icon"); + if (target.find(".text").text().trim() === Diaspora.I18n.t("stream.public")) { + icon.removeClass("entypo-lock"); + icon.addClass("entypo-globe"); + } else { + icon.removeClass("entypo-globe"); + icon.addClass("entypo-lock"); + } + }); + + function _toggleRadio(target) { + $(".dropdown-menu > li").removeClass("selected"); + target.toggleClass("selected"); + } + + function _toggleCheckbox(target) { + $(".dropdown-menu > li.radio").removeClass("selected"); + target.toggleClass("selected"); + } + + // take care of the form fields that will indicate the selected aspects + function _updateSelectedAspectIds() { + let form = $("#new_status_message"); + + // remove previous selection + form.find('input[name="aspect_ids[]"]').remove(); + + // create fields for current selection + form.find(".dropdown-menu > li.selected").each(function() { + let uid = _.uniqueId("aspect_ids_"); + let id = $(this).data("aspect_id"); + form.append('<input id="' + uid + '" name="aspect_ids[]" type="hidden" value="' + id + '">'); + }); + } + + // change class and text of the dropdown button + function _updateButton() { + let button = $(".btn.dropdown-toggle"), + selectedAspects = $(".dropdown-menu > li.selected").length, + buttonText; + + switch (selectedAspects) { + case 0: + buttonText = Diaspora.I18n.t("aspect_dropdown.select_aspects"); + break; + case 1: + buttonText = $(".dropdown-menu > li.selected .text").first().text(); + break; + default: + buttonText = Diaspora.I18n.t("aspect_dropdown.toggle", {count: selectedAspects.toString()}); + } + button.find(".text").text(buttonText); + } }); diff --git a/app/assets/stylesheets/_mixins.scss b/app/assets/stylesheets/_mixins.scss index 17523f226..1f3dfb1b6 100644 --- a/app/assets/stylesheets/_mixins.scss +++ b/app/assets/stylesheets/_mixins.scss @@ -1,7 +1,7 @@ /* Mixin file for sass. Here is where we define our variables and browser compatability functions used in all scss/sass files */ -/* Transision defaults */ +// Transition defaults $speed: 0.1s; $easing: linear; @@ -138,3 +138,21 @@ $default-border-radius: 3px; .glyphicon-ok { display: none;} } } + +@mixin aspect-dropdown-link($anchor-size) { + $link-text-color: #333; + + a { + cursor: pointer; + padding-left: 10px; + + .text { + color: $link-text-color; + font-size: $anchor-size; + } + + &:hover { + background: $background-grey; + } + } +} diff --git a/app/assets/stylesheets/aspects.scss b/app/assets/stylesheets/aspects.scss index dce9a065d..5d79f11a8 100644 --- a/app/assets/stylesheets/aspects.scss +++ b/app/assets/stylesheets/aspects.scss @@ -1,26 +1,19 @@ +@import 'mixins'; + .aspect-dropdown { li { @include selectable-list; + @include aspect-dropdown-link(1em); .status_indicator { width: 19px; height: 14px; display: inline-block; } - - a { - .text { - color: #333333; - } - &:hover { - background: $background-grey; - } - cursor: pointer; - padding-left: 10px; - } } } + .aspect-membership { max-height: 300px; overflow: auto; diff --git a/app/assets/stylesheets/mobile/mobile.scss b/app/assets/stylesheets/mobile/mobile.scss index 63e0777e4..2a88055e6 100644 --- a/app/assets/stylesheets/mobile/mobile.scss +++ b/app/assets/stylesheets/mobile/mobile.scss @@ -658,40 +658,44 @@ form#update_profile_form { .submit_block { margin-bottom: 20px; } } -select#user_language, select#user_color_theme, #user_auto_follow_back_aspect_id, #aspect_ids_ { - padding: 3px; -} - .hero-unit-mobile { - padding: 10px; - font-size: 14px; - line-height: 18px; - color: inherit; background-color: $background-grey; border-radius: 10px; + color: inherit; + font-size: 14px; + line-height: 18px; + padding: 10px; } .search-mobile { - text-align: center; padding-top: 30px; + text-align: center; } input#q.search { margin-bottom: 20px; } -select#aspect_ids_ { - width: auto !important; - float: right; - margin: 0px; +.aspect-dropdown { + li { + @include selectable-list; + @include aspect-dropdown-link(128%); + + .status-indicator { + display: inline-block; + height: 14px; + width: 19px; + } + } } #file-upload-spinner { - top: 0px; + top: 0; } -#publisher_mobile { +#publisher-mobile { float: right; + margin-left: 5px; } #file-upload-publisher { diff --git a/app/assets/stylesheets/mobile/settings.scss b/app/assets/stylesheets/mobile/settings.scss index 9c959beb4..0880462d3 100644 --- a/app/assets/stylesheets/mobile/settings.scss +++ b/app/assets/stylesheets/mobile/settings.scss @@ -56,4 +56,8 @@ width: 50px; } } + + select { + padding: 3px; + } } diff --git a/app/views/aspects/_aspect_dropdown.mobile.haml b/app/views/aspects/_aspect_dropdown.mobile.haml new file mode 100644 index 000000000..222e6f002 --- /dev/null +++ b/app/views/aspects/_aspect_dropdown.mobile.haml @@ -0,0 +1,29 @@ +-# Note: all_aspects is a global in the ApplicationController + +.btn-group.aspect-dropdown + %button.btn.btn-default.dropdown-toggle{data: {toggle: "dropdown"}} + %span.text + = t("all_aspects") + %span.caret + %ul.dropdown-menu.pull-right{unSelectable: "on"} + + %li.public.radio{"data-aspect_id" => "public"} + %a + %span.status-indicator + %i.glyphicon.glyphicon-ok + %span.text + = t("public") + %li.all-aspects.radio.selected{"data-aspect_id" => "all_aspects"} + %a + %span.status-indicator + %i.glyphicon.glyphicon-ok + %span.text + = t("all_aspects") + %li.divider + - all_aspects.each do |aspect| + %li.aspect-selector{"data-aspect_id" => aspect.id} + %a + %span.status-indicator + %i.glyphicon.glyphicon-ok + %span.text + = aspect.name diff --git a/app/views/publisher/_publisher.mobile.haml b/app/views/publisher/_publisher.mobile.haml index e031c1027..da881fa25 100644 --- a/app/views/publisher/_publisher.mobile.haml +++ b/app/views/publisher/_publisher.mobile.haml @@ -8,6 +8,7 @@ = status.hidden_field :provider_display_name, value: 'mobile' = status.text_area :text, placeholder: t('shared.publisher.whats_on_your_mind'), rows: 4, autofocus: "autofocus", class: "form-control" + = hidden_field_tag "aspect_ids[]", "all_aspects" .form-group %span#publisher-service-icons - if current_user.services @@ -16,27 +17,18 @@ title: service.provider.titleize, class: "service_icon dim", id: "#{service.provider}", maxchar: "#{service.class::MAX_CHARACTERS}" - %select{id: "aspect_ids_", class: "form-control", name: "aspect_ids[]"} - %option{value: 'public'} - = t('public') - - %option{value: 'all_aspects', selected: true} - = t('all_aspects') - - - current_user.aspects.each do |aspect| - %option{value: aspect.id} - = "ยท #{aspect.name}" - .clear #publisher-textarea-wrapper %ul#photodropzone #fileInfo-publisher - - #file-upload-publisher{class: "btn btn-default"} - %i.entypo-camera.middle - #publisher_mobile - = submit_tag t("shared.publisher.share"), - class: "btn btn-primary", - id: "submit_new_message", - data: {"disable-with" => t("shared.publisher.posting")} .clearfix + .btn-toolbar + .pull-left#file-upload-publisher + %i.entypo-camera.middle + .pull-right#publisher-mobile + = submit_tag t("shared.publisher.share"), + class: "btn btn-primary", + id: "submit_new_message", + data: {"disable-with" => t("shared.publisher.posting")} + .pull-right + = render partial: "aspects/aspect_dropdown" diff --git a/docker/develop/Dockerfile b/docker/develop/Dockerfile index 6f9db164c..3b04347c6 100644 --- a/docker/develop/Dockerfile +++ b/docker/develop/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7-slim-bullseye +FROM amd64/ruby:2.7-slim-bullseye RUN DEBIAN_FRONTEND=noninteractive \ apt-get update && \ diff --git a/docker/develop/docker-compose.yml b/docker/develop/docker-compose.yml index b2d5e9d55..8b41d6ed7 100644 --- a/docker/develop/docker-compose.yml +++ b/docker/develop/docker-compose.yml @@ -1,6 +1,7 @@ version: "3.4" volumes: + redis_data: postgresql_data: mysql_data: dia_data_tmp: @@ -21,8 +22,18 @@ services: - dia_data_bundle:/diaspora/vendor/bundle ports: - ${DIASPORA_DOCKER_PORT:-3000}:3000 + environment: + - ENVIRONMENT_REDIS=redis://redis + - SERVER_LISTEN=tcp://0.0.0.0:3000 depends_on: - "${DIASPORA_DOCKER_DB}" + - redis + + redis: + image: redis:7 + command: redis-server --save 60 1 --loglevel warning + volumes: + - redis_data:/data postgresql: image: postgres:10.3 diff --git a/docker/develop/docker-entrypoint.sh b/docker/develop/docker-entrypoint.sh index 19f9cdb57..a212b7f3a 100755 --- a/docker/develop/docker-entrypoint.sh +++ b/docker/develop/docker-entrypoint.sh @@ -18,18 +18,11 @@ chown -R $HOST_UID:$HOST_GID /home/diaspora mkdir -p /diaspora/tmp/pids chown $HOST_UID:$HOST_GID /diaspora/tmp /diaspora/tmp/pids /diaspora/vendor/bundle -# ----- Wait for DB ---- -if [ -z $DIA_NODB ] || [ ! $DIA_NODB -eq 1 ]; then - if grep -qFx " <<: *postgresql" /diaspora/config/database.yml; then - host=postgresql - port=5432 - else - host=mysql - port=3306 - fi - - c=0 +function wait_for_port() { + local host=$1 + local port=$2 + local c=0 trap '{ exit 1; }' INT while ! (< /dev/tcp/${host}/${port}) 2>/dev/null; do printf "\rWaiting for $host:$port to become ready ... ${c}s" @@ -40,6 +33,18 @@ if [ -z $DIA_NODB ] || [ ! $DIA_NODB -eq 1 ]; then if [ ! -z $c ]; then printf "\rWaiting for $host:$port to become ready ... done (${c}s)\n" fi +} + +if [ -z $DIA_NODB ] || [ ! $DIA_NODB -eq 1 ]; then + # ----- Wait for DB ----- + if grep -qFx " <<: *postgresql" /diaspora/config/database.yml; then + wait_for_port postgresql 5432 + else + wait_for_port mysql 3306 + fi + + # ----- Wait for Redis ----- + wait_for_port redis 6379 fi cd /diaspora diff --git a/features/mobile/posts_from_main_page.feature b/features/mobile/posts_from_main_page.feature index d8aad60b9..90b9e6d88 100644 --- a/features/mobile/posts_from_main_page.feature +++ b/features/mobile/posts_from_main_page.feature @@ -21,13 +21,31 @@ Feature: posting from the mobile main page Scenario: post and delete some text Given I visit the mobile publisher page And I append "I am eating yogurt" to the publisher - And I select "Unicorns" from "aspect_ids_" - And I press "Share" + And I press the aspect dropdown + And I toggle the aspect "Unicorns" + And I press the share button When I go to the stream page Then I should see "I am eating yogurt" When I confirm the alert after I click on selector "a.remove" Then I should not see "I am eating yogurt" + Scenario: post in multiple aspects + Given I visit the mobile publisher page + And I append "I am selecting my friends" to the publisher + And I press the aspect dropdown + And I toggle the aspect "PostingTo" + And I toggle the aspect "Unicorns" + And I press the share button + + When I visit the stream with aspect "PostingTo" + Then I should see "I am selecting my friends" + + When I visit the stream with aspect "Unicorns" + Then I should see "I am selecting my friends" + + When I visit the stream with aspect "NotPostingThingsHere" + Then I should not see "I am selecting my friends" + Scenario: post a photo without text Given I visit the mobile publisher page When I attach the file "spec/fixtures/button.png" to hidden "qqfile" within "#file-upload-publisher" diff --git a/features/step_definitions/aspects_steps.rb b/features/step_definitions/aspects_steps.rb index 4a5c9e577..e025200d1 100644 --- a/features/step_definitions/aspects_steps.rb +++ b/features/step_definitions/aspects_steps.rb @@ -2,7 +2,11 @@ module AspectCukeHelpers def click_aspect_dropdown - find(".aspect-dropdown .dropdown-toggle").trigger "click" + find(".aspect-dropdown > .dropdown-toggle").click + end + + def click_share_button + find("#submit_new_message").trigger "click" end def toggle_aspect(a_name) @@ -112,6 +116,17 @@ When /^I press the aspect dropdown$/ do click_aspect_dropdown end +When /^I press the share button$/ do + # There were issues 'clicking' the share button on mobile + click_share_button +end + +When /^I visit the stream with aspect "([^"]*)"$/ do |aspect_name| + # In mobile view aspects are single anchors + a_id = @me.aspects.where(name: aspect_name).pick(:id) + visit("/aspects?a_ids[]=#{a_id}") +end + When /^(.*) in the aspect creation modal$/ do |action| within("#newAspectModal") do step action diff --git a/script/diaspora-dev b/script/diaspora-dev index 067f8c978..1c5eace04 100755 --- a/script/diaspora-dev +++ b/script/diaspora-dev @@ -44,6 +44,10 @@ print_usage() { print_usage_header "clean [options]" \ " --config Delete configuration files as well" ;; + docker-compose) + echo; echo "Run docker-compose commands with the required environment variables" + print_usage_header "docker-compose [options]" + ;; # test & development cucumber) echo; echo "Run cucumber tests" @@ -136,30 +140,31 @@ print_usage_full() { print_usage_header "$SCRIPT_NAME COMMAND" echo echo "Management Commands:" - echo " setup Prepare diaspora* to run for development" - echo " start Start diaspora*" - echo " stop Stop diaspora*" - echo " restart Restart of diaspora*" - echo " logs Follow log output of diaspora*" - echo " status Show current instance status of diaspora*" - echo " clean Reset diaspora* instance" + echo " setup Prepare diaspora* to run for development" + echo " start Start diaspora*" + echo " stop Stop diaspora*" + echo " restart Restart of diaspora*" + echo " logs Follow log output of diaspora*" + echo " status Show current instance status of diaspora*" + echo " clean Reset diaspora* instance" + echo " docker-compose Run docker-compose commands" echo echo "Test and Development Commands:" - echo " cucumber Run cucumber tests" - echo " jasmine Run jasmine tests" - echo " rspec Run rspec tests" - echo " pronto Run pronto checks" - echo " migrate Execute pending migrations" + echo " cucumber Run cucumber tests" + echo " jasmine Run jasmine tests" + echo " rspec Run rspec tests" + echo " pronto Run pronto checks" + echo " migrate Execute pending migrations" echo echo "Misc. Commands:" - echo " build Build basic diaspora* environment" - echo " bundle (Re-)Install gems for diaspora*" - echo " yarn (Re-)Install frontend dependencies for diaspora*" - echo " config Configure diaspora*" - echo " exec Execute a command in the run environment (advanced)" - echo " help Show help for commands" - echo " setup-rails Prepare diaspora* development environment (install dependencies, migrate db)" - echo " setup-tests Prepare diaspora* test environment" + echo " build Build basic diaspora* environment" + echo " bundle (Re-)Install gems for diaspora*" + echo " yarn (Re-)Install frontend dependencies for diaspora*" + echo " config Configure diaspora*" + echo " exec Execute a command in the run environment (advanced)" + echo " help Show help for commands" + echo " setup-rails Prepare diaspora* development environment (install dependencies, migrate db)" + echo " setup-tests Prepare diaspora* test environment" echo echo "Run '$SCRIPT_NAME help COMMAND' for more information on a command." } @@ -208,6 +213,11 @@ dia_is_db_running() { dia_docker_compose ps --services --filter status=running | grep -qx $DIASPORA_DOCKER_DB } +dia_is_redis_running() { + # Check if redis container is running + dia_docker_compose ps --services --filter status=running | grep -qx redis +} + dia_get_db() { # Get currently configured or assumed db type grep -q '^ <<: \*mysql' "$DIASPORA_CONFIG_DB" 2>/dev/null && echo mysql || echo postgresql @@ -324,13 +334,14 @@ dia_exec() { # Use a running container dia_docker_compose exec $detach diaspora /exec-entrypoint.sh "$@" else - if ! dia_is_db_running; then not_running=1; fi + # stop db/redis if it was not running before + if ! dia_is_db_running; then stopdb="dia_docker_compose stop $DIASPORA_DOCKER_DB"; fi + if ! dia_is_redis_running; then stopredis="dia_docker_compose stop redis"; fi # Start a new container echo "No running instance found, starting new one for command execution ..." dia_docker_compose run --rm $detach --service-ports diaspora "$@" - if [ ! -z $not_running ]; then - dia_docker_compose stop $DIASPORA_DOCKER_DB - fi + $stopdb + $stopredis fi } @@ -449,24 +460,28 @@ dia_setup() { dia_setup_rails() { # Prepare rails, install dependencies, migrate database, ... - # stop db if it was not running before echo "Setting up environment for tests ..." + # stop db/redis if it was not running before if ! dia_is_db_running; then stopdb="dia_docker_compose stop $DIASPORA_DOCKER_DB"; fi + if ! dia_is_redis_running; then stopredis="dia_docker_compose stop redis"; fi dia_docker_compose run --rm diaspora bin/setup $stopdb + $stopredis } dia_setup_tests() { # Prepare all possible tests - # stop db if it was not running before echo "Setting up environment for tests ..." + # stop db/redis if it was not running before if ! dia_is_db_running; then stopdb="dia_docker_compose stop $DIASPORA_DOCKER_DB"; fi + if ! dia_is_redis_running; then stopredis="dia_docker_compose stop redis"; fi dia_docker_compose run \ --rm \ -e RAILS_ENV=test \ diaspora \ bin/rake db:create db:migrate tests:generate_fixtures assets:generate_error_pages $stopdb + $stopredis } dia_start() { @@ -546,6 +561,9 @@ case "$dia_command" in cucumber) dia_cucumber "$@" ;; + docker-compose) + dia_docker_compose "$@" + ;; exec) dia_exec "$@" ;; diff --git a/spec/workers/check_birthday_spec.rb b/spec/workers/check_birthday_spec.rb index 1f026ab61..7f8573b79 100644 --- a/spec/workers/check_birthday_spec.rb +++ b/spec/workers/check_birthday_spec.rb @@ -6,15 +6,10 @@ describe Workers::CheckBirthday do let(:contact2) { eve.contact_for(bob.person) } before do - Timecop.freeze(Time.zone.local(1999, 9, 9)) - birthday_profile.update(birthday: "1990-09-09") + birthday_profile.update(birthday: Time.zone.now) allow(Notifications::ContactsBirthday).to receive(:notify) end - after do - Timecop.return - end - it "calls notify method for the birthday person's contacts" do Workers::CheckBirthday.new.perform expect(Notifications::ContactsBirthday).to have_received(:notify).with(contact1, []) @@ -24,13 +19,15 @@ describe Workers::CheckBirthday do it "does nothing if the birthday does not exist" do birthday_profile.update(birthday: nil) Workers::CheckBirthday.new.perform - expect(Notifications::ContactsBirthday).not_to have_received(:notify) + expect(Notifications::ContactsBirthday).not_to have_received(:notify).with(contact1, []) + expect(Notifications::ContactsBirthday).not_to have_received(:notify).with(contact2, []) end it "does nothing if the person's birthday is not today" do - birthday_profile.update(birthday: "1988-04-15") + birthday_profile.update(birthday: Time.zone.now - 1.day) Workers::CheckBirthday.new.perform - expect(Notifications::ContactsBirthday).not_to have_received(:notify) + expect(Notifications::ContactsBirthday).not_to have_received(:notify).with(contact1, []) + expect(Notifications::ContactsBirthday).not_to have_received(:notify).with(contact2, []) end it "does not call notify method if a person is not a contact of the birthday person" do diff --git a/spec/workers/queue_users_for_removal_spec.rb b/spec/workers/queue_users_for_removal_spec.rb index 8b9707104..2ddc4262b 100644 --- a/spec/workers/queue_users_for_removal_spec.rb +++ b/spec/workers/queue_users_for_removal_spec.rb @@ -22,7 +22,7 @@ describe Workers::QueueUsersForRemoval do user = FactoryBot.create(:user, last_seen: Time.zone.now - 732.days, sign_in_count: 5) Workers::QueueUsersForRemoval.new.perform user.reload - expect(user.remove_after.to_i).to eq(removal_date.utc.to_i) + expect(user.remove_after.to_i).to be_within(1.day).of(removal_date.utc.to_i) expect(ActionMailer::Base.deliveries.count).to eq(1) end @@ -31,7 +31,7 @@ describe Workers::QueueUsersForRemoval do user = FactoryBot.create(:user, last_seen: Time.zone.now - 735.days, sign_in_count: 0) Workers::QueueUsersForRemoval.new.perform user.reload - expect(user.remove_after.to_i).to eq(removal_date.utc.to_i) + expect(user.remove_after.to_i).to be_within(1.day).of(removal_date.utc.to_i) expect(ActionMailer::Base.deliveries.count).to eq(0) # no email sent end |