Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 ruby:3.0.3-slim-buster
FROM --platform=linux/amd64 ruby:3.0.3-bullseye

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
Expand Down Expand Up @@ -29,27 +29,27 @@ RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /
&& rm -rf /var/lib/apt/lists/*

# add repository for Node.js in the LTS version
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -

RUN apt-get install -y --no-install-recommends > /dev/null \
nodejs=* \
qt5-default=* \
libqt5webkit5-dev=* \
gstreamer1.0-plugins-base=* \
libappindicator3-1=* \
gstreamer1.0-tools=* \
qtdeclarative5-dev=* \
fonts-liberation=* \
gstreamer1.0-x=* \
libasound2=* \
libnspr4=* \
libnss3=* \
libxss1=* \
libxtst6=* \
xdg-utils=* \
qtdeclarative5-dev=* \
fonts-liberation=* \
gstreamer1.0-x=* \
nodejs \
qtbase5-dev \
libqt5webkit5-dev \
gstreamer1.0-plugins-base \
libappindicator3-1 \
gstreamer1.0-tools \
qtdeclarative5-dev \
fonts-liberation \
gstreamer1.0-x \
libasound2 \
libnspr4 \
libnss3 \
libxss1 \
libxtst6 \
xdg-utils \
qtdeclarative5-dev \
fonts-liberation \
gstreamer1.0-x \
wkhtmltopdf \
libxslt1-dev \
libxml2-dev \
Expand Down
17 changes: 17 additions & 0 deletions app/controllers/admin/domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def update

if @domain.update(dp)
flash[:notice] = I18n.t('domain_updated')
inform_registrar_about_status_changes
redirect_to [:admin, @domain]
else
@domain.reload
Expand Down Expand Up @@ -111,6 +112,22 @@ def domain_params
end
end

def inform_registrar_about_status_changes
return unless @domain.saved_change_to_statuses?

old_statuses, new_statuses = @domain.saved_change_to_statuses
removed = old_statuses - new_statuses
added = new_statuses - old_statuses

added.each do |status|
@domain.registrar.notifications.create!(text: "#{status} set on domain #{@domain.name}")
end

removed.each do |status|
@domain.registrar.notifications.create!(text: "#{status} is cancelled on domain #{@domain.name}")
end
end

def build_associations
@server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) }
@server_statuses = [nil] if @server_statuses.empty?
Expand Down
26 changes: 26 additions & 0 deletions test/integration/domain/domains_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'test_helper'

class DomainsControllerTest < ApplicationIntegrationTest

def setup
@domain = domains(:shop)
@admin = users(:admin)
sign_in @admin
end

def test_inform_registrar_about_status_changes
patch admin_domain_path(domains(:shop)), params: { domain: { statuses: [DomainStatus::PENDING_UPDATE,] } }

# Status OK is removed because, if:
# (statuses.length > 1) || !valid?
# then status OK is removed by manage_automatic_statuses method in domain.rb
notifications = domains(:shop).registrar.notifications.last(2)
assert_equal "#{DomainStatus::PENDING_UPDATE} set on domain #{domains(:shop).name}", notifications.first.text
assert_equal "#{DomainStatus::OK} is cancelled on domain #{domains(:shop).name}", notifications.last.text

patch admin_domain_path(domains(:shop)), params: { domain: { statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION] } }
notifications = domains(:shop).registrar.notifications.last(2)
assert_equal "#{DomainStatus::PENDING_DELETE_CONFIRMATION} set on domain #{domains(:shop).name}", notifications.first.text
assert_equal "#{DomainStatus::PENDING_UPDATE} is cancelled on domain #{domains(:shop).name}", notifications.last.text
end
end
Loading