Use display in followable shared specs names when referring to DOM elements renderization. Add whitespace to proposal page.

This commit is contained in:
taitus
2017-07-05 15:48:31 +02:00
committed by Senén Rodero Rodríguez
parent 5fe894aa6b
commit e54e33f296
6 changed files with 64 additions and 65 deletions

View File

@@ -97,7 +97,6 @@ ActiveRecord::Schema.define(version: 20170704105112) do
t.integer "budget_id" t.integer "budget_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.integer "ballot_lines_count", default: 0
end end
create_table "budget_groups", force: :cascade do |t| create_table "budget_groups", force: :cascade do |t|

View File

@@ -329,7 +329,7 @@ feature 'Budget Investments' do
end end
end end
scenario "Not sow flaggable buttons" do scenario "Don't display flaggable buttons" do
investment = create(:budget_investment, heading: heading) investment = create(:budget_investment, heading: heading)
visit budget_investment_path(budget_id: budget.id, id: investment.id) visit budget_investment_path(budget_id: budget.id, id: investment.id)

View File

@@ -36,7 +36,7 @@ feature 'Proposal Notifications' do
expect(Notification.count).to eq(1) expect(Notification.count).to eq(1)
end end
scenario "Send a notification (Follower user)" do scenario "Send a notification (Follower)" do
author = create(:user) author = create(:user)
proposal = create(:proposal, author: author) proposal = create(:proposal, author: author)
user_follower = create(:user) user_follower = create(:user)
@@ -47,7 +47,7 @@ feature 'Proposal Notifications' do
expect(Notification.count).to eq(1) expect(Notification.count).to eq(1)
end end
scenario "Send a notification (Follower user and Active voter)" do scenario "Send a notification (Follower and Voter)" do
author = create(:user) author = create(:user)
proposal = create(:proposal, author: author) proposal = create(:proposal, author: author)

View File

@@ -218,7 +218,7 @@ feature 'Users' do
@user = create(:user) @user = create(:user)
end end
scenario 'show interests' do scenario 'Display interests' do
proposal = create(:proposal, tag_list: "Sport") proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user) create(:follow, :followed_proposal, followable: proposal, user: @user)
@@ -234,7 +234,7 @@ feature 'Users' do
expect(page).to have_content("Sport") expect(page).to have_content("Sport")
end end
scenario 'not show interests when proposal has been destroyed' do scenario 'Not display interests when proposal has been destroyed' do
proposal = create(:proposal, tag_list: "Sport") proposal = create(:proposal, tag_list: "Sport")
create(:follow, :followed_proposal, followable: proposal, user: @user) create(:follow, :followed_proposal, followable: proposal, user: @user)
proposal.destroy proposal.destroy
@@ -251,14 +251,14 @@ feature 'Users' do
expect(page).not_to have_content("Sport") expect(page).not_to have_content("Sport")
end end
scenario 'no visible by default' do scenario 'No visible by default' do
visit user_path(@user) visit user_path(@user)
expect(page).to have_content(@user.username) expect(page).to have_content(@user.username)
expect(page).not_to have_css('#public_interests') expect(page).not_to have_css('#public_interests')
end end
scenario 'user can show public page' do scenario 'User can display public page' do
login_as(@user) login_as(@user)
visit account_path visit account_path
@@ -271,7 +271,7 @@ feature 'Users' do
expect(page).to have_css('#public_interests') expect(page).to have_css('#public_interests')
end end
scenario 'is always visible for the owner' do scenario 'Is always visible for the owner' do
login_as(@user) login_as(@user)
visit account_path visit account_path
@@ -282,7 +282,7 @@ feature 'Users' do
expect(page).to have_css('#public_interests') expect(page).to have_css('#public_interests')
end end
scenario 'is always visible for admins' do scenario 'Is always visible for admins' do
login_as(@user) login_as(@user)
visit account_path visit account_path
@@ -296,7 +296,7 @@ feature 'Users' do
expect(page).to have_css('#public_interests') expect(page).to have_css('#public_interests')
end end
scenario 'is always visible for moderators' do scenario 'Is always visible for moderators' do
login_as(@user) login_as(@user)
visit account_path visit account_path

