docbrown/spec/requests/articles/articles_admin_feature_spec.rb
Ben Halpern 66b32215f3
Small win: Add "Feature post" button alongside new "admin actions" drawer in mod panel. (#16544)
* Initial hack

* Begin functionality implementation

* Add proper route

* Finish up

* Fix test and formatting

* Fix test vars

* Update app/views/moderations/actions_panel.html.erb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update app/views/moderations/actions_panel.html.erb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update app/views/moderations/actions_panel.html.erb

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update app/controllers/articles_controller.rb

Co-authored-by: Michael Kohl <me@citizen428.net>

* Update file to not use keys that are not needed

* Finalize featured logic

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Michael Kohl <me@citizen428.net>
2022-02-17 12:43:27 -05:00

34 lines
843 B
Ruby

require "rails_helper"
RSpec.describe "ArticlesAdminFeature", type: :request do
let(:user) { create(:user) }
let(:article) { create(:article, user_id: user.id) }
let(:super_admin) { create(:user, :super_admin) }
before do
sign_in super_admin
end
it "features an article" do
expect(article.featured).to be false
patch "/articles/#{article.id}/admin_featured_toggle", params: {
id: article.id,
article: { featured: 1 }
}
article.reload
expect(article.featured).to be true
end
it "unfeatures an article" do
article.update_column(:featured, true)
expect(article.featured).to be true
patch "/articles/#{article.id}/admin_featured_toggle", params: {
id: article.id,
article: { featured: 0 }
}
article.reload
expect(article.featured).to be false
end
end