Skip to content

Commit

Permalink
Merge branch 'feat/update-decidim-0-28-0' into fix-rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuki-joto authored Mar 19, 2024
2 parents 74b3b6e + 10eabae commit de6dd40
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ARG RAILS_ENV="production"
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
BUNDLER_JOBS=4 \
BUNDLER_VERSION=2.2.33 \
BUNDLER_VERSION=2.3.7 \
APP_HOME=/app \
RAILS_ENV=${RAILS_ENV} \
RAILS_LOG_TO_STDOUT=true \
Expand Down
42 changes: 23 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ GEM
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
aws-eventstream (1.3.0)
aws-partitions (1.896.0)
aws-sdk-core (3.191.3)
aws-partitions (1.899.0)
aws-sdk-core (3.191.4)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.77.0)
aws-sdk-kms (1.78.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.143.0)
aws-sdk-s3 (1.146.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
Expand All @@ -104,14 +104,14 @@ GEM
base64 (0.2.0)
batch-loader (1.5.0)
bcrypt (3.1.20)
better_html (2.0.2)
better_html (2.1.0)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
smart_properties
bigdecimal (3.1.6)
bigdecimal (3.1.7)
bindex (0.8.1)
bootsnap (1.18.3)
msgpack (~> 1.2)
Expand Down Expand Up @@ -377,7 +377,7 @@ GEM
temple
erubi (1.12.0)
escape_utils (1.2.2)
excon (0.109.0)
excon (0.110.0)
execjs (2.9.1)
extended-markdown-filter (0.7.0)
html-pipeline (~> 2.9)
Expand All @@ -403,7 +403,7 @@ GEM
file_validators (3.0.0)
activemodel (>= 3.2)
mime-types (>= 1.0)
fog-aws (3.21.0)
fog-aws (3.22.0)
fog-core (~> 2.1)
fog-json (~> 1.1)
fog-xml (~> 0.1)
Expand Down Expand Up @@ -515,8 +515,7 @@ GEM
mime-types-data (3.2024.0305)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.22.2)
minitest (5.22.3)
msgpack (1.7.2)
multi_json (1.15.0)
multi_xml (0.6.0)
Expand All @@ -535,8 +534,11 @@ GEM
net-protocol
newrelic_rpm (9.7.1)
nio4r (2.7.0)
nokogiri (1.16.2)
mini_portile2 (~> 2.8.2)
nokogiri (1.16.3-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.3-x86_64-linux)
racc (~> 1.4)
oauth (1.1.0)
oauth-tty (~> 1.0, >= 1.0.1)
Expand Down Expand Up @@ -690,14 +692,14 @@ GEM
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.1)
rspec-rails (6.1.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.13.1)
Expand Down Expand Up @@ -849,7 +851,9 @@ GEM
rubyzip (>= 1.0.0)

PLATFORMS
ruby
aarch64-linux
arm64-darwin-23
x86_64-linux

DEPENDENCIES
aws-sdk-s3
Expand Down Expand Up @@ -888,4 +892,4 @@ RUBY VERSION
ruby 3.1.1p18

BUNDLED WITH
2.2.33
2.3.7
17 changes: 0 additions & 17 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@
exit 1
end

Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.args << "--headless=new"
options.args << "--no-sandbox"
options.args << if ENV["BIG_SCREEN_SIZE"].present?
"--window-size=1920,3000"
else
"--window-size=1920,1080"
end
options.args << "--ignore-certificate-errors" if ENV["TEST_SSL"]
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
capabilities: [options]
)
end

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
Expand Down
108 changes: 77 additions & 31 deletions spec/system/user_profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
let(:user) { create(:user, :confirmed) }

before do
I18n.default_locale = :en
Rails.application.config.i18n.default_locale = :en
Decidim.default_locale = :en
switch_to_host(user.organization.host)
end

after do
I18n.default_locale = :ja
Rails.application.config.i18n.default_locale = :ja
Decidim.default_locale = :ja
end

Expand All @@ -27,14 +27,18 @@
end
end

it "is not indexable by crawlers" do
expect(page.find('meta[name="robots"]', visible: false)[:content]).to eq("noindex")
end

it "shows the profile page when clicking on the menu" do
within ".wrapper" do
within "[data-content]" do
expect(page).to have_content(user.nickname)
end
end

it "adds a link to edit the profile" do
within ".wrapper" do
within "[data-content]" do
click_link "Edit profile"
end

Expand All @@ -47,10 +51,14 @@
visit decidim.profile_path(user.nickname)
end

it "is not indexable by crawlers" do
expect(page.find('meta[name="robots"]', visible: false)[:content]).to eq("noindex")
end

it "shows user name in the header, its nickname and a contact link" do
expect(page).to have_css("h1", text: user.name)
expect(page).to have_selector("h1", text: user.name)
expect(page).to have_content(user.nickname)
expect(page).to have_link("Contact")
expect(page).to have_link("Message")
end

it "does not show officialization stuff" do
Expand All @@ -61,7 +69,7 @@
let(:user) { create(:user, :officialized, officialized_as: nil) }

it "shows officialization status" do
expect(page).to have_content("This participant is publicly verified")
expect(page).to have_content("Official participant")
end
end

Expand All @@ -71,33 +79,44 @@
end

it "shows officialization status" do
click_link "Badges"
expect(page).to have_content("Major of Barcelona")
end

