* Fix menu dropdown disable issue * Initial base work * Add real algorithm * Add working object and test * Fix schema * Fix schema * Fix schema * Finalize * Add update script and explict_points * Proper implicit/explicit points * Fix tests * Add docs * Fix tests * Fix data update script test * Fix data update script test * Fix typo * Improve efficiency and add more logic * Changed to find_each * Change to bulk insert * Update tests and refactor logic * Various improvements * Fix typo * Fix tests * Remove extra line * Fix tests * Fix test typo * Cache site-wide tag names
27 lines
744 B
Ruby
27 lines
744 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Following/Unfollowing", type: :request do
|
|
let(:user) { create(:user) }
|
|
let(:user_2) { create(:user) }
|
|
let(:tag) { create(:tag) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
describe "PUT follows/:id" do
|
|
it "updates follow points" do
|
|
user.follow(tag)
|
|
put "/follows/#{Follow.last.id}", params: { follow: { explicit_points: 3.0 } }
|
|
expect(Follow.last.explicit_points).to eq(3.0)
|
|
expect(Follow.last.points).to eq(3.0)
|
|
end
|
|
|
|
it "does not update if follow does not belong to user" do
|
|
user_2.follow(tag)
|
|
expect do
|
|
put "/follows/#{Follow.last.id}", params: { follow: { points: 3.0 } }
|
|
end.to raise_error(Pundit::NotAuthorizedError)
|
|
end
|
|
end
|
|
end
|