View File

@@ -8,17 +8,17 @@ describe Follow do
expect(follow).to be_valid expect(follow).to be_valid
end end
it "should not be valid without an user_id" do it "should not be valid without a user_id" do
follow.user_id = nil follow.user_id = nil
expect(follow).to_not be_valid expect(follow).to_not be_valid
end end
it "should not be valid without an followable_id" do it "should not be valid without a followable_id" do
follow.followable_id = nil follow.followable_id = nil
expect(follow).to_not be_valid expect(follow).to_not be_valid
end end
it "should not be valid without an followable_type" do it "should not be valid without a followable_type" do
follow.followable_type = nil follow.followable_type = nil
expect(follow).to_not be_valid expect(follow).to_not be_valid
end end

View File

@@ -1,4 +1,4 @@
RSpec.shared_examples "followable" do |followable_class_name, followable_path, followable_path_arguments| shared_examples "followable" do |followable_class_name, followable_path, followable_path_arguments|
include ActionView::Helpers include ActionView::Helpers
let!(:arguments) { {} } let!(:arguments) { {} }
@@ -11,7 +11,9 @@ RSpec.shared_examples "followable" do |followable_class_name, followable_path, f
end end
end end
scenario "Should not show follow button when there is no logged user" do context "Show" do
scenario "Should not display follow button when there is no logged user" do
visit send(followable_path, arguments) visit send(followable_path, arguments)
within "##{dom_id(followable)}" do within "##{dom_id(followable)}" do
@@ -19,7 +21,7 @@ RSpec.shared_examples "followable" do |followable_class_name, followable_path, f
end end
end end
scenario "Should show follow button when user is logged in" do scenario "Should display follow button when user is logged in" do
user = create(:user) user = create(:user)
login_as(user) login_as(user)
@@ -30,7 +32,16 @@ RSpec.shared_examples "followable" do |followable_class_name, followable_path, f
end end
end end
scenario "Following", :js do scenario "Should display follow button when user is logged and is not following" do
user = create(:user)
login_as(user)
visit send(followable_path, arguments)
expect(page).to have_link("Follow")
end
scenario "Should display unfollow button when click on follow button", :js do
user = create(:user) user = create(:user)
login_as(user) login_as(user)
@@ -41,11 +52,9 @@ RSpec.shared_examples "followable" do |followable_class_name, followable_path, f
expect(page).to have_css("#unfollow-expand-#{followable_dom_name}-#{followable.id}") expect(page).to have_css("#unfollow-expand-#{followable_dom_name}-#{followable.id}")
end end
expect(Follow.followed?(user, followable)).to be
end end
scenario "Show unfollow button when user already follow this followable" do scenario "Display unfollow button when user already following" do
user = create(:user) user = create(:user)
follow = create(:follow, user: user, followable: followable) follow = create(:follow, user: user, followable: followable)
login_as(user) login_as(user)
@@ -55,7 +64,7 @@ RSpec.shared_examples "followable" do |followable_class_name, followable_path, f
expect(page).to have_link("Unfollow") expect(page).to have_link("Unfollow")
end end
scenario "Unfollowing", :js do scenario "Should display follow button when click on unfollow button", :js do
user = create(:user) user = create(:user)
follow = create(:follow, user: user, followable: followable) follow = create(:follow, user: user, followable: followable)
login_as(user) login_as(user)
@@ -67,17 +76,8 @@ RSpec.shared_examples "followable" do |followable_class_name, followable_path, f
expect(page).to have_css("#follow-expand-#{followable_dom_name}-#{followable.id}") expect(page).to have_css("#follow-expand-#{followable_dom_name}-#{followable.id}")
end end
end
expect(Follow.followed?(user, followable)).not_to be
end
scenario "Show follow button when user is not following this followable" do
user = create(:user)
login_as(user)
visit send(followable_path, arguments)
expect(page).to have_link("Follow")
end end
end end