* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Blocks", type: :request do
|
|
let(:user) { create(:user, :super_admin) }
|
|
|
|
before { sign_in user }
|
|
|
|
describe "GET blocks index" do
|
|
it "renders proper blocks index" do
|
|
create(:block, user_id: user.id, input_css: ".blue { color: blue;}")
|
|
get "/blocks"
|
|
expect(response.body).to include("color: blue")
|
|
end
|
|
end
|
|
|
|
# rubocop:disable RSpec/ExampleLength
|
|
describe "POST blocks" do
|
|
it "creates block from input data" do
|
|
post "/blocks", params: {
|
|
block: {
|
|
input_css: ".blue { color: blue;}",
|
|
input_html: "yo",
|
|
input_javascript: "alert('hey')",
|
|
},
|
|
}
|
|
expect(Block.all.size).to eq(1)
|
|
end
|
|
end
|
|
|
|
describe "PUT blocks" do
|
|
it "updates block from input data" do
|
|
block = create(:block, user_id: user.id, input_css: ".blue { color: blue;}")
|
|
put "/blocks/#{block.id}", params: {
|
|
block: { input_css: ".blue { color: red;}",
|
|
input_html: "yo",
|
|
input_javascript: "alert('hey')" },
|
|
}
|
|
expect(Block.last.processed_css).to include("color: red")
|
|
end
|
|
end
|
|
# rubocop:enable RSpec/ExampleLength
|
|
|
|
describe "DELETE blocks" do
|
|
it "updates block from input data" do
|
|
block = create(:block, user_id: user.id, input_css: ".blue { color: blue;}")
|
|
delete "/blocks/#{block.id}"
|
|
expect(Block.all.size).to eq(0)
|
|
end
|
|
end
|
|
end
|