mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Update rspec syntax to v3
update rspec syntax to v3 change syntax to rspec v3 oops. fix typo mailers classes with rspec3 syntax helpers with rspec3 syntax jobs with rspec3 syntax serializers with rspec3 syntax views with rspec3 syntax support to rspec3 syntax category spec with rspec3 syntax
This commit is contained in:
@@ -12,12 +12,12 @@ describe BasicPostSerializer do
|
||||
|
||||
it "returns the name it when `enable_names` is true" do
|
||||
SiteSetting.stubs(:enable_names?).returns(true)
|
||||
json[:name].should be_present
|
||||
expect(json[:name]).to be_present
|
||||
end
|
||||
|
||||
it "doesn't return the name it when `enable_names` is false" do
|
||||
SiteSetting.stubs(:enable_names?).returns(false)
|
||||
json[:name].should be_blank
|
||||
expect(json[:name]).to be_blank
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -30,16 +30,16 @@ describe PostSerializer do
|
||||
end
|
||||
|
||||
it "displays the correct info" do
|
||||
visible_actions_for(actor).sort.should == [:like,:notify_user,:spam,:vote]
|
||||
visible_actions_for(post.user).sort.should == [:like,:vote]
|
||||
visible_actions_for(nil).sort.should == [:like,:vote]
|
||||
visible_actions_for(admin).sort.should == [:like,:notify_user,:spam,:vote]
|
||||
expect(visible_actions_for(actor).sort).to eq([:like,:notify_user,:spam,:vote])
|
||||
expect(visible_actions_for(post.user).sort).to eq([:like,:vote])
|
||||
expect(visible_actions_for(nil).sort).to eq([:like,:vote])
|
||||
expect(visible_actions_for(admin).sort).to eq([:like,:notify_user,:spam,:vote])
|
||||
end
|
||||
|
||||
it "can't flag your own post to notify yourself" do
|
||||
serializer = PostSerializer.new(post, scope: Guardian.new(post.user), root: false)
|
||||
notify_user_action = serializer.actions_summary.find { |a| a[:id] == PostActionType.types[:notify_user] }
|
||||
notify_user_action[:can_act].should == false
|
||||
expect(notify_user_action[:can_act]).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,10 +55,10 @@ describe PostSerializer do
|
||||
|
||||
it "serializes correctly" do
|
||||
[:name, :username, :display_username, :avatar_template, :user_title, :trust_level].each do |attr|
|
||||
subject[attr].should be_nil
|
||||
expect(subject[attr]).to be_nil
|
||||
end
|
||||
[:moderator, :staff, :yours].each do |attr|
|
||||
subject[attr].should == false
|
||||
expect(subject[attr]).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -71,12 +71,12 @@ describe PostSerializer do
|
||||
|
||||
it "returns the display_username it when `enable_names` is on" do
|
||||
SiteSetting.stubs(:enable_names).returns(true)
|
||||
json[:display_username].should be_present
|
||||
expect(json[:display_username]).to be_present
|
||||
end
|
||||
|
||||
it "doesn't return the display_username it when `enable_names` is off" do
|
||||
SiteSetting.stubs(:enable_names).returns(false)
|
||||
json[:display_username].should be_blank
|
||||
expect(json[:display_username]).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,7 +95,7 @@ describe PostSerializer do
|
||||
|
||||
it "includes the raw post for everyone" do
|
||||
[nil, user, Fabricate(:user), Fabricate(:moderator), Fabricate(:admin)].each do |user|
|
||||
serialized_post_for_user(user)[:raw].should == raw
|
||||
expect(serialized_post_for_user(user)[:raw]).to eq(raw)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -104,21 +104,21 @@ describe PostSerializer do
|
||||
let(:post) { Fabricate.build(:post, raw: raw, user: user, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached]) }
|
||||
|
||||
it "shows the raw post only if authorized to see it" do
|
||||
serialized_post_for_user(nil)[:raw].should == nil
|
||||
serialized_post_for_user(Fabricate(:user))[:raw].should == nil
|
||||
expect(serialized_post_for_user(nil)[:raw]).to eq(nil)
|
||||
expect(serialized_post_for_user(Fabricate(:user))[:raw]).to eq(nil)
|
||||
|
||||
serialized_post_for_user(user)[:raw].should == raw
|
||||
serialized_post_for_user(Fabricate(:moderator))[:raw].should == raw
|
||||
serialized_post_for_user(Fabricate(:admin))[:raw].should == raw
|
||||
expect(serialized_post_for_user(user)[:raw]).to eq(raw)
|
||||
expect(serialized_post_for_user(Fabricate(:moderator))[:raw]).to eq(raw)
|
||||
expect(serialized_post_for_user(Fabricate(:admin))[:raw]).to eq(raw)
|
||||
end
|
||||
|
||||
it "can view edit history only if authorized" do
|
||||
serialized_post_for_user(nil)[:can_view_edit_history].should == false
|
||||
serialized_post_for_user(Fabricate(:user))[:can_view_edit_history].should == false
|
||||
expect(serialized_post_for_user(nil)[:can_view_edit_history]).to eq(false)
|
||||
expect(serialized_post_for_user(Fabricate(:user))[:can_view_edit_history]).to eq(false)
|
||||
|
||||
serialized_post_for_user(user)[:can_view_edit_history].should == true
|
||||
serialized_post_for_user(Fabricate(:moderator))[:can_view_edit_history].should == true
|
||||
serialized_post_for_user(Fabricate(:admin))[:can_view_edit_history].should == true
|
||||
expect(serialized_post_for_user(user)[:can_view_edit_history]).to eq(true)
|
||||
expect(serialized_post_for_user(Fabricate(:moderator))[:can_view_edit_history]).to eq(true)
|
||||
expect(serialized_post_for_user(Fabricate(:admin))[:can_view_edit_history]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -127,7 +127,7 @@ describe PostSerializer do
|
||||
|
||||
it "can view edit history" do
|
||||
[nil, user, Fabricate(:user), Fabricate(:moderator), Fabricate(:admin)].each do |user|
|
||||
serialized_post_for_user(user)[:can_view_edit_history].should == true
|
||||
expect(serialized_post_for_user(user)[:can_view_edit_history]).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -136,12 +136,12 @@ describe PostSerializer do
|
||||
let(:post) { Fabricate.build(:post, raw: raw, user: user, wiki: true, hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached]) }
|
||||
|
||||
it "can view edit history only if authorized" do
|
||||
serialized_post_for_user(nil)[:can_view_edit_history].should == false
|
||||
serialized_post_for_user(Fabricate(:user))[:can_view_edit_history].should == false
|
||||
expect(serialized_post_for_user(nil)[:can_view_edit_history]).to eq(false)
|
||||
expect(serialized_post_for_user(Fabricate(:user))[:can_view_edit_history]).to eq(false)
|
||||
|
||||
serialized_post_for_user(user)[:can_view_edit_history].should == true
|
||||
serialized_post_for_user(Fabricate(:moderator))[:can_view_edit_history].should == true
|
||||
serialized_post_for_user(Fabricate(:admin))[:can_view_edit_history].should == true
|
||||
expect(serialized_post_for_user(user)[:can_view_edit_history]).to eq(true)
|
||||
expect(serialized_post_for_user(Fabricate(:moderator))[:can_view_edit_history]).to eq(true)
|
||||
expect(serialized_post_for_user(Fabricate(:admin))[:can_view_edit_history]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ describe TopicListItemSerializer do
|
||||
topic.posters = []
|
||||
serialized = TopicListItemSerializer.new(topic, scope: Guardian.new, root: false).as_json
|
||||
|
||||
serialized[:title].should == "test"
|
||||
serialized[:bumped].should == true
|
||||
expect(serialized[:title]).to eq("test")
|
||||
expect(serialized[:bumped]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ describe UserSerializer do
|
||||
let(:untrusted_attributes) { %i{bio_raw bio_cooked bio_excerpt location website profile_background card_background} }
|
||||
|
||||
it "doesn't serialize untrusted attributes" do
|
||||
untrusted_attributes.each { |attr| json.should_not have_key(attr) }
|
||||
untrusted_attributes.each { |attr| expect(json).not_to have_key(attr) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ describe UserSerializer do
|
||||
let(:json) { serializer.as_json }
|
||||
|
||||
it "produces json" do
|
||||
json.should be_present
|
||||
expect(json).to be_present
|
||||
end
|
||||
|
||||
context "with `enable_names` true" do
|
||||
@@ -30,7 +30,7 @@ describe UserSerializer do
|
||||
end
|
||||
|
||||
it "has a name" do
|
||||
json[:name].should be_present
|
||||
expect(json[:name]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ describe UserSerializer do
|
||||
end
|
||||
|
||||
it "has a name" do
|
||||
json[:name].should be_blank
|
||||
expect(json[:name]).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,13 +102,13 @@ describe UserSerializer do
|
||||
|
||||
it "doesn't serialize the fields by default" do
|
||||
json[:custom_fields]
|
||||
json[:custom_fields].should be_empty
|
||||
expect(json[:custom_fields]).to be_empty
|
||||
end
|
||||
|
||||
it "serializes the fields listed in public_user_custom_fields site setting" do
|
||||
SiteSetting.stubs(:public_user_custom_fields).returns('public_field')
|
||||
json[:custom_fields]['public_field'].should == user.custom_fields['public_field']
|
||||
json[:custom_fields]['secret_field'].should == nil
|
||||
expect(json[:custom_fields]['public_field']).to eq(user.custom_fields['public_field'])
|
||||
expect(json[:custom_fields]['secret_field']).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user