\ No newline at end of file
diff --git a/app/views/invitations/show.html.erb b/app/views/invitations/show.html.erb
index d3d18be..705aa6c 100644
--- a/app/views/invitations/show.html.erb
+++ b/app/views/invitations/show.html.erb
@@ -16,7 +16,7 @@
<% if @invitation.pending? %>
\ No newline at end of file
diff --git a/app/views/likes_mailer/notify_like.html.erb b/app/views/likes_mailer/notify_like.html.erb
index 9195aa9..e59dbbb 100644
--- a/app/views/likes_mailer/notify_like.html.erb
+++ b/app/views/likes_mailer/notify_like.html.erb
@@ -6,12 +6,12 @@
<%= t('.comment_likes', like_count: @comment_likes.count) if @comment_likes.any? %>
<%= t('.regards') %>,
-Portfoliorrr
\ No newline at end of file
+
Portfoliorrr
\ No newline at end of file
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb
index 60ccb79..b1c03b0 100644
--- a/app/views/posts/show.html.erb
+++ b/app/views/posts/show.html.erb
@@ -44,9 +44,11 @@
<% end %>
-
+ <% if @post.edited_at.present? %>
+
+ <% end %>
<% post.tags.each do |tag| %>
diff --git a/config/application.rb b/config/application.rb
index ff33ae3..b2e37ee 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -38,5 +38,11 @@ class Application < Rails::Application
# Don't generate system test files.
config.generators.system_tests = nil
+
+ # ColaBora API configurations
+ config.colabora_api_v1 = config_for(:colabora_api_v1)
+
+ # Portfoliorrr API configurations
+ config.portfoliorrr_api_v1 = config_for(:portfoliorrr_api_v1)
end
end
diff --git a/config/colabora_api_v1.yml b/config/colabora_api_v1.yml
new file mode 100644
index 0000000..9168649
--- /dev/null
+++ b/config/colabora_api_v1.yml
@@ -0,0 +1,9 @@
+development:
+ base_url: 'http://localhost:3000'
+ projects_url: '/api/v1/projects'
+ proposals_url: '/api/v1/proposals'
+
+test:
+ base_url: 'http://localhost:3000'
+ projects_url: '/api/v1/projects'
+ proposals_url: '/api/v1/proposals'
\ No newline at end of file
diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb
new file mode 100644
index 0000000..5852b58
--- /dev/null
+++ b/config/initializers/friendly_id.rb
@@ -0,0 +1,107 @@
+# FriendlyId Global Configuration
+#
+# Use this to set up shared configuration options for your entire application.
+# Any of the configuration options shown here can also be applied to single
+# models by passing arguments to the `friendly_id` class method or defining
+# methods in your model.
+#
+# To learn more, check out the guide:
+#
+# http://norman.github.io/friendly_id/file.Guide.html
+
+FriendlyId.defaults do |config|
+ # ## Reserved Words
+ #
+ # Some words could conflict with Rails's routes when used as slugs, or are
+ # undesirable to allow as slugs. Edit this list as needed for your app.
+ config.use :reserved
+
+ config.reserved_words = %w[new edit index session login logout users admin
+ stylesheets assets javascripts images]
+
+ # This adds an option to treat reserved words as conflicts rather than exceptions.
+ # When there is no good candidate, a UUID will be appended, matching the existing
+ # conflict behavior.
+
+ # config.treat_reserved_as_conflict = true
+
+ # ## Friendly Finders
+ #
+ # Uncomment this to use friendly finders in all models. By default, if
+ # you wish to find a record by its friendly id, you must do:
+ #
+ # MyModel.friendly.find('foo')
+ #
+ # If you uncomment this, you can do:
+ #
+ # MyModel.find('foo')
+ #
+ # This is significantly more convenient but may not be appropriate for
+ # all applications, so you must explicitly opt-in to this behavior. You can
+ # always also configure it on a per-model basis if you prefer.
+ #
+ # Something else to consider is that using the :finders addon boosts
+ # performance because it will avoid Rails-internal code that makes runtime
+ # calls to `Module.extend`.
+ #
+ # config.use :finders
+ #
+ # ## Slugs
+ #
+ # Most applications will use the :slugged module everywhere. If you wish
+ # to do so, uncomment the following line.
+ #
+ # config.use :slugged
+ #
+ # By default, FriendlyId's :slugged addon expects the slug column to be named
+ # 'slug', but you can change it if you wish.
+ #
+ # config.slug_column = 'slug'
+ #
+ # By default, slug has no size limit, but you can change it if you wish.
+ #
+ # config.slug_limit = 255
+ #
+ # When FriendlyId can not generate a unique ID from your base method, it appends
+ # a UUID, separated by a single dash. You can configure the character used as the
+ # separator. If you're upgrading from FriendlyId 4, you may wish to replace this
+ # with two dashes.
+ #
+ # config.sequence_separator = '-'
+ #
+ # Note that you must use the :slugged addon **prior** to the line which
+ # configures the sequence separator, or else FriendlyId will raise an undefined
+ # method error.
+ #
+ # ## Tips and Tricks
+ #
+ # ### Controlling when slugs are generated
+ #
+ # As of FriendlyId 5.0, new slugs are generated only when the slug field is
+ # nil, but if you're using a column as your base method can change this
+ # behavior by overriding the `should_generate_new_friendly_id?` method that
+ # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
+ # more like 4.0.
+ # Note: Use(include) Slugged module in the config if using the anonymous module.
+ # If you have `friendly_id :name, use: slugged` in the model, Slugged module
+ # is included after the anonymous module defined in the initializer, so it
+ # overrides the `should_generate_new_friendly_id?` method from the anonymous module.
+ #
+ # config.use :slugged
+ # config.use Module.new {
+ # def should_generate_new_friendly_id?
+ # slug.blank? || _changed?
+ # end
+ # }
+ #
+ # FriendlyId uses Rails's `parameterize` method to generate slugs, but for
+ # languages that don't use the Roman alphabet, that's not usually sufficient.
+ # Here we use the Babosa library to transliterate Russian Cyrillic slugs to
+ # ASCII. If you use this, don't forget to add "babosa" to your Gemfile.
+ #
+ # config.use Module.new {
+ # def normalize_friendly_id(text)
+ # text.to_slug.normalize! :transliterations => [:russian, :latin]
+ # end
+ # }
+end
diff --git a/config/locales/models/connections.pt-BR.yml b/config/locales/models/connections.pt-BR.yml
index a8d1387..07cd5f6 100644
--- a/config/locales/models/connections.pt-BR.yml
+++ b/config/locales/models/connections.pt-BR.yml
@@ -29,4 +29,7 @@ pt-BR:
connections_mailer:
notify_follow:
- subject: 'Alguém seguiu seu perfil'
\ No newline at end of file
+ subject: 'Alguém seguiu seu perfil'
+ greeting: Olá, %{recipient}!
+ access_profile: para acessar seu perfil e continuar interagindo.
+ regards: Abraços,
\ No newline at end of file
diff --git a/config/locales/models/invitation.pt-BR.yml b/config/locales/models/invitation.pt-BR.yml
index 019e826..c17d43b 100644
--- a/config/locales/models/invitation.pt-BR.yml
+++ b/config/locales/models/invitation.pt-BR.yml
@@ -32,5 +32,8 @@ pt-BR:
invitations_mailer:
received_invitation:
+ greeting: Olá, %{recipient}!
subject: 'Você recebeu um convite'
- body: Você recebeu um convite para participar do projeto %{title}.
+ body: Você recebeu um convite para participar do projeto %{title}.
+ access_invitations: para ver seus convites e aceitá-los.
+ regards: Abraços,
diff --git a/config/portfoliorrr_api_v1.yml b/config/portfoliorrr_api_v1.yml
new file mode 100644
index 0000000..75c9712
--- /dev/null
+++ b/config/portfoliorrr_api_v1.yml
@@ -0,0 +1,11 @@
+development:
+ base_url: 'http://localhost:4000'
+ invitations_url: '/api/v1/invitations/'
+ request_invitation_url: '/api/v1/projects/request_invitation'
+ projects_url: '/api/v1/projects'
+
+test:
+ base_url: 'http://localhost:4000'
+ invitations_url: '/api/v1/invitations/'
+ request_invitation_url: '/api/v1/projects/request_invitation'
+ projects_url: '/api/v1/projects'
diff --git a/db/migrate/20240215115659_add_slug_to_profiles.rb b/db/migrate/20240215115659_add_slug_to_profiles.rb
new file mode 100644
index 0000000..e8983ab
--- /dev/null
+++ b/db/migrate/20240215115659_add_slug_to_profiles.rb
@@ -0,0 +1,6 @@
+class AddSlugToProfiles < ActiveRecord::Migration[7.1]
+ def change
+ add_column :profiles, :slug, :string
+ add_index :profiles, :slug, unique: true
+ end
+end
diff --git a/db/migrate/20240215171014_add_slug_to_posts.rb b/db/migrate/20240215171014_add_slug_to_posts.rb
new file mode 100644
index 0000000..8b0745c
--- /dev/null
+++ b/db/migrate/20240215171014_add_slug_to_posts.rb
@@ -0,0 +1,6 @@
+class AddSlugToPosts < ActiveRecord::Migration[7.1]
+ def change
+ add_column :posts, :slug, :string
+ add_index :posts, :slug, unique: true
+ end
+end
diff --git a/db/migrate/20240215173337_add_slug_to_invitations.rb b/db/migrate/20240215173337_add_slug_to_invitations.rb
new file mode 100644
index 0000000..ee67bf3
--- /dev/null
+++ b/db/migrate/20240215173337_add_slug_to_invitations.rb
@@ -0,0 +1,6 @@
+class AddSlugToInvitations < ActiveRecord::Migration[7.1]
+ def change
+ add_column :invitations, :slug, :string
+ add_index :invitations, :slug, unique: true
+ end
+end
diff --git a/db/migrate/20240215181135_create_friendly_id_slugs.rb b/db/migrate/20240215181135_create_friendly_id_slugs.rb
new file mode 100644
index 0000000..a09491d
--- /dev/null
+++ b/db/migrate/20240215181135_create_friendly_id_slugs.rb
@@ -0,0 +1,21 @@
+MIGRATION_CLASS =
+ if ActiveRecord::VERSION::MAJOR >= 5
+ ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
+ else
+ ActiveRecord::Migration
+ end
+
+class CreateFriendlyIdSlugs < MIGRATION_CLASS
+ def change
+ create_table :friendly_id_slugs do |t|
+ t.string :slug, null: false
+ t.integer :sluggable_id, null: false
+ t.string :sluggable_type, limit: 50
+ t.string :scope
+ t.datetime :created_at
+ end
+ add_index :friendly_id_slugs, [:sluggable_type, :sluggable_id]
+ add_index :friendly_id_slugs, [:slug, :sluggable_type], length: {slug: 140, sluggable_type: 50}
+ add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], length: {slug: 70, sluggable_type: 50, scope: 70}, unique: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1e32535..5aa8144 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_02_14_151256) do
+ActiveRecord::Schema[7.1].define(version: 2024_02_15_181135) do
create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
t.text "body"
@@ -84,6 +84,17 @@
t.index ["profile_id"], name: "index_education_infos_on_profile_id"
end
+ create_table "friendly_id_slugs", force: :cascade do |t|
+ t.string "slug", null: false
+ t.integer "sluggable_id", null: false
+ t.string "sluggable_type", limit: 50
+ t.string "scope"
+ t.datetime "created_at"
+ t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
+ t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
+ t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id"
+ end
+
create_table "invitation_requests", force: :cascade do |t|
t.integer "profile_id", null: false
t.text "message"
@@ -108,7 +119,9 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "project_id", null: false
+ t.string "slug"
t.index ["profile_id"], name: "index_invitations_on_profile_id"
+ t.index ["slug"], name: "index_invitations_on_slug", unique: true
end
create_table "job_categories", force: :cascade do |t|
@@ -166,6 +179,8 @@
t.integer "status", default: 0
t.datetime "published_at"
t.string "old_status"
+ t.string "slug"
+ t.index ["slug"], name: "index_posts_on_slug", unique: true
t.index ["user_id"], name: "index_posts_on_user_id"
end
@@ -203,6 +218,8 @@
t.integer "privacy", default: 10
t.integer "status", default: 5
t.boolean "removed", default: false
+ t.string "slug"
+ t.index ["slug"], name: "index_profiles_on_slug", unique: true
t.index ["user_id"], name: "index_profiles_on_user_id"
end
diff --git a/db/seeds/superseed.rb b/db/seeds/superseed.rb
index bc3a8be..12b937e 100644
--- a/db/seeds/superseed.rb
+++ b/db/seeds/superseed.rb
@@ -58,6 +58,7 @@
]
# Adiciona usuários, perfis, informações pessoais
+print "\n4. criando usuários "
@number_of_users.times do
user = FactoryBot.create(:user, :seed)
profile = FactoryBot.create(:profile, :seed, user:)
@@ -65,10 +66,11 @@
personal_info = FactoryBot.create(:personal_info, :seed, profile:)
# Adiciona experiências profissionais
- FactoryBot.create(:professional_info, :first_seed, profile:)
+ FactoryBot.create(:professional_info, :first_job, profile:)
rand(2..7).times do
- FactoryBot.create(:professional_info, :seed, profile:)
+ FactoryBot.create(:professional_info, :seed_job, profile:)
end
+ FactoryBot.create(:professional_info, :current_job, profile:)
# Adiciona experiências acadêmicas
FactoryBot.create(:education_info, :first_seed, profile:)
@@ -85,34 +87,33 @@
job_category: job_categories.sample,
description: Faker::Lorem.paragraph)
end
+ print '.'
+end
- # Cria um post com imagem e outros posts somente texto (WIP)
+# Para cada user cria um post com imagem e de um a três sem imagens
+print "\n3. criando postagens "
+User.all.each do |user|
html_post = %()
- FactoryBot.create(:post,
- :published,
- title: Faker::Lorem.sentence, content: "#{Faker::Lorem.paragraphs(number: rand(3..6)).join(' ')} #{html_post}",
- tag_list: [tags].sample,
- user:)
+ FactoryBot.create(:post, :seed, user:, content: "#{Faker::Lorem.paragraphs(number: 3).join(' ')} #{html_post}")
rand(1..3).times do
- FactoryBot.create(:post,
- :published,
- title: Faker::Lorem.sentence,
- content: "#{Faker::Lorem.paragraphs(number: rand(3..6)).join(' ')}",
- tag_list: [tags].sample,
- user:)
+ FactoryBot.create(:post, :seed, user:)
end
+ print '.'
end
# Adiciona followers aos perfis
+print "\n2. estabelecendo seguidores e seguidos "
User.all.each do |user|
rand(2..5).times do
not_followed_profiles = Profile.all.reject { |profile| profile.following?(user.profile) }
followed_profile = not_followed_profiles.sample if not_followed_profiles.any?
Connection.create!(follower: user.profile, followed_profile:) unless followed_profile == user.profile
end
+ print '.'
end
# Adiciona comentários e likes
+print "\n1. criando comentários e dando likes "
Post.all.each do |post|
rand(0..10).times do
FactoryBot.create(:like, likeable: post, user: User.all.reject { |user| post.likes.pluck(:user_id).include?(user.id) }.sample)
@@ -123,7 +124,9 @@
FactoryBot.create(:like, likeable: comment, user: User.all.reject { |user| comment.likes.pluck(:user_id).include?(user.id) }.sample)
end
end
+ print '.'
end
-puts "Pronto! #{@number_of_users} usuários criados."
+puts "\nPronto! #{@number_of_users} usuários criados."
puts "Admin: #{admin.email}, senha: #{admin.password}"
+puts "\n"
diff --git a/spec/factories/posts.rb b/spec/factories/posts.rb
index f4e2404..c40477d 100644
--- a/spec/factories/posts.rb
+++ b/spec/factories/posts.rb
@@ -1,13 +1,36 @@
FactoryBot.define do
+ def long_post
+ 'very big sentence'
+ end
+
factory :post do
user
title { Faker::Lorem.sentence }
- content { Faker::Lorem.paragraph sentence_count: rand(35..50) }
+ content { Faker::Lorem.paragraph sentence_count: rand(2..12) }
edited_at { Time.zone.now }
trait :published do
published_at { Time.zone.now }
status { :published }
end
+
+ trait :seed do
+ content do
+ [
+ Faker::Lorem.paragraph(sentence_count: rand(4..18)),
+ Faker::Lorem.paragraph(sentence_count: rand(2..18)),
+ Faker::Lorem.paragraph(sentence_count: rand(4..18)),
+ Faker::Lorem.paragraph(sentence_count: rand(4..18)),
+ Faker::Lorem.paragraph(sentence_count: rand(4..18))
+ ].join('
')
+ end
+ tag_list do
+ [
+ %w[tdd rubocop], %w[seeds desafios], %w[boaspraticas solid], %w[vue zoom], %w[vue desafios],
+ %w[codesaga desafios tdd], %w[rubocop vue seeds], %w[zoom boaspraticas solid],
+ %w[tdd codesaga], %w[rubocop vue desafios], %w[seeds boaspraticas zoom], %w[solid codesaga]
+ ].sample
+ end
+ end
end
end
diff --git a/spec/factories/professional_infos.rb b/spec/factories/professional_infos.rb
index 827a72e..fbe5106 100644
--- a/spec/factories/professional_infos.rb
+++ b/spec/factories/professional_infos.rb
@@ -12,22 +12,34 @@
position { %w[programador estagiário gerente].sample }
end
- trait :first_seed do
+ trait :first_job do
company { Faker::Company.name }
position { Faker::Job.position }
+ description { Faker::Lorem.sentences(number: 6) }
profile
start_date { Faker::Date.backward(days: Time.zone.today - profile.personal_info.birth_date + 5840) }
end_date { Faker::Date.between(from: start_date, to: start_date.advance(months: rand(2..120))) }
end
- trait :seed do
+ trait :seed_job do
company { Faker::Company.name }
position { Faker::Job.position }
+ description { Faker::Lorem.sentences(number: 6) }
start_date do
Faker::Date.between(from: profile.professional_infos.last.end_date,
to: profile.professional_infos.last.end_date.advance(months: rand(2..12)))
end
end_date { Faker::Date.between(from: start_date, to: start_date.advance(months: rand(2..120))) }
end
+
+ trait :current_job do
+ company { Faker::Company.name }
+ position { Faker::Job.position }
+ description { Faker::Lorem.sentences(number: 6) }
+ profile
+ start_date { Faker::Date.backward(days: Time.zone.today - profile.personal_info.birth_date + 5840) }
+ end_date {}
+ current_job { true }
+ end
end
end
diff --git a/spec/jobs/request_invitation_job_spec.rb b/spec/jobs/request_invitation_job_spec.rb
index d72a645..7b97c16 100644
--- a/spec/jobs/request_invitation_job_spec.rb
+++ b/spec/jobs/request_invitation_job_spec.rb
@@ -3,11 +3,7 @@
RSpec.describe RequestInvitationJob, type: :job do
it 'altera a solicitação de convite para pending caso receba uma confirmação de sucesso do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
- project_id: invitation_request.project_id,
- profile_id: invitation_request.profile.id,
- email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ invitation_request_params = { invitation_request_id: invitation_request.id }.as_json
json_proposal_response = File.read(Rails.root.join('./spec/support/json/proposal_201.json'))
fake_portfoliorrr_response = double('faraday_response', status: :ok, body: json_proposal_response)
@@ -30,11 +26,7 @@
it 'enfileira um novo job caso receba um aviso de erro no servidor do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
- project_id: invitation_request.project_id,
- profile_id: invitation_request.profile.id,
- email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ invitation_request_params = { invitation_request_id: invitation_request.id }.as_json
fake_colabora_response_body = { 'errors': ['Erro interno de servidor.'] }.as_json
fake_portfoliorrr_response = double('faraday_response', status: :ok, body: fake_colabora_response_body)
@@ -57,11 +49,7 @@
it 'altera a solicitação de convite para error caso receba um aviso de erro do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
- project_id: invitation_request.project_id,
- profile_id: invitation_request.profile.id,
- email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ invitation_request_params = { invitation_request_id: invitation_request.id }.as_json
fake_colabora_response_body = { 'errors': ['Usuário já faz parte deste projeto'] }.as_json
fake_portfoliorrr_response = double('faraday_response', status: :ok, body: fake_colabora_response_body)
@@ -84,11 +72,7 @@
it 'altera a solicitação de convite para aborted se receber pela quinta vez um erro da API do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
- project_id: invitation_request.project_id,
- profile_id: invitation_request.profile.id,
- email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ invitation_request_params = { invitation_request_id: invitation_request.id }.as_json
fake_colabora_response_body = { 'errors': ['Erro interno de servidor.'] }.as_json
fake_portfoliorrr_response = double('faraday_response', status: :ok, body: fake_colabora_response_body)
@@ -114,11 +98,7 @@
it 'gera uma nova tentativa caso a API do Portfoliorrr esteja fora do ar, sem limite de tentativas' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
- project_id: invitation_request.project_id,
- profile_id: invitation_request.profile.id,
- email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ invitation_request_params = { invitation_request_id: invitation_request.id }.as_json
fake_response_body = { 'error': 'Houve um erro interno no servidor ao processar sua solicitação.' }.as_json
fake_portfoliorrr_response = double('faraday_response', status: :internal_server_error, body: fake_response_body)
diff --git a/spec/mailer/connections_mailer_spec.rb b/spec/mailer/connections_mailer_spec.rb
index 9656f87..ecffb2f 100644
--- a/spec/mailer/connections_mailer_spec.rb
+++ b/spec/mailer/connections_mailer_spec.rb
@@ -14,7 +14,8 @@
expect(mail.subject).to include 'Alguém seguiu seu perfil'
expect(mail.to).to eq [followed_profile.email]
expect(mail.from).to eq ['notifications@portfoliorrr.com']
- expect(mail.body).to include 'Danilo Martins começou a seguir você'
+ expect(mail.body).to include ""
+ expect(mail.body).to include 'Danilo Martins começou a seguir você'
end
end
end
diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb
index 217d17f..5c2c04c 100644
--- a/spec/models/profile_spec.rb
+++ b/spec/models/profile_spec.rb
@@ -248,4 +248,35 @@
expect(Connection.active.count).to eq 2
end
end
+
+ describe '#order_by_premium' do
+ it 'retorna perfis premium primeiro e depois os perfis free' do
+ create(:user, :free, full_name: 'André Porteira')
+ create(:user, :free, full_name: 'Eliseu Ramos')
+ create(:user, full_name: 'Moisés Campus')
+ user_premium_inactive = create(:user, full_name: 'Joao Almeida')
+ user_premium_inactive.subscription.inactive!
+
+ result = Profile.order_by_premium
+
+ expect(result.first.full_name).to eq 'Moisés Campus'
+ expect(result.second.full_name).to eq 'André Porteira'
+ expect(result.third.full_name).to eq 'Eliseu Ramos'
+ expect(result.fourth.full_name).to eq 'Joao Almeida'
+ end
+
+ it 'ordena por nome em caso de mesmo status de assinatura' do
+ create(:user, :free, full_name: 'André Almeida')
+ create(:user, :free, full_name: 'André Barbosa')
+ create(:user, full_name: 'André Campus')
+ create(:user, full_name: 'André Dias')
+
+ result = Profile.order_by_premium
+
+ expect(result.first.full_name).to eq 'André Campus'
+ expect(result.second.full_name).to eq 'André Dias'
+ expect(result.third.full_name).to eq 'André Almeida'
+ expect(result.fourth.full_name).to eq 'André Barbosa'
+ end
+ end
end
diff --git a/spec/requests/apis/v1/projects/projects_request_invitations_api_spec.rb b/spec/requests/apis/v1/projects/projects_request_invitations_api_spec.rb
index c02a437..39d086b 100644
--- a/spec/requests/apis/v1/projects/projects_request_invitations_api_spec.rb
+++ b/spec/requests/apis/v1/projects/projects_request_invitations_api_spec.rb
@@ -4,25 +4,19 @@
context 'GET /api/v1/projects/request_invitation' do
it 'com sucesso e recebe confirmação da criação de proposal' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id.to_s,
- project_id: invitation_request.project_id.to_s,
- profile_id: invitation_request.profile.id.to_s,
+ invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ message: invitation_request.message,
+ profile_id: invitation_request.profile.id,
+ project_id: invitation_request.project_id } } }.as_json
json_proposal_response = File.read(Rails.root.join('./spec/support/json/proposal_201.json'))
fake_colabora_response = double('faraday_response', status: 201, body: json_proposal_response)
- colabora_api_connection = double('Faraday::Connection', post: fake_colabora_response)
- allow(Faraday).to receive(:new)
- .with(url: 'http://localhost:3000', params: invitation_request_params['data'])
- .and_return(colabora_api_connection)
- allow(colabora_api_connection)
- .to receive(:post)
- .with('/api/v1/proposals')
- .and_return(fake_colabora_response)
-
- get '/api/v1/projects/request_invitation', params: invitation_request_params
+ url = 'http://localhost:3000/api/v1/proposals'
+ allow(Faraday).to receive(:post).with(url, invitation_request_params['data'])
+ .and_return(fake_colabora_response)
+ get '/api/v1/projects/request_invitation', params: { invitation_request_id: invitation_request.id }.as_json
expect(response).to have_http_status :ok
expect(response.content_type).to include 'application/json'
json_response = JSON.parse(response.body)
@@ -32,24 +26,19 @@
it 'com sucesso, mas recebe alerta de erro 404 do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id.to_s,
- project_id: invitation_request.project_id.to_s,
- profile_id: invitation_request.profile.id.to_s,
+ invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ message: invitation_request.message,
+ profile_id: invitation_request.profile.id,
+ project_id: invitation_request.project_id } } }.as_json
+ url = 'http://localhost:3000/api/v1/proposals'
fake_colabora_response_body = { 'errors': ['Projeto não encontrado'] }.as_json
fake_colabora_response = double('faraday_response', status: 404, body: fake_colabora_response_body)
- colabora_api_connection = double('Faraday::Connection', post: fake_colabora_response)
- allow(Faraday).to receive(:new)
- .with(url: 'http://localhost:3000', params: invitation_request_params['data'])
- .and_return(colabora_api_connection)
- allow(colabora_api_connection)
- .to receive(:post)
- .with('/api/v1/proposals')
- .and_return(fake_colabora_response)
+ allow(Faraday).to receive(:post).with(url, invitation_request_params['data'])
+ .and_return(fake_colabora_response)
- get '/api/v1/projects/request_invitation', params: invitation_request_params
+ get '/api/v1/projects/request_invitation', params: { invitation_request_id: invitation_request.id }.as_json
expect(response).to have_http_status :ok
expect(response.content_type).to include 'application/json'
@@ -60,24 +49,19 @@
it 'com sucesso, mas recebe alerta de erro 409 do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id.to_s,
- project_id: invitation_request.project_id.to_s,
- profile_id: invitation_request.profile.id.to_s,
+ invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ message: invitation_request.message,
+ profile_id: invitation_request.profile.id,
+ project_id: invitation_request.project_id } } }.as_json
+ url = 'http://localhost:3000/api/v1/proposals'
fake_colabora_response_body = { 'errors': ['Usuário já faz parte deste projeto'] }.as_json
fake_colabora_response = double('faraday_response', status: 409, body: fake_colabora_response_body)
- colabora_api_connection = double('Faraday::Connection', post: fake_colabora_response)
- allow(Faraday).to receive(:new)
- .with(url: 'http://localhost:3000', params: invitation_request_params['data'])
- .and_return(colabora_api_connection)
- allow(colabora_api_connection)
- .to receive(:post)
- .with('/api/v1/proposals')
- .and_return(fake_colabora_response)
+ allow(Faraday).to receive(:post).with(url, invitation_request_params['data'])
+ .and_return(fake_colabora_response)
- get '/api/v1/projects/request_invitation', params: invitation_request_params
+ get '/api/v1/projects/request_invitation', params: { invitation_request_id: invitation_request.id }.as_json
expect(response).to have_http_status :ok
expect(response.content_type).to include 'application/json'
@@ -88,24 +72,19 @@
it 'com sucesso, mas recebe alerta de erro 500 do Cola?Bora!' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id.to_s,
- project_id: invitation_request.project_id.to_s,
- profile_id: invitation_request.profile.id.to_s,
+ invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ message: invitation_request.message,
+ profile_id: invitation_request.profile.id,
+ project_id: invitation_request.project_id } } }.as_json
+ url = 'http://localhost:3000/api/v1/proposals'
fake_colabora_response_body = { 'errors': ['Erro interno de servidor.'] }.as_json
fake_colabora_response = double('faraday_response', status: 500, body: fake_colabora_response_body)
- colabora_api_connection = double('Faraday::Connection', post: fake_colabora_response)
- allow(Faraday).to receive(:new)
- .with(url: 'http://localhost:3000', params: invitation_request_params['data'])
- .and_return(colabora_api_connection)
- allow(colabora_api_connection)
- .to receive(:post)
- .with('/api/v1/proposals')
- .and_return(fake_colabora_response)
+ allow(Faraday).to receive(:post).with(url, invitation_request_params['data'])
+ .and_return(fake_colabora_response)
- get '/api/v1/projects/request_invitation', params: invitation_request_params
+ get '/api/v1/projects/request_invitation', params: { invitation_request_id: invitation_request.id }.as_json
expect(response).to have_http_status :ok
expect(response.content_type).to include 'application/json'
@@ -116,17 +95,17 @@
it 'e retorna erro interno do servidor no Portfoliorrr' do
invitation_request = create(:invitation_request)
- invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id.to_s,
- project_id: invitation_request.project_id.to_s,
- profile_id: invitation_request.profile.id.to_s,
+ invitation_request_params = { data: { proposal: { invitation_request_id: invitation_request.id,
email: invitation_request.profile.email,
- message: invitation_request.message } } }.as_json
+ message: invitation_request.message,
+ profile_id: invitation_request.profile.id,
+ project_id: invitation_request.project_id } } }.as_json
- allow(Faraday).to receive(:new)
- .with(url: 'http://localhost:3000', params: invitation_request_params['data'])
- .and_raise(ActiveRecord::ConnectionNotEstablished)
+ url = 'http://localhost:3000/api/v1/proposals'
+ allow(Faraday).to receive(:post).with(url, invitation_request_params['data'])
+ .and_raise(ActiveRecord::ConnectionNotEstablished)
- get '/api/v1/projects/request_invitation', params: invitation_request_params
+ get '/api/v1/projects/request_invitation', params: { invitation_request_id: invitation_request.id }.as_json
expect(response).to have_http_status :internal_server_error
json_response = JSON.parse(response.body)
diff --git a/spec/requests/apis/v1/search_user_by_job_categories_spec.rb b/spec/requests/apis/v1/search_user_by_job_categories_spec.rb
index b8a5ccb..4c821f1 100644
--- a/spec/requests/apis/v1/search_user_by_job_categories_spec.rb
+++ b/spec/requests/apis/v1/search_user_by_job_categories_spec.rb
@@ -67,13 +67,13 @@
expect(json_response['data'].class).to eq Array
expect(json_response['data'].first.keys).not_to include 'created_at'
expect(json_response['data'].first.keys).not_to include 'updated_at'
- expect(json_response['data'].first['profile_id']).to eq 1
- expect(json_response['data'].first['full_name']).to eq 'Joao Almeida'
- expect(json_response['data'].first['job_categories']).to eq [{ 'name' => 'Ruby on Rails',
- 'description' => 'Especialista em Ruby.' }]
- expect(json_response['data'].second['profile_id']).to eq 2
- expect(json_response['data'].second['full_name']).to eq 'André Porteira'
- expect(json_response['data'].second['job_categories']).to eq []
+ expect(json_response['data'].first['profile_id']).to eq 2
+ expect(json_response['data'].first['full_name']).to eq 'André Porteira'
+ expect(json_response['data'].first['job_categories']).to eq []
+ expect(json_response['data'].second['profile_id']).to eq 1
+ expect(json_response['data'].second['full_name']).to eq 'Joao Almeida'
+ expect(json_response['data'].second['job_categories']).to eq [{ 'name' => 'Ruby on Rails',
+ 'description' => 'Especialista em Ruby.' }]
end
it 'retorna um erro interno do servidor' do
@@ -86,5 +86,39 @@
expect(json_response.class).to eq Hash
expect(json_response['error']).to eq 'Houve um erro interno no servidor ao processar sua solicitação.'
end
+
+ it 'retorna perfis premium primeiro e depois os perfis comuns' do
+ create(:user, :free, full_name: 'Eliseu Ramos')
+ create(:user, :free, full_name: 'André Porteira')
+ create(:user, full_name: 'Moisés Campus')
+ create(:user, full_name: 'Joao Almeida')
+
+ get '/api/v1/profiles'
+
+ expect(response.status).to eq 200
+ json_response = JSON.parse(response.body)
+ expect(json_response['data'].count).to eq 4
+ expect(json_response['data'].first['full_name']).to eq 'Joao Almeida'
+ expect(json_response['data'].second['full_name']).to eq 'Moisés Campus'
+ expect(json_response['data'].third['full_name']).to eq 'André Porteira'
+ expect(json_response['data'].fourth['full_name']).to eq 'Eliseu Ramos'
+ end
+
+ it 'retorna perfis premium primeiro e depois os perfis free na busca com parâmetro' do
+ ruby = create(:job_category, name: 'Ruby on Rails')
+
+ user_premium = create(:user, full_name: 'Moisés Campus')
+ user_premium.profile.profile_job_categories.create(job_category: ruby, description: 'Sou um especialista em Ruby')
+ user_free = create(:user, :free, full_name: 'André Almeida')
+ user_free.profile.profile_job_categories.create(job_category: ruby, description: 'Fiz um e-commerce em Ruby')
+
+ get '/api/v1/profiles', params: { search: 'ruby' }
+
+ expect(response.status).to eq 200
+ json_response = JSON.parse(response.body)
+ expect(json_response['data'].count).to eq 2
+ expect(json_response['data'].first['full_name']).to eq 'Moisés Campus'
+ expect(json_response['data'].second['full_name']).to eq 'André Almeida'
+ end
end
end
diff --git a/spec/services/invitation_request_service/colabora_invitation_request_post_spec.rb b/spec/services/invitation_request_service/colabora_invitation_request_post_spec.rb
new file mode 100644
index 0000000..8d8830e
--- /dev/null
+++ b/spec/services/invitation_request_service/colabora_invitation_request_post_spec.rb
@@ -0,0 +1,18 @@
+require 'rails_helper'
+
+RSpec.describe InvitationRequestService::ColaBoraInvitationRequestPost do
+ context '.send' do
+ it 'retorna a resposta da requisição feita ao ColaBora' do
+ invitation_request = create(:invitation_request)
+ fake_colabora_body = File.read(Rails.root.join('./spec/support/json/proposal_201.json'))
+ fake_colabora_response = double('faraday_response', status: 201, body: fake_colabora_body)
+ allow(Faraday).to receive(:post).and_return(fake_colabora_response)
+
+ response = InvitationRequestService::ColaBoraInvitationRequestPost.send(invitation_request)
+
+ json_response = JSON.parse(response.body)
+ expect(json_response.class).to eq Hash
+ expect(json_response['data']['proposal_id']).to eq 1
+ end
+ end
+end
diff --git a/spec/services/projects_service/colabora_api_get_projects_spec.rb b/spec/services/projects_service/colabora_api_get_projects_spec.rb
new file mode 100644
index 0000000..ebfcffa
--- /dev/null
+++ b/spec/services/projects_service/colabora_api_get_projects_spec.rb
@@ -0,0 +1,18 @@
+require 'rails_helper'
+
+RSpec.describe ProjectsService::ColaBoraApiGetProjects do
+ context '.send' do
+ it 'retorna array de objetos do tipo Project' do
+ json_data = File.read(Rails.root.join('./spec/support/json/projects.json'))
+ fake_response = double('faraday_response', success?: true, body: json_data)
+
+ allow(Faraday).to receive(:get).with('http://localhost:3000/api/v1/projects').and_return(fake_response)
+
+ result = ProjectsService::ColaBoraApiGetProjects.send
+
+ json_response = JSON.parse(result.body)
+ expect(json_response.class).to eq Array
+ expect(json_response.count).to eq 4
+ end
+ end
+end
diff --git a/spec/services/invitation_request_service/colabora_project_spec.rb b/spec/services/projects_service/colabora_project_spec.rb
similarity index 82%
rename from spec/services/invitation_request_service/colabora_project_spec.rb
rename to spec/services/projects_service/colabora_project_spec.rb
index 8dcab46..7917426 100644
--- a/spec/services/invitation_request_service/colabora_project_spec.rb
+++ b/spec/services/projects_service/colabora_project_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-RSpec.describe InvitationRequestService::ColaboraProject do
+RSpec.describe ProjectsService::ColaBoraProject do
context '.send' do
it 'retorna array de objetos do tipo Project' do
json_data = File.read(Rails.root.join('./spec/support/json/projects.json'))
@@ -20,9 +20,9 @@
category: 'Industrial')
]
allow(Faraday).to receive(:get).with('http://localhost:3000/api/v1/projects').and_return(fake_response)
- allow(InvitationRequestService::ColaboraProject).to receive(:build_projects).and_return(projects)
+ allow(ProjectsService::ColaBoraProject).to receive(:build_projects).and_return(projects)
- result = InvitationRequestService::ColaboraProject.send
+ result = ProjectsService::ColaBoraProject.send
expect(result.class).to eq Array
expect(result.count).to eq 4
@@ -33,7 +33,7 @@
fake_response = double('faraday_response', success?: false, status: :internal_server_error)
allow(Faraday).to receive(:get).with('http://localhost:3000/api/v1/projects').and_return(fake_response)
- expect { InvitationRequestService::ColaboraProject.send }.to raise_error(StandardError)
+ expect { ProjectsService::ColaBoraProject.send }.to raise_error(StandardError)
end
end
end
diff --git a/spec/system/authentication/visitor_logs_in_spec.rb b/spec/system/authentication/visitor_logs_in_spec.rb
index 08d533f..75eeec6 100644
--- a/spec/system/authentication/visitor_logs_in_spec.rb
+++ b/spec/system/authentication/visitor_logs_in_spec.rb
@@ -59,7 +59,7 @@
click_button class: 'dropdown-toggle'
click_on 'Sair'
- expect(current_path).to eq root_path
+ expect(page).to have_current_path root_path
expect(page).to have_content 'Logout efetuado com sucesso'
end
diff --git a/spec/system/connections/user_follows_another_user_spec.rb b/spec/system/connections/user_follows_another_user_spec.rb
index abdea9e..ce3dd7e 100644
--- a/spec/system/connections/user_follows_another_user_spec.rb
+++ b/spec/system/connections/user_follows_another_user_spec.rb
@@ -17,7 +17,7 @@
expect(mail).to have_received(:deliver_later)
expect(Connection.count).to eq 1
- expect(current_path).to eq profile_path(followed)
+ expect(page).to have_current_path profile_path(followed.profile.slug)
expect(page).to have_content('Agora você está seguindo Eliseu Ramos')
expect(page).not_to have_button('Seguir', exact: true)
expect(page).to have_button('Deixar de Seguir', exact: true)
@@ -28,7 +28,7 @@
visit profile_path(followed.profile)
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
expect(page).to have_content 'Para continuar, faça login ou registre-se.'
end
@@ -43,7 +43,7 @@
click_on 'Seguir'
follower_relationship = Connection.last
- expect(current_path).to eq profile_path(followed.profile)
+ expect(page).to have_current_path profile_path(followed.profile)
expect(follower_relationship).to be_active
expect(page).to have_content('Agora você está seguindo Eliseu Ramos')
expect(page).to have_button('Deixar de Seguir', exact: true)
diff --git a/spec/system/connections/user_unfollows_another_user_spec.rb b/spec/system/connections/user_unfollows_another_user_spec.rb
index 445afbd..bac86ea 100644
--- a/spec/system/connections/user_unfollows_another_user_spec.rb
+++ b/spec/system/connections/user_unfollows_another_user_spec.rb
@@ -12,7 +12,7 @@
click_on 'Deixar de Seguir'
follower_relationship = Connection.last
- expect(current_path).to eq profile_path(followed.profile)
+ expect(page).to have_current_path profile_path(followed.profile)
expect(follower_relationship).to be_inactive
expect(page).to have_content("Você deixou de seguir #{followed.full_name}")
expect(page).to have_button('Seguir', exact: true)
diff --git a/spec/system/connections/user_views_followers_spec.rb b/spec/system/connections/user_views_followers_spec.rb
index 14e5290..7581ef4 100644
--- a/spec/system/connections/user_views_followers_spec.rb
+++ b/spec/system/connections/user_views_followers_spec.rb
@@ -44,7 +44,7 @@
visit profile_following_path(user.profile)
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
end
end
end
diff --git a/spec/system/connections/user_views_following_users_spec.rb b/spec/system/connections/user_views_following_users_spec.rb
index ca3dc57..07ffa42 100644
--- a/spec/system/connections/user_views_following_users_spec.rb
+++ b/spec/system/connections/user_views_following_users_spec.rb
@@ -44,6 +44,6 @@
visit profile_connections_path(user.profile)
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
end
end
diff --git a/spec/system/education_info/user_creates_education_info_spec.rb b/spec/system/education_info/user_creates_education_info_spec.rb
index 005fa91..fbb60ba 100644
--- a/spec/system/education_info/user_creates_education_info_spec.rb
+++ b/spec/system/education_info/user_creates_education_info_spec.rb
@@ -62,7 +62,7 @@
check 'Exibir no Perfil'
click_on 'Salvar'
- expect(current_path).to eq new_user_profile_education_info_path
+ expect(page).to have_current_path new_user_profile_education_info_path
expect(page).to have_content 'Não foi possível cadastrar formação acadêmica'
expect(page).to have_content 'Instituição não pode ficar em branco'
expect(page).to have_content 'Curso não pode ficar em branco'
diff --git a/spec/system/education_info/user_edits_education_info_spec.rb b/spec/system/education_info/user_edits_education_info_spec.rb
index 41dd54f..f4d2b7c 100644
--- a/spec/system/education_info/user_edits_education_info_spec.rb
+++ b/spec/system/education_info/user_edits_education_info_spec.rb
@@ -38,7 +38,7 @@
check 'Exibir no Perfil'
click_on 'Salvar'
- expect(current_path).to eq edit_education_info_path(education_info)
+ expect(page).to have_current_path edit_education_info_path(education_info)
expect(page).to have_content 'Não foi possível atualizar formação acadêmica'
expect(page).to have_content 'Instituição não pode ficar em branco'
expect(page).to have_content 'Curso não pode ficar em branco'
diff --git a/spec/system/invitations/user_views_invitations_spec.rb b/spec/system/invitations/user_views_invitations_spec.rb
index dab5e0b..770f2f5 100644
--- a/spec/system/invitations/user_views_invitations_spec.rb
+++ b/spec/system/invitations/user_views_invitations_spec.rb
@@ -13,7 +13,7 @@
click_on 'Convites'
end
- expect(current_path).to eq invitations_path
+ expect(page).to have_current_path invitations_path
expect(page).to have_content 'Projeto Cola?Bora!'
expect(page).to have_content 'Um projeto muito legal'
expect(page).to have_content "Expira dia: #{I18n.l(invitation.expiration_date, format: :default)}"
@@ -134,6 +134,6 @@
it 'mas precisa estar logado' do
visit invitations_path
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
end
end
diff --git a/spec/system/job_categories/admin_create_job_category_spec.rb b/spec/system/job_categories/admin_create_job_category_spec.rb
index e95af39..2665fbe 100644
--- a/spec/system/job_categories/admin_create_job_category_spec.rb
+++ b/spec/system/job_categories/admin_create_job_category_spec.rb
@@ -17,7 +17,7 @@
it 'e deve estar logado' do
visit job_categories_path
- expect(current_path).to eq(new_user_session_path)
+ expect(page).to have_current_path(new_user_session_path)
expect(page).to have_content('Para continuar, faça login ou registre-se.')
end
diff --git a/spec/system/notifications/user_sees_new_follower_notification_spec.rb b/spec/system/notifications/user_sees_new_follower_notification_spec.rb
index 2e78d64..72b6dd8 100644
--- a/spec/system/notifications/user_sees_new_follower_notification_spec.rb
+++ b/spec/system/notifications/user_sees_new_follower_notification_spec.rb
@@ -22,7 +22,7 @@
visit notifications_path
click_on 'Paulo começou a seguir você'
- expect(page).to have_current_path profile_path(follower)
+ expect(page).to have_current_path profile_path(follower.profile.slug)
expect(Notification.last).to be_clicked
end
end
diff --git a/spec/system/personal_info/user_edits_personal_info_spec.rb b/spec/system/personal_info/user_edits_personal_info_spec.rb
index 9c23dfc..cc2b3df 100644
--- a/spec/system/personal_info/user_edits_personal_info_spec.rb
+++ b/spec/system/personal_info/user_edits_personal_info_spec.rb
@@ -78,7 +78,7 @@
it 'e é redirecionado para a tela de login' do
visit edit_user_profile_path
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
expect(page).to have_content 'Para continuar, faça login ou registre-se'
end
end
diff --git a/spec/system/posts/user_creates_post_spec.rb b/spec/system/posts/user_creates_post_spec.rb
index 6ebc5d4..4c259de 100644
--- a/spec/system/posts/user_creates_post_spec.rb
+++ b/spec/system/posts/user_creates_post_spec.rb
@@ -4,7 +4,7 @@
it 'apenas quando autenticado' do
visit new_post_path
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
end
it 'com sucesso' do
diff --git a/spec/system/posts/user_edits_post_spec.rb b/spec/system/posts/user_edits_post_spec.rb
index f2deff6..425c55b 100644
--- a/spec/system/posts/user_edits_post_spec.rb
+++ b/spec/system/posts/user_edits_post_spec.rb
@@ -37,7 +37,7 @@
login_as user
visit edit_post_path(post)
- expect(current_path).to eq root_path
+ expect(page).to have_current_path root_path
expect(page).to have_content 'Você não pode acessar este conteúdo ou realizar esta ação'
end
@@ -70,7 +70,7 @@
post = create(:post, user:, title: 'Post A', content: 'Primeira postagem')
login_as user
- visit profile_path(user)
+ visit profile_path(user.profile.slug)
within "div#post-#{post.id}" do
click_button id: 'pin'
end
@@ -91,7 +91,7 @@
post = create(:post, user:, title: 'Post A', content: 'Primeira postagem', pin: 'pinned')
login_as user
- visit profile_path(user)
+ visit profile_path(user.profile.slug)
within 'div#fixed' do
click_button id: 'unpin'
end
@@ -111,7 +111,7 @@
post2 = create(:post, user:, title: 'Post B', content: 'Segunda postagem')
login_as user
- visit profile_path(user)
+ visit profile_path(user.profile.slug)
within "div#post-#{post.id}" do
click_button id: 'pin'
end
@@ -134,7 +134,7 @@
other_user = create(:user, citizen_id_number: '61328427056', email: 'visitor@email.com')
login_as other_user
- visit profile_path(user)
+ visit profile_path(user.profile.slug)
expect(page).not_to have_content 'Fixar'
expect(page).not_to have_content 'Desafixar'
diff --git a/spec/system/posts/user_views_post_list_spec.rb b/spec/system/posts/user_views_post_list_spec.rb
index c5eed89..15659ae 100644
--- a/spec/system/posts/user_views_post_list_spec.rb
+++ b/spec/system/posts/user_views_post_list_spec.rb
@@ -13,7 +13,7 @@
click_on 'Pesquisar'
click_on user.full_name
- expect(page).to have_current_path(profile_path(user))
+ expect(page).to have_current_path(profile_path(user.profile.slug))
within 'h2#post-list-title' do
expect(page).to have_content('Publicações')
end
@@ -39,7 +39,7 @@
published_at: 2.days.from_now)
login_as user
- visit profile_path(user)
+ visit profile_path(user.profile.slug)
expect(page).to have_content 'Há 2 dias'
end
@@ -56,7 +56,7 @@
create(:post, user:, title: 'Conteúdo C', content: 'Primeira postagem')
login_as user
- visit profile_path(user)
+ visit profile_path(user.profile.slug)
expect(page.body.index('Conteúdo C')).to be < page.body.index('Texto B')
expect(page.body.index('Texto B')).to be < page.body.index('Post A')
diff --git a/spec/system/posts/visitor_views_post_spec.rb b/spec/system/posts/visitor_views_post_spec.rb
index 23aa44f..df5c740 100644
--- a/spec/system/posts/visitor_views_post_spec.rb
+++ b/spec/system/posts/visitor_views_post_spec.rb
@@ -6,7 +6,7 @@
visit post_path(post)
- expect(current_path).to eq post_path(post)
+ expect(page).to have_current_path post_path(post)
expect(page).to have_content 'Título do post'
expect(page).to have_content 'Conteúdo do post'
expect(page).to have_link "Criado por #{post.user.full_name}", href: profile_path(post.user.profile)
diff --git a/spec/system/professional_info/user_creates_professional_info_spec.rb b/spec/system/professional_info/user_creates_professional_info_spec.rb
index 24bb8cc..49c1463 100644
--- a/spec/system/professional_info/user_creates_professional_info_spec.rb
+++ b/spec/system/professional_info/user_creates_professional_info_spec.rb
@@ -42,7 +42,7 @@
click_on 'Salvar'
- expect(current_path).to eq new_user_profile_professional_info_path
+ expect(page).to have_current_path new_user_profile_professional_info_path
expect(page).to have_content 'Não foi possível cadastrar experiência profissional'
expect(page).to have_content 'Empresa não pode ficar em branco'
@@ -67,7 +67,7 @@
click_on 'Salvar'
- expect(current_path).to eq new_user_profile_professional_info_path
+ expect(page).to have_current_path new_user_profile_professional_info_path
expect(page).to have_content 'Não foi possível cadastrar experiência profissional'
expect(page).to have_content 'Empresa não pode ficar em branco'
diff --git a/spec/system/professional_info/user_edits_professional_info_spec.rb b/spec/system/professional_info/user_edits_professional_info_spec.rb
index 4e462f7..258fbdb 100644
--- a/spec/system/professional_info/user_edits_professional_info_spec.rb
+++ b/spec/system/professional_info/user_edits_professional_info_spec.rb
@@ -47,7 +47,7 @@
click_on 'Salvar'
- expect(current_path).to eq edit_professional_info_path(professional_info)
+ expect(page).to have_current_path edit_professional_info_path(professional_info)
expect(page).to have_content 'Não foi possível atualizar experiência profissional'
expect(page).to have_content 'Empresa não pode ficar em branco'
@@ -93,7 +93,7 @@
visit edit_professional_info_path(professional_info_user1)
- expect(current_path).to eq root_path
+ expect(page).to have_current_path root_path
expect(page).to have_content 'Não foi possível completar sua ação'
end
end
diff --git a/spec/system/profile/user_views_profile_spec.rb b/spec/system/profile/user_views_profile_spec.rb
index d7cc611..2b2b8fb 100644
--- a/spec/system/profile/user_views_profile_spec.rb
+++ b/spec/system/profile/user_views_profile_spec.rb
@@ -91,7 +91,7 @@
it 'e é redirecionado para a página de login' do
user = create(:user)
visit profile_path(user.profile)
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
expect(page).to have_content 'Para continuar, faça login ou registre-se'
end
end
diff --git a/spec/system/reports/admin_sees_reports_listing_page_spec.rb b/spec/system/reports/admin_sees_reports_listing_page_spec.rb
index b13dfa1..28cb320 100644
--- a/spec/system/reports/admin_sees_reports_listing_page_spec.rb
+++ b/spec/system/reports/admin_sees_reports_listing_page_spec.rb
@@ -96,7 +96,7 @@
login_as user
visit reports_path
- expect(current_path).to eq root_path
+ expect(page).to have_current_path root_path
expect(page).to have_content 'Você não têm permissão para realizar essa ação.'
end
end
diff --git a/spec/system/reports/user_report_spec.rb b/spec/system/reports/user_report_spec.rb
index 077e2f0..c26669a 100644
--- a/spec/system/reports/user_report_spec.rb
+++ b/spec/system/reports/user_report_spec.rb
@@ -31,7 +31,7 @@
login_as user
visit new_report_path params: { reportable: post, reportable_type: post.class.name }
- expect(current_path).to eq root_path
+ expect(page).to have_current_path root_path
expect(page).to have_content 'Essa publicação não está disponível.'
end
@@ -209,7 +209,7 @@
visit new_report_path params: { reportable: post, reportable_type: post.class.name }
- expect(current_path).to eq new_user_session_path
+ expect(page).to have_current_path new_user_session_path
expect(page).to have_content 'Para continuar, faça login ou registre-se.'
end
end
diff --git a/spec/system/searches/user_searches_post_by_tag_spec.rb b/spec/system/searches/user_searches_post_by_tag_spec.rb
index 149e382..e6ea0db 100644
--- a/spec/system/searches/user_searches_post_by_tag_spec.rb
+++ b/spec/system/searches/user_searches_post_by_tag_spec.rb
@@ -13,10 +13,10 @@
click_on 'tdd'
end
- expect(current_path).to eq searches_path
expect(page).to have_content post.title
expect(page).to have_content another_post.title
expect(page).not_to have_content other_post.title
+ expect(current_path).to eq searches_path
end
it 'ao buscar por uma hashtag no campo de busca da home' do
@@ -30,11 +30,11 @@
fill_in 'Buscar', with: '#tdd'
click_on 'Pesquisar'
- expect(current_path).to eq searches_path
expect(page).to have_content post.title
expect(page).to have_content another_post.title
expect(page).not_to have_content other_post.title
expect(page).to have_content '2 Publicações com: #tdd'
+ expect(current_path).to eq searches_path
end
it 'deve ser uma busca exata' do
@@ -48,10 +48,10 @@
fill_in 'Buscar', with: '#td'
click_on 'Pesquisar'
- expect(current_path).to eq searches_path
expect(page).not_to have_content post.title
expect(page).not_to have_content another_post.title
expect(page).not_to have_content other_post.title
expect(page).to have_content 'Nenhum resultado encontrado com: #td'
+ expect(current_path).to eq searches_path
end
end
diff --git a/spec/system/searches/user_searches_spec.rb b/spec/system/searches/user_searches_spec.rb
index 40daee1..08916e2 100644
--- a/spec/system/searches/user_searches_spec.rb
+++ b/spec/system/searches/user_searches_spec.rb
@@ -9,7 +9,7 @@
fill_in 'Buscar', with: ''
click_on 'Pesquisar'
- expect(current_path).to eq root_path
+ expect(page).to have_current_path root_path
expect(page).to have_content 'Você precisa informar um termo para fazer a pesquisa'
end
end
diff --git a/spec/system/searches/users_searchs_others_users_spec.rb b/spec/system/searches/users_searchs_others_users_spec.rb
index ed346d7..6811761 100644
--- a/spec/system/searches/users_searchs_others_users_spec.rb
+++ b/spec/system/searches/users_searchs_others_users_spec.rb
@@ -15,7 +15,6 @@
fill_in 'Buscar', with: 'gErAl'
click_on 'Pesquisar'
- expect(current_path).to eq searches_path
expect(page).to have_content('2 resultados para: gErAl')
expect(page).not_to have_content 'Horácio Fernandes'
expect(page).to have_link 'Geraldo José'
@@ -26,6 +25,7 @@
within 'h2' do
expect(page).to have_content 'Resultados da Pesquisa'
end
+ expect(current_path).to eq searches_path
end
it 'e não encontra nenhum usuário' do
diff --git a/spec/system/settings/user_changes_profile_to_private_spec.rb b/spec/system/settings/user_changes_profile_to_private_spec.rb
index 43d11bb..b80b5bb 100644
--- a/spec/system/settings/user_changes_profile_to_private_spec.rb
+++ b/spec/system/settings/user_changes_profile_to_private_spec.rb
@@ -28,10 +28,10 @@
fill_in 'Buscar', with: 'C++'
click_on 'Pesquisar'
- expect(current_path).to eq searches_path
expect(page).to have_content('1 resultado para: C++')
expect(page).not_to have_content private_user.full_name
expect(page).to have_content public_user.full_name
+ expect(current_path).to eq searches_path
end
it 'e dados aparecem aos seguidores' do