it "is not indexable by crawlers" do
click_link "Badges"
expect(page.find('meta[name="robots"]', visible: false)[:content]).to eq("noindex")
end
end

context "when displaying followers and following" do
let(:other_user) { create(:user, organization: user.organization) }
let(:user_to_follow) { create(:user, organization: user.organization) }
let(:user_group) { create(:user_group, organization: user.organization) }
let(:public_resource) { create(:dummy_resource, :published) }

before do
create(:follow, user:, followable: other_user)
create(:follow, user:, followable: user_to_follow)
create(:follow, user: other_user, followable: user)
create(:follow, user:, followable: user_group)
create(:follow, user:, followable: public_resource)
end

it "shows the number of followers and following" do
visit decidim.profile_path(user.nickname)
expect(page).to have_link("Followers 1")
expect(page).to have_link("Follows 3")
within(".profile__details") do
expect(page).to have_content("1 follower")
expect(page).to have_content("3 follows")
end
end

it "lists the followers" do
visit decidim.profile_path(user.nickname)
click_link "Followers"

expect(page).to have_content(other_user.name)
expect(page.find('meta[name="robots"]', visible: false)[:content]).to eq("noindex")
end

it "lists the followings" do
Expand All @@ -107,26 +126,66 @@
expect(page).to have_no_content("Some of the resources followed are not public.")
expect(page).to have_content(translated(other_user.name))
expect(page).to have_content(translated(user_to_follow.name))
expect(page).to have_content(translated(public_resource.title))
expect(page).to have_content(translated(user_group.name))
expect(page).to have_no_content(translated(public_resource.title))
expect(page.find('meta[name="robots"]', visible: false)[:content]).to eq("noindex")
end

context "when the user follows non public resources" do
let(:non_public_resource) { create(:dummy_resource) }
let(:non_public_resource) { create(:user, :blocked) }

before do
create(:follow, user:, followable: non_public_resource)
end

it "lists only the public followings" do
visit decidim.profile_path(user.nickname)
expect(page).to have_link("Follows 4")
within(".profile__details") do
expect(page).to have_content("4 follows")
end

click_link "Follows"
expect(page).to have_content("Some of the resources followed are not public.")
expect(page).to have_content(translated(other_user.name))
expect(page).to have_content(translated(user_to_follow.name))
expect(page).to have_content(translated(public_resource.title))
expect(page).to have_no_content(translated(non_public_resource.title))
expect(page).to have_content(translated(user_group.name))
expect(page).to have_no_content(translated(public_resource.title))
expect(page).to have_no_content(translated(non_public_resource.name))
end
end

context "when the user follows a blocked user" do
let(:blocked_user) { create(:user, :blocked) }

before do
create(:follow, user:, followable: blocked_user)
end

it "lists only the unblocked followings" do
visit decidim.profile_path(user.nickname)

click_link "Follows"
expect(page).to have_content("Some of the resources followed are not public.")
expect(page).to have_content(translated(other_user.name))
expect(page).to have_content(translated(user_to_follow.name))
expect(page).to have_content(translated(user_group.name))
expect(page).to have_no_content(translated(public_resource.title))
end
end

context "when the user is followed by a blocked user" do
let(:blocked_user) { create(:user, :blocked) }

before do
create(:follow, user: blocked_user, followable: user)
end

it "lists only the unblocked followers" do
visit decidim.profile_path(user.nickname)

click_link "Followers"
expect(page).to have_content(translated(other_user.name))
expect(page).to have_no_content(translated(blocked_user.name))
end
end
end
Expand All @@ -140,16 +199,8 @@
end

it "shows a badges tab" do
penfing "badges not use"
expect(page).to have_link("Badges")
end

it "shows a badges section on the sidebar" do
penfing "badges not use"
within ".profile--sidebar" do
expect(page).to have_css(".badge-container img[title^='Tests']")
end
end
end

context "when badges are disabled" do
Expand All @@ -159,13 +210,7 @@
end

it "shows a badges tab" do
expect(page).to have_no_link("Badges")
end

it "doesn't have a badges section on the sidebar" do
within ".profile--sidebar" do
expect(page).to have_no_content("Badges")
end
expect(page).not_to have_link("Badges")
end
end
end
Expand All @@ -184,6 +229,7 @@

expect(page).to have_content(accepted_user_group.name)
expect(page).to have_no_content(pending_user_group.name)
expect(page.find('meta[name="robots"]', visible: false)[:content]).to eq("noindex")
end

context "when user groups are disabled" do
Expand All @@ -199,7 +245,7 @@
before do
allow(Decidim.view_hooks)
.to receive(:render)
.with(a_kind_of(Symbol), a_kind_of(Decidim::ProfileSidebarCell))
.with(a_kind_of(Symbol), a_kind_of(Decidim::ProfileCell))
.and_return("Rendered from #{view_hook} view hook")

visit decidim.profile_path(user.nickname)
Expand All @@ -209,7 +255,7 @@
let(:view_hook) { :user_profile_bottom }

it "renders the view hook" do
expect(Decidim.view_hooks).to have_received(:render).with(:user_profile_bottom, a_kind_of(Decidim::ProfileSidebarCell))
expect(Decidim.view_hooks).to have_received(:render).with(:user_profile_bottom, a_kind_of(Decidim::ProfileCell))
expect(page).to have_content("Rendered from user_profile_bottom view hook")
end
end
Expand Down

0 comments on commit de6dd40

Please sign in to comment.