Use .reload instead of (true) in specs

Or remove it where not needed
This commit is contained in:
Benjamin Neff 2017-08-06 18:48:39 +02:00
parent 2a6515fab9
commit 7c9590a27c
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
5 changed files with 21 additions and 21 deletions

View file

@ -55,18 +55,18 @@ describe ProfilesController, :type => :controller do
end
it "sets nsfw" do
expect(eve.person(true).profile.nsfw).to eq(false)
expect(eve.person.reload.profile.nsfw).to eq(false)
put :update, params: {profile: {id: eve.person.id, nsfw: "1"}}
expect(eve.person(true).profile.nsfw).to eq(true)
expect(eve.person.reload.profile.nsfw).to eq(true)
end
it "unsets nsfw" do
eve.person.profile.nsfw = true
eve.person.profile.save
expect(eve.person(true).profile.nsfw).to eq(true)
expect(eve.person.reload.profile.nsfw).to eq(true)
put :update, params: {profile: {id: eve.person.id}}
expect(eve.person(true).profile.nsfw).to eq(false)
expect(eve.person.reload.profile.nsfw).to eq(false)
end
it 'sets tags' do
@ -75,7 +75,7 @@ describe ProfilesController, :type => :controller do
:profile => {:tag_string => ''} }
put :update, params: params
expect(eve.person(true).profile.tag_list.to_set).to eq(['apples', 'oranges'].to_set)
expect(eve.person.reload.profile.tag_list.to_set).to eq(%w[apples oranges].to_set)
end
it 'sets plaintext tags' do
@ -84,7 +84,7 @@ describe ProfilesController, :type => :controller do
:profile => {:tag_string => '#pears'} }
put :update, params: params
expect(eve.person(true).profile.tag_list.to_set).to eq(['apples', 'oranges', 'pears'].to_set)
expect(eve.person.reload.profile.tag_list.to_set).to eq(%w[apples oranges pears].to_set)
end
it 'sets plaintext tags without #' do
@ -93,7 +93,7 @@ describe ProfilesController, :type => :controller do
:profile => {:tag_string => 'bananas'} }
put :update, params: params
expect(eve.person(true).profile.tag_list.to_set).to eq(['apples', 'oranges', 'bananas'].to_set)
expect(eve.person.reload.profile.tag_list.to_set).to eq(%w[apples oranges bananas].to_set)
end
it 'sets valid birthday' do
@ -105,9 +105,10 @@ describe ProfilesController, :type => :controller do
:day => '28' } } }
put :update, params: params
expect(eve.person(true).profile.birthday.year).to eq(2001)
expect(eve.person(true).profile.birthday.month).to eq(2)
expect(eve.person(true).profile.birthday.day).to eq(28)
birthday = eve.person.reload.profile.birthday
expect(birthday.year).to eq(2001)
expect(birthday.month).to eq(2)
expect(birthday.day).to eq(28)
end
it 'displays error for invalid birthday' do

View file

@ -36,7 +36,7 @@ describe "attack vectors", type: :request do
post_message(generate_payload(Diaspora::Federation::Entities.profile(profile), alice, bob), bob)
expect(eve.profile(true).first_name).not_to eq("Not BOB")
expect(eve.profile.reload.first_name).not_to eq("Not BOB")
end
it "public post should not be spoofed from another author" do
@ -59,14 +59,14 @@ describe "attack vectors", type: :request do
it "should not receive contact retractions from another person" do
# we are banking on bob being friends with alice and eve
# here, alice is trying to disconnect bob and eve
contact = bob.contacts(true).find_by(person_id: eve.person.id)
contact = bob.contacts.reload.find_by(person_id: eve.person.id)
expect(contact).to be_sharing
post_message(
generate_payload(Diaspora::Federation::Entities.retraction(ContactRetraction.for(contact)), alice, bob), bob
)
expect(bob.contacts(true).find_by(person_id: eve.person.id)).to be_sharing
expect(bob.contacts.reload.find_by(person_id: eve.person.id)).to be_sharing
end
end

View file

@ -161,7 +161,6 @@ describe Contact, type: :model do
describe "#contacts" do
before do
bob.aspects.create(name: "next")
bob.aspects(true)
@original_aspect = bob.aspects.where(name: "generic").first
@new_aspect = bob.aspects.where(name: "next").first

View file

@ -21,7 +21,7 @@ describe User::Connecting, type: :model do
expect {
eve.disconnected_by(alice.person)
}.to change(eve.contacts(true), :count).by(-1)
}.to change(eve.contacts, :count).by(-1)
end
it "does not remove contact if disconnect twice" do
@ -31,7 +31,7 @@ describe User::Connecting, type: :model do
expect {
bob.disconnected_by(alice.person)
bob.disconnected_by(alice.person)
}.not_to change(bob.contacts(true), :count)
}.not_to change(bob.contacts, :count)
contact.reload
expect(contact).not_to be_sharing
@ -50,7 +50,7 @@ describe User::Connecting, type: :model do
it "removes a contacts receiving flag" do
expect(bob.contacts.find_by(person_id: alice.person.id)).to be_receiving
bob.disconnect(bob.contact_for(alice.person))
expect(bob.contacts(true).find_by(person_id: alice.person.id)).not_to be_receiving
expect(bob.contacts.reload.find_by(person_id: alice.person.id)).not_to be_receiving
end
it "removes contact if not sharing" do
@ -58,7 +58,7 @@ describe User::Connecting, type: :model do
expect {
alice.disconnect(contact)
}.to change(alice.contacts(true), :count).by(-1)
}.to change(alice.contacts, :count).by(-1)
end
it "does not remove contact if disconnect twice" do
@ -68,7 +68,7 @@ describe User::Connecting, type: :model do
expect {
alice.disconnect(contact)
alice.disconnect(contact)
}.not_to change(bob.contacts(true), :count)
}.not_to change(bob.contacts, :count)
contact.reload
expect(contact).not_to be_receiving
@ -100,7 +100,7 @@ describe User::Connecting, type: :model do
expect {
alice.disconnect(contact)
}.to change(contact.aspects(true), :count).from(2).to(0)
}.to change(contact.aspects, :count).from(2).to(0)
end
end
end

View file

@ -30,7 +30,7 @@ shared_examples_for "it is taggable" do
it "supports non-ascii characters" do
tag_list.each do |tag|
expect(@object.tags(true).map(&:name)).to include(tag)
expect(@object.tags.reload.map(&:name)).to include(tag)
end